00001
00002
00003
00004 #ifndef DYNARRIMPL_HPP
00005 #define DYNARRIMPL_HPP
00006
00007 #include "pi/int64.h"
00008 template<class T>
00009 class DynArrC;
00010
00011 class VObj; class DynI;
00012
00013 typedef DynArrC<char> DynArrCChar;
00014 typedef DynArrC<wchar_t> DynArrCWCharT;
00015 typedef DynArrC<short> DynArrCShort;
00016 typedef DynArrC<int> DynArrCInt;
00017 typedef DynArrC<int64> DynArrCInt64;
00018 typedef DynArrC<void*> DynArrCPtr;
00019 typedef DynArrC<VObj*> DynArrCPtrVObj;
00020 typedef DynArrC<DynI*> DynArrCPtrDynI;
00021
00022
00023
00024
00025 #ifdef DO_IMPLEMENT_DYNARRIMPL
00026 #define DO_IMPLEMENTING // If app has not defined it already
00027 #endif
00028 #include "dynobj/DynObj.h"
00029
00030
00031 #define DYNARRCtCHARt_TYPE_ID 0x94E29000
00032 #define DYNARRCtWCHAR_Tt_TYPE_ID 0x79F42000
00033 #define DYNARRCtSHORTt_TYPE_ID 0x856AD000
00034 #define DYNARRCtINTt_TYPE_ID 0xB9FFD000
00035 #define DYNARRCtINT64t_TYPE_ID 0xF9CE2000
00036 #define DYNARRCtVOIDpt_TYPE_ID 0xEC17D000
00037 #define DYNARRCtVOBJpt_TYPE_ID 0xA36A0000
00038 #define DYNARRCtDYNIpt_TYPE_ID 0xC6737000
00039
00040
00041 DO_DECL_TYPE_INFO(DynArrC<char>,DYNARRCtCHARt_TYPE_ID);
00042 DO_DECL_TYPE_INFO(DynArrC<wchar_t>,DYNARRCtWCHAR_Tt_TYPE_ID);
00043 DO_DECL_TYPE_INFO(DynArrC<short>,DYNARRCtSHORTt_TYPE_ID);
00044 DO_DECL_TYPE_INFO(DynArrC<int>,DYNARRCtINTt_TYPE_ID);
00045 DO_DECL_TYPE_INFO(DynArrC<int64>,DYNARRCtINT64t_TYPE_ID);
00046 DO_DECL_TYPE_INFO(DynArrC<void*>,DYNARRCtVOIDpt_TYPE_ID);
00047 DO_DECL_TYPE_INFO(DynArrC<VObj*>,DYNARRCtVOBJpt_TYPE_ID);
00048 DO_DECL_TYPE_INFO(DynArrC<DynI*>,DYNARRCtDYNIpt_TYPE_ID);
00049
00050
00051
00052
00053 #include "DoError.h"
00054 #include "utils/ExpArr.hpp"
00055 #include "utils/GNotifier.h"
00056 #include <string.h>
00057 #include "DynArr.hpp"
00058 #include "DoBase.hpp"
00059
00060 #ifndef GNOTIFIER_H
00061 #error No GNotifier
00062 #endif
00063
00064 #ifndef NOTIFIERI_HPP
00065 #error No Notfier
00066 #endif
00067
00068 typedef NotifierI __NotifierI;
00069
00070 template<class T>
00071 class DynArrC : public DynArrI<T>, public GNotifier {
00072 public:
00073 DynArrC( const DynI* pdi_init ) {
00074
00075
00076 const DynArrI<T>& da = *do_cast<const DynArrI<T>*>(pdi_init);
00077 if( da.doIsOk() )
00078 m_ea.Push( da.Base(), da.Size() );
00079
00080 else{
00081
00082 const DynData& dd = *do_cast<const DynData*>(pdi_init);
00083 if( dd.doIsOk() ){
00084
00085 VObj::SetError( "DynArrC::DynArrC: Could not use Constructor args (DynData)" );
00086
00087
00088
00089 }
00090 }
00091 }
00092
00093
00094 virtual DynObjType* docall doGetType( const DynI **pself ) const;
00095
00096 virtual void docall doDestroy( ) { delete this; }
00097
00098
00099 virtual const ArrBase<T,int>& docall GetArrBase( ) const { return m_ea.GetArrBase(); }
00100 virtual T& docall ElemRef( int ix ){ return m_ea[ix]; }
00101
00102 virtual DynArrI<T>& docall Push( T t ){ m_ea.Push(t); return *this; }
00103
00104 virtual T docall Pop( ) { return m_ea.Pop(); }
00105 virtual T& docall Top( ) { return m_ea.Top(); }
00106
00107 virtual DynArrI<T>& docall Empty( ) { m_ea.Empty(); return *this; }
00108 virtual bool docall MakeSpaceAt( int at_ix, int n_space=1 ){
00109 return m_ea.MakeSpaceAt( at_ix, n_space );
00110 }
00111 virtual DynArrI<T>& docall OverWrite( const T* pt, int cnt, int at_ix ){
00112 if( !pt || !cnt ) return *this;
00113 if( cnt<0 || at_ix<0 || at_ix+cnt>m_ea.Size() ) EA_THROW_RV( "DynArr<T>::OverWrite: Invalid index", *this );
00114 memcpy( m_ea.Base()+at_ix, pt, cnt*sizeof(T) );
00115 return *this;
00116 }
00117
00118 ExpArr<T> m_ea;
00119 };
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 #ifdef DO_IMPLEMENT_DYNARRIMPL
00135
00136
00137 DynObjTypeI2R<DynArrC<char>,DynArrChar,true> g_do_vtype_DynArrCTcharT("DynArrC<char>:DynArrChar",DYNARRCtCHARt_TYPE_ID,DOT_USER_TYPE,__FILE__);
00138 SideBaseDecl g_do_vtype_sbd_DynArrCTcharT_1("DynArrC<char>","NotifierI",sizeof(NotifierI),sidebase_offset<DynArrC<char>,NotifierI>(),NULL,-1,NULL);
00139 template<>
00140 DynObjType* DynArrC<char>::doGetType( const DynI **pself ) const {
00141 if(pself) *pself=(const DynI*)(const void*)this;
00142 return &g_do_vtype_DynArrCTcharT;
00143 }
00144 DynObjTypeI2R<DynArrC<wchar_t>,DynArrWCharT,true> g_do_vtype_DynArrCTwchar_tT("DynArrC<wchar_t>:DynArrWCharT",DYNARRCtWCHAR_Tt_TYPE_ID,DOT_USER_TYPE,__FILE__);
00145 SideBaseDecl g_do_vtype_sbd_DynArrCTwchar_tT_1("DynArrC<wchar_t>","NotifierI",sizeof(NotifierI),sidebase_offset<DynArrC<wchar_t>,NotifierI>(),NULL,-1,NULL);
00146 template<>
00147 DynObjType* DynArrC<wchar_t>::doGetType( const DynI **pself ) const {
00148 if(pself) *pself=(const DynI*)(const void*)this;
00149 return &g_do_vtype_DynArrCTwchar_tT;
00150 }
00151 DynObjTypeI2R<DynArrC<short>,DynArrShort,true> g_do_vtype_DynArrCTshortT("DynArrC<short>:DynArrShort",DYNARRCtSHORTt_TYPE_ID,DOT_USER_TYPE,__FILE__);
00152 SideBaseDecl g_do_vtype_sbd_DynArrCTshortT_1("DynArrC<short>","NotifierI",sizeof(NotifierI),sidebase_offset<DynArrC<short>,NotifierI>(),NULL,-1,NULL);
00153 template<>
00154 DynObjType* DynArrC<short>::doGetType( const DynI **pself ) const {
00155 if(pself) *pself=(const DynI*)(const void*)this;
00156 return &g_do_vtype_DynArrCTshortT;
00157 }
00158 DynObjTypeI2R<DynArrC<int>,DynArrInt,true> g_do_vtype_DynArrCTintT("DynArrC<int>:DynArrInt",DYNARRCtINTt_TYPE_ID,DOT_USER_TYPE,__FILE__);
00159 SideBaseDecl g_do_vtype_sbd_DynArrCTintT_1("DynArrC<int>","NotifierI",sizeof(NotifierI),sidebase_offset<DynArrC<int>,NotifierI>(),NULL,-1,NULL);
00160 template<>
00161 DynObjType* DynArrC<int>::doGetType( const DynI **pself ) const {
00162 if(pself) *pself=(const DynI*)(const void*)this;
00163 return &g_do_vtype_DynArrCTintT;
00164 }
00165 DynObjTypeI2R<DynArrC<int64>,DynArrInt64,true> g_do_vtype_DynArrCTint64T("DynArrC<int64>:DynArrInt64",DYNARRCtINT64t_TYPE_ID,DOT_USER_TYPE,__FILE__);
00166 SideBaseDecl g_do_vtype_sbd_DynArrCTint64T_1("DynArrC<int64>","NotifierI",sizeof(NotifierI),sidebase_offset<DynArrC<int64>,NotifierI>(),NULL,-1,NULL);
00167 template<>
00168 DynObjType* DynArrC<int64>::doGetType( const DynI **pself ) const {
00169 if(pself) *pself=(const DynI*)(const void*)this;
00170 return &g_do_vtype_DynArrCTint64T;
00171 }
00172 DynObjTypeI2R<DynArrC<void*>,DynArrPtr,true> g_do_vtype_DynArrCTvoidpT("DynArrC<void*>:DynArrPtr",DYNARRCtVOIDpt_TYPE_ID,DOT_USER_TYPE,__FILE__);
00173 SideBaseDecl g_do_vtype_sbd_DynArrCTvoidpT_1("DynArrC<void*>","NotifierI",sizeof(NotifierI),sidebase_offset<DynArrC<void*>,NotifierI>(),NULL,-1,NULL);
00174 template<>
00175 DynObjType* DynArrC<void*>::doGetType( const DynI **pself ) const {
00176 if(pself) *pself=(const DynI*)(const void*)this;
00177 return &g_do_vtype_DynArrCTvoidpT;
00178 }
00179 DynObjTypeI2R<DynArrC<VObj*>,DynArrPtrVObj,true> g_do_vtype_DynArrCTVObjpT("DynArrC<VObj*>:DynArrPtrVObj",DYNARRCtVOBJpt_TYPE_ID,DOT_USER_TYPE,__FILE__);
00180 SideBaseDecl g_do_vtype_sbd_DynArrCTVObjpT_1("DynArrC<VObj*>","NotifierI",sizeof(NotifierI),sidebase_offset<DynArrC<VObj*>,NotifierI>(),NULL,-1,NULL);
00181 template<>
00182 DynObjType* DynArrC<VObj*>::doGetType( const DynI **pself ) const {
00183 if(pself) *pself=(const DynI*)(const void*)this;
00184 return &g_do_vtype_DynArrCTVObjpT;
00185 }
00186 DynObjTypeI2R<DynArrC<DynI*>,DynArrPtrDynI,true> g_do_vtype_DynArrCTDynIpT("DynArrC<DynI*>:DynArrPtrDynI",DYNARRCtDYNIpt_TYPE_ID,DOT_USER_TYPE,__FILE__);
00187 SideBaseDecl g_do_vtype_sbd_DynArrCTDynIpT_1("DynArrC<DynI*>","NotifierI",sizeof(NotifierI),sidebase_offset<DynArrC<DynI*>,NotifierI>(),NULL,-1,NULL);
00188 template<>
00189 DynObjType* DynArrC<DynI*>::doGetType( const DynI **pself ) const {
00190 if(pself) *pself=(const DynI*)(const void*)this;
00191 return &g_do_vtype_DynArrCTDynIpT;
00192 }
00193
00194
00195 doUserTypeDecl g_do_ut_decl_DynArrImpl_0("DynArrC<char>:DynArrChar",DYNARRCtCHARt_TYPE_ID);
00196 doUserTypeDecl g_do_ut_decl_DynArrImpl_1("DynArrC<wchar_t>:DynArrWCharT",DYNARRCtWCHAR_Tt_TYPE_ID);
00197 doUserTypeDecl g_do_ut_decl_DynArrImpl_2("DynArrC<short>:DynArrShort",DYNARRCtSHORTt_TYPE_ID);
00198 doUserTypeDecl g_do_ut_decl_DynArrImpl_3("DynArrC<int>:DynArrInt",DYNARRCtINTt_TYPE_ID);
00199 doUserTypeDecl g_do_ut_decl_DynArrImpl_4("DynArrC<int64>:DynArrInt64",DYNARRCtINT64t_TYPE_ID);
00200 doUserTypeDecl g_do_ut_decl_DynArrImpl_5("DynArrC<void*>:DynArrPtr",DYNARRCtVOIDpt_TYPE_ID);
00201 doUserTypeDecl g_do_ut_decl_DynArrImpl_6("DynArrC<VObj*>:DynArrPtrVObj",DYNARRCtVOBJpt_TYPE_ID);
00202 doUserTypeDecl g_do_ut_decl_DynArrImpl_7("DynArrC<DynI*>:DynArrPtrDynI",DYNARRCtDYNIpt_TYPE_ID);
00203 #endif //DO_IMPLEMENT_...
00204
00205
00206 #endif // DYNARRIMPL_HPP
00207
00208