Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

handler.h

Go to the documentation of this file.
00001 // handler.h --
00002 // $Id: handler.h,v 1.11 2003/11/23 01:42:51 wcvs Exp $
00003 // This is part of Metakit, the homepage is https://www.equi4.com/metakit/
00004 
00009 #ifndef __HANDLER_H__
00010 #define __HANDLER_H__
00011 
00013 // Declarations in this file
00014 
00015   class c4_Handler;         // data representation handler
00016 
00017 //  class c4_Sequence;
00018     class c4_HandlerSeq;      // a sequence built from handlers
00019 
00020   class c4_Column;          // not defined here
00021   class c4_Field;           // not defined here
00022   class c4_Persist;         // not defined here
00023   class c4_SaveContext;       // not defined here
00024 
00026 
00027 class c4_Handler
00028 {
00029   c4_Property _property;
00030 
00031 public:
00032   c4_Handler (const c4_Property& _prop);
00033     //: Constructor (this is an abstract base class).
00034   virtual ~c4_Handler ();
00035 
00036   virtual void Define(int, const t4_byte**);
00037     //: Called when the corresponding table has been fully defined.
00038   virtual void FlipBytes();
00039     //: Called to reverse the internal byte order of foreign data.
00040   virtual void Commit(c4_SaveContext& ar_);
00041     //: Commit the associated column(s) to file.
00042   virtual void OldDefine(char, c4_Persist&);
00043 
00044   const c4_Property& Property() const;
00045     //: Returns the property associated with this handler.
00046   int PropId() const;
00047     //: Returns the id of the property associated with this handler.
00048 
00049   void ClearBytes(c4_Bytes& buf_) const;
00050     //: Returns the default value for items of this type.
00051 
00052   virtual int ItemSize(int index_) = 0;
00053     //: Return width of specified data item.
00054   void GetBytes(int index_, c4_Bytes& buf_, bool copySmall_ =false);
00055     //: Used for backward compatibility, should probably be replaced.
00056   virtual const void* Get(int index_, int& length_) = 0;
00057     //: Retrieves the data item at the specified index.
00058   virtual void Set(int index_, const c4_Bytes& buf_) = 0;
00059     //: Stores a new data item at the specified index.
00060 
00061   int Compare(int index_, const c4_Bytes& buf_);
00062     //: Compares an entry with a specified data item.
00063 
00064   virtual void Insert(int index_, const c4_Bytes& buf_, int count_) = 0;
00065     //: Inserts 1 or more data items at the specified index.
00066   virtual void Remove(int index_, int count_) = 0;
00067     //: Removes 1 or more data items at the specified index.
00068   void Move(int from_, int to_);
00069     //: Move a data item to another position.
00070 
00071   virtual c4_Column* GetNthMemoCol(int index_, bool alloc_ =false);
00072     //: Special access to underlying data of memo entries
00073 
00074   virtual bool IsPersistent() const;
00075     //: True if this handler might do I/O to satisfy fetches
00076 
00077   virtual void Unmapped();
00078     //: Make sure this handler stops using file mappings
00079 
00080   virtual bool HasSubview(int index_);
00081     //: True if this subview has materialized into an object
00082 };
00083 
00085 
00086 class c4_HandlerSeq : public c4_Sequence
00087 {
00088   c4_PtrArray _handlers;
00089   c4_Persist* _persist;
00090   c4_Field* _field; 
00091   c4_HandlerSeq* _parent;
00092   int _numRows;
00093 
00094 public:
00095   c4_HandlerSeq (c4_Persist*);
00096   c4_HandlerSeq (c4_HandlerSeq& owner_, c4_Handler* handler_);
00097 
00098   virtual int NumRows() const;
00099   virtual void SetNumRows(int);
00100   
00101   virtual int NumHandlers() const;
00102   virtual c4_Handler& NthHandler(int) const;
00103   virtual const c4_Sequence* HandlerContext(int) const;
00104   virtual int AddHandler(c4_Handler*);
00105 
00106   void DefineRoot();
00107   void Restructure(c4_Field&, bool remove_);
00108   void DetachFromParent();
00109   void DetachFromStorage(bool full_);
00110   void DetermineSpaceUsage();
00111     
00112   c4_Field& Definition() const;
00113   const char* Description();
00114   c4_HandlerSeq& Parent() const;
00115   virtual c4_Persist* Persist() const;
00116   
00117   c4_Field& Field(int) const;
00118   int NumFields() const;
00119   char ColumnType(int index_) const;
00120   bool IsNested(int) const;
00121   
00122   void Prepare(const t4_byte** ptr_, bool selfDesc_);
00123   void OldPrepare();
00124 
00125   void FlipAllBytes();
00126   void ExchangeEntries(int srcPos_, c4_HandlerSeq& dst_, int dstPos_);
00127 
00128   c4_HandlerSeq& SubEntry(int, int) const;
00129   
00130   c4_Field* FindField(const c4_Handler* handler_);
00131 
00132   void UnmappedAll();
00133   
00134   static void BuildMeta(int, int, c4_View&, const c4_Field&);
00135 
00136 protected:
00137   virtual c4_Handler* CreateHandler(const c4_Property&);
00138 
00139   virtual ~c4_HandlerSeq ();
00140 };
00141 
00143 
00144 #if q4_INLINE
00145 #include "handler.inl"
00146 #endif
00147 
00149 
00150 #endif


Metakit C++ API Reference - https://www.equi4.com/metakit.html - extracted with Doxygen