00001
00002
00003
00004
00009 #ifndef __HANDLER_H__
00010 #define __HANDLER_H__
00011
00013
00014
00015 class c4_Handler;
00016
00017
00018 class c4_HandlerSeq;
00019
00020 class c4_Column;
00021 class c4_Field;
00022 class c4_Persist;
00023 class c4_SaveContext;
00024
00026
00027 class c4_Handler
00028 {
00029 c4_Property _property;
00030
00031 public:
00032 c4_Handler (const c4_Property& _prop);
00033
00034 virtual ~c4_Handler ();
00035
00036 virtual void Define(int, const t4_byte**);
00037
00038 virtual void FlipBytes();
00039
00040 virtual void Commit(c4_SaveContext& ar_);
00041
00042 virtual void OldDefine(char, c4_Persist&);
00043
00044 const c4_Property& Property() const;
00045
00046 int PropId() const;
00047
00048
00049 void ClearBytes(c4_Bytes& buf_) const;
00050
00051
00052 virtual int ItemSize(int index_) = 0;
00053
00054 void GetBytes(int index_, c4_Bytes& buf_, bool copySmall_ =false);
00055
00056 virtual const void* Get(int index_, int& length_) = 0;
00057
00058 virtual void Set(int index_, const c4_Bytes& buf_) = 0;
00059
00060
00061 int Compare(int index_, const c4_Bytes& buf_);
00062
00063
00064 virtual void Insert(int index_, const c4_Bytes& buf_, int count_) = 0;
00065
00066 virtual void Remove(int index_, int count_) = 0;
00067
00068 void Move(int from_, int to_);
00069
00070
00071 virtual c4_Column* GetNthMemoCol(int index_, bool alloc_ =false);
00072
00073
00074 virtual bool IsPersistent() const;
00075
00076
00077 virtual void Unmapped();
00078
00079
00080 virtual bool HasSubview(int index_);
00081
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