Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

Table.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Table_Table_h
00002 #define Impala_Core_Table_Table_h
00003 
00004 namespace Impala
00005 {
00006 namespace Core
00007 {
00008 namespace Table
00009 {
00010 
00011 
00015 class Table
00016 {
00017 public:
00018 
00019     Table()
00020     {
00021         mLast = 0;
00022         mCursor = -1;
00023     }
00024 
00025     virtual ~Table()
00026     {
00027     }
00028 
00029     int
00030     Size() const
00031     {
00032         return mLast;
00033     }
00034 
00035     void
00036     SetSize(int nr)
00037     {
00038         mLast = nr;
00039     }
00040 
00041     void
00042     SetEmpty()
00043     {
00044         mLast = 0;
00045         mCursor = -1;
00046     }
00047 
00048     void
00049     RemoveLast()
00050     {
00051         if (mLast > 0)
00052             mLast--;
00053         if (mCursor > mLast)
00054             mCursor = -1;
00055     }
00056 
00057     // cursor part
00058 
00059     bool
00060     HasCursor() const
00061     {
00062         return mCursor != -1;
00063     }
00064 
00065     int
00066     GetCursor() const
00067     {
00068         return mCursor;
00069     }
00070 
00071     bool
00072     SetCursor(int newPos)
00073     {
00074         if ((newPos < 0) || (newPos >= mLast))
00075             return false;
00076         mCursor = newPos;
00077         return true;
00078     }
00079 
00080     bool
00081     MoveCursor(int steps)
00082     {
00083         if (mCursor + steps < 0) // allow move from -1 to 0, but not 0 to -1
00084             return false;
00085         return SetCursor(mCursor + steps);
00086     }
00087 
00088     void
00089     DeleteCursor()
00090     {
00091         mCursor = -1;
00092     }
00093 
00094 protected:
00095 
00096     int   mLast;
00097     int   mCursor;
00098 
00099 };
00100 
00101 } // namespace Table
00102 } // namespace Core
00103 } // namespace Impala
00104 
00105 #endif

Generated on Fri Mar 19 09:31:20 2010 for ImpalaSrc by  doxygen 1.5.1