00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00023 #ifndef INCLUDE_MY_OBJECT_H
00024 #define INCLUDE_MY_OBJECT_H
00025 
00026 class Object;
00027 typedef void * (Object::*Obj_CallBack) (void *);
00028 
00084 class Object 
00085 {
00086 public:
00087         void *thisParent;
00088         int type;
00089         LONG param; 
00090         Obj_CallBack callBackAlloc;
00091 
00092 public:
00093         Object()
00094         {
00095                 param = 0;
00096                 thisParent=NULL;
00097                 type=-1;
00098                 callBackAlloc=NULL;
00099         }
00100 
00101         Object(int _type,void *_thisParent)
00102         {
00103                 type = _type;
00104                 thisParent = _thisParent;
00105         }
00106 
00107         void operator= (Object &source)
00108         {
00109                 param = source.param;
00110                 type = source.type;     
00111                 callBackAlloc = source.callBackAlloc;
00112                 thisParent = (*this.*callBackAlloc)(source.thisParent);
00113         }
00114 };
00115 
00124 template <class T,int V> class BaseObj : public Object
00125 {
00126 public:
00127         T elem;
00128 
00129         BaseObj() : Object(V,(void *)this) 
00130         {
00131                 callBackAlloc = (Obj_CallBack) Duplicate;
00132         }
00133 
00134         void * Duplicate (void *_in)
00135         {
00136                 BaseObj<T,V> *in = (BaseObj<T,V> *)_in;
00137                 BaseObj<T,V> *out = new BaseObj<T,V>;
00138                 *out = *in;
00139                 return (void *)out;
00140         }
00141 
00142         void operator=(BaseObj<T,V> &source)
00143         {
00144                 elem = source.elem;
00145         }
00146 };
00147 
00148 #define CBASE_INDEX_INT         0
00149 #define CBASE_INDEX_FLOAT       1
00150 #define CBASE_INDEX_DOUBLE      2
00151 #define CBASE_INDEX_STRING      3
00152 #define CBASE_INDEX_CUSTOM      4
00153 
00154 #define CBase_int BaseObj<int,CBASE_INDEX_INT>
00155 #define CBase_float BaseObj<float,CBASE_INDEX_FLOAT>
00156 #define CBase_double BaseObj<double,CBASE_INDEX_DOUBLE>
00157 #define CBase_string BaseObj<MyString,CBASE_INDEX_STRING>
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 
00207 
00208 
00209 
00210 
00211 
00212 
00213 
00214 
00215 
00216 
00217 
00218 #endif