C++ Samples
Demonstrates how to create a C++ application using the VideoXpert SDK
CppSamples::Common::Paging Class Reference

Paging class helps to divide a collection into pages of given number of lines. More...

#include <Paging.h>

Public Member Functions

 Paging (int count, int numberInPage)
 Create an instance of Paging class. More...
 
 ~Paging ()
 
int GetCurrentPage () const
 Current page number. It gives 1 for first page. More...
 
int GetEndIndex () const
 Zero based index of last item in the current page. More...
 
int GetPageCount () const
 Total number of pages. More...
 
int GetStartIndex () const
 Zero based index of first item in the current page. More...
 
void NextPage ()
 Move to the next page. More...
 
void PreviousPage ()
 Move to the previous page. More...
 

Private Attributes

int _count
 
int _currentPage
 
int _numberInPage
 
int _pageCount
 

Detailed Description

Paging class helps to divide a collection into pages of given number of lines.

Definition at line 9 of file Paging.h.

Constructor & Destructor Documentation

Paging::Paging ( int  count,
int  numberInPage 
)

Create an instance of Paging class.

Parameters
countTotal number of items in the collection.
numberInPageRequired number of items per page.

Definition at line 7 of file Paging.cpp.

7  {
8  // Initialize the default variables
9  _count = count;
10  _numberInPage = numberInPage;
11  _currentPage = 1;
12 
13  // Calculate total number of pages from given input
14  _pageCount = (count - 1) / numberInPage + 1;
15 }
CppSamples::Common::Paging::~Paging ( )
inline

Definition at line 19 of file Paging.h.

19 { }

Member Function Documentation

int Paging::GetCurrentPage ( ) const

Current page number. It gives 1 for first page.

Definition at line 18 of file Paging.cpp.

18  {
19  // Get current page number
20  return _currentPage;
21 }
int Paging::GetEndIndex ( ) const

Zero based index of last item in the current page.

Definition at line 24 of file Paging.cpp.

24  {
25  // Calculate end index
26  int endIndex = _currentPage *_numberInPage - 1;
27  // Ensure the index is not crossing the limit.
28  if (endIndex >= _count)
29  endIndex = _count - 1;
30  return endIndex;
31 }
int CppSamples::Common::Paging::GetPageCount ( ) const
inline

Total number of pages.

Definition at line 34 of file Paging.h.

34 { return _pageCount; }
int Paging::GetStartIndex ( ) const

Zero based index of first item in the current page.

Definition at line 34 of file Paging.cpp.

34  {
35  // Calculate start index
36  return (_currentPage - 1)*_numberInPage;
37 }
void Paging::NextPage ( )

Move to the next page.

Definition at line 39 of file Paging.cpp.

39  {
40  // Move to next page
41  _currentPage++;
42  // Ensure the page number is not crossing the limit.
45 }
void Paging::PreviousPage ( )

Move to the previous page.

Definition at line 47 of file Paging.cpp.

47  {
48  // Move back to previous page
49  _currentPage--;
50  // Ensure the page number is not crossing the limit.
51  if (_currentPage <= 0)
52  _currentPage = 1;
53 }

Member Data Documentation

int CppSamples::Common::Paging::_count
private

Definition at line 52 of file Paging.h.

int CppSamples::Common::Paging::_currentPage
private

Definition at line 53 of file Paging.h.

int CppSamples::Common::Paging::_numberInPage
private

Definition at line 54 of file Paging.h.

int CppSamples::Common::Paging::_pageCount
private

Definition at line 55 of file Paging.h.


The documentation for this class was generated from the following files: