00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef FLC_CORE_TABLE_H
00017 #define FLC_CORE_TABLE_H
00018
00019 #include <falcon/setup.h>
00020 #include <falcon/carray.h>
00021 #include <falcon/genericvector.h>
00022 #include <falcon/sequence.h>
00023 #include <falcon/fassert.h>
00024 #include <falcon/item.h>
00025 #include <falcon/genericmap.h>
00026
00027 namespace Falcon {
00028
00029 class CoreTable;
00030
00031
00032
00033
00034 class CoreTable: public Sequence
00035 {
00036 CoreArray *m_currentPage;
00037 GenericVector m_pages;
00038 GenericVector m_headerData;
00039 Map m_heading;
00040 uint32 m_currentPageId;
00041 uint32 m_order;
00042
00044 numeric *m_biddingVals;
00045 uint32 m_biddingSize;
00046
00047 public:
00048 enum {
00049 noitem = 0xFFFFFFFF
00050 };
00051
00052 CoreTable();
00053 CoreTable( const CoreTable& other );
00054 virtual ~CoreTable();
00055
00056 CoreArray *page( uint32 num ) const {
00057 return *reinterpret_cast<CoreArray **>(m_pages.size() >= num ? m_pages.at(num) : 0);
00058 }
00059
00060 uint32 pageCount() const { return m_pages.size(); }
00061
00063 uint32 order() const { return m_order; }
00064
00068 const Item& columnData( uint32 pos ) const {
00069 fassert( pos < order() );
00070 return *(Item*) m_headerData.at(pos);
00071 }
00072
00076 Item& columnData( uint32 pos ) {
00077 fassert( pos < order() );
00078 return *(Item*) m_headerData.at(pos);
00079 }
00080
00084 void columnData( uint32 pos, const Item& data ) {
00085 fassert( pos < order() );
00086 m_headerData.set( const_cast<Item*>( &data ), pos);
00087 }
00088
00092 const String &heading( uint32 pos ) const;
00093
00098 void renameColumn( uint32 pos, const String &name );
00099
00110 void insertColumn( uint32 pos, const String &name, const Item &data, const Item &dflt );
00111
00119 bool removeColumn( uint32 pos );
00120
00121 bool setCurrentPage( uint32 num )
00122 {
00123 if ( num < m_pages.size() )
00124 {
00125 m_currentPageId = num;
00126 m_currentPage = *reinterpret_cast<CoreArray **>(m_pages.at( num ));
00127 return true;
00128 }
00129
00130 return false;
00131 }
00132
00133 CoreArray *currentPage() const { return m_currentPage; }
00134 uint32 currentPageId() const { return m_currentPageId; }
00135 bool setHeader( CoreArray *header );
00136 uint32 getHeaderPos( const String &name ) const;
00137 Item *getHeaderData( uint32 pos ) const;
00138
00139 Item *getHeaderData( const String &name ) const {
00140 uint32 pos = getHeaderPos( name );
00141 if ( pos == noitem )
00142 return 0;
00143
00144 return getHeaderData( pos );
00145 }
00146
00156 bool insertRow( CoreArray *ca, uint32 pos=noitem, uint32 page = noitem );
00157
00163 bool removeRow( uint32 pos, uint32 page = noitem );
00164
00165
00178 bool insertPage( CoreObject *self, CoreArray *data, uint32 pos = noitem );
00179
00184 bool removePage( uint32 pos );
00185
00186
00187
00188
00192 virtual FalconData *clone() const;
00193
00194 virtual const Item &front() const;
00195 virtual const Item &back() const;
00196
00197
00199 virtual void clear();
00200
00202 virtual void append( const Item &data );
00203
00205 virtual void prepend( const Item &data );
00206
00210 virtual bool empty() const { return m_currentPage == 0 || m_currentPage->length() == 0; }
00211
00214 virtual void gcMark( uint32 mark );
00215
00216
00220 numeric *biddings() const { return m_biddingVals; }
00221
00223 uint32 biddingsSize() const { return m_biddingSize; }
00224
00225 void reserveBiddings( uint32 size );
00226
00227
00228
00229
00230 protected:
00231 virtual void getIterator( Iterator& tgt, bool tail = false ) const ;
00232 virtual void copyIterator( Iterator& tgt, const Iterator& source ) const ;
00233
00234 virtual void insert( Iterator &iter, const Item &data ) ;
00235 virtual void erase( Iterator &iter ) ;
00236 virtual bool hasNext( const Iterator &iter ) const ;
00237 virtual bool hasPrev( const Iterator &iter ) const ;
00238 virtual bool hasCurrent( const Iterator &iter ) const ;
00239 virtual bool next( Iterator &iter ) const ;
00240 virtual bool prev( Iterator &iter ) const ;
00241 virtual Item& getCurrent( const Iterator &iter ) ;
00242 virtual Item& getCurrentKey( const Iterator &iter ) ;
00243 virtual bool equalIterator( const Iterator &first, const Iterator &second ) const ;
00244
00245 };
00246
00247 }
00248
00249 #endif
00250
00251