Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

preproc.h

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /* POLiTe - Persistent Object Library Test                                    */
00004 /*                                        Ph.D. Thesis by Mgr. Michal Kopecky */
00005 /*                                                                            */
00006 /* Charles University Prague                                                  */
00007 /*                                                                            */
00008 /******************************************************************************/
00009 /*                                                                            */
00010 /* File name: ...                                                             */
00011 /* Module: ......                                                             */
00012 /*                                                                            */
00013 /******************************************************************************/
00014 
00015 #ifndef __PREPROC_H__
00016 #define __PREPROC_H__
00017 
00018 // Common POLiTe Header(s)
00019 #include <lStr.h>
00020 
00021 #define CLASS(X) \
00022         friend Proto<X>; \
00023         protected: typedef X _THiS_CLaSS_; \
00024         public: static const char *ClassName() {return #X;}; \
00025         protected: static Object *_New() {return new X;}; \
00026         public: Ref<X> operator &() \
00027         { \
00028                 if (IsPersistent()) \
00029                         return Ref<X>(Connection(),Prototype(),_KeyValues(),_Strategies); \
00030                 else \
00031                         return Ref<X>(this); \
00032         }; \
00033         public: virtual class ProtoBase *Prototype() const
00034 #define ABSTRACT_CLASS(X) \
00035         friend Proto<X>; \
00036         protected: typedef X _THiS_CLaSS_; \
00037         public: static const char *ClassName() {return #X;}; \
00038         protected: static Object *_New() {return NULL;}; \
00039         public: Ref<X> operator &() \
00040         { \
00041                 if (IsPersistent()) \
00042                         return  Ref<X>(Connection(),Prototype(),_KeyValues(),_Strategies); \
00043                 else \
00044                         return Ref<X>(this); \
00045         }; \
00046         public: virtual class ProtoBase *Prototype() const = 0
00047 #define PARENTS(X) \
00048         public: static const char* ParentClassNames() {return X;}
00049 #define FROM(X) \
00050         public: static const char *From() {return X;}
00051 #define WHERE(X) \
00052         public: static const char *Where() {return X;}
00053 #define GROUP_BY(X) \
00054         public: static const char *GroupBy() {return X;}
00055 #define HAVING(X) \
00056         public: static const char *Having() {return X;}
00057 #define ORDER_BY(X) \
00058         public: static const char *OrderBy() {return X;}
00059 #define CLASS_PROTOTYPE(T) \
00060         extern Proto<T> T##_class; \
00061         class ProtoBase *T::Prototype() const {return (ProtoBase *)&T##_class;}
00062 #define ABSTRACT_CLASS_PROTOTYPE(T) \
00063         extern Proto<T> T##_class
00064 #define PROTOTYPE(T) \
00065         Proto<T> T##_class;
00066 
00067 #define TYPE_INT 'i'
00068 #define TYPE_UNSIGNED 'u'
00069 #define TYPE_FLOAT 'f'
00070 #define TYPE_CHAR 'c'
00071 #define TYPE_STRING 's'
00072 #define TYPE_PTR 'p'
00073 #define TYPE_UNKNOWN '?'
00074 
00075 #define dbMember(T,X) \
00076         protected: T _##X; \
00077         public: T X() const {return _##X;}; \
00078         public: void X(const T X##_) {_##X=X##_; MarkAsDirty();}
00079 #define dbString(X) \
00080         protected: char * _##X; \
00081         public: char * X() const {return _##X;}; \
00082         public: void X(const char * X##_) {StrCpy(_##X,X##_); MarkAsDirty();}
00083 #define dbPtr(T,X) \
00084         protected: long int _##X; \
00085         public: Ref<T> X() const \
00086         { \
00087                 if (IsPersistent()) \
00088                         if (_##X>0) \
00089                         { \
00090                                 Ref<T> t(Connection(),_##X); \
00091                                 return _Virtualise(t); \
00092                         } \
00093                         else \
00094                                 return DBNULL; \
00095                 else \
00096                         return DBNULL; \
00097         } \
00098         public: void X(const Ref<T> &X##_) \
00099         { \
00100                 if (X##_==DBNULL) _##X=0; else sscanf(_SelectKeyValues(X##_),"%li",&_##X); \
00101                 MarkAsDirty(); \
00102         }
00103 #define dbShort(X) dbMember(short,X)
00104 #define dbUShort(X) dbMember(unsigned short,X)
00105 #define dbInt(X) dbMember(int,X)
00106 #define dbUInt(X) dbMember(unsigned int,X)
00107 #define dbLong(X) dbMember(long,X)
00108 #define dbULong(X) dbMember(unsigned long,X)
00109 #define dbFloat(X) dbMember(float,X)
00110 #define dbDouble(X) dbMember(double,X)
00111 #define dbChar(X) dbMember(char,X)
00112 #define dbBool(X) dbMember(bool,X)
00113 #define dbMemberRO(T,X) \
00114         protected: T _##X; \
00115         public: T X() const {return _##X;}
00116 #define dbStringRO(X) \
00117         protected: char * _##X; \
00118         public: char * X() const {return _##X;}
00119 #define dbPtrRO(T,X) \
00120         protected: long int _##X; \
00121         public: Ref<T> X() const \
00122         { \
00123                 return IsPersistent() ? _##X>0 ? _Virtualise(Ref<T>(Connection(),_##X,Class[#T])) : DBNULL : DBNULL; \
00124         }
00125 #define dbShortRO(X) dbMemberRO(short,X)
00126 #define dbUShortRO(X) dbMemberRO(unsigned short,X)
00127 #define dbIntRO(X) dbMemberRO(int,X)
00128 #define dbUIntRO(X) dbMemberRO(unsigned int,X)
00129 #define dbLongRO(X) dbMemberRO(long,X)
00130 #define dbULongRO(X) dbMemberRO(unsigned long,X)
00131 #define dbFloatRO(X) dbMemberRO(float,X)
00132 #define dbDoubleRO(X) dbMemberRO(double,X)
00133 #define dbCharRO(X) dbMemberRO(char,X)
00134 #define dbBoolRO(X) dbMemberRO(bool,X)
00135 
00136 #define MAPKEY_BEGIN \
00137         public: static void MapKey(int i, const char *&attr, unsigned char Object::*&mem, const char *&col, char &type, unsigned int &len, bool &rw) { \
00138                 rw = true; \
00139                 if (i<0) {attr=NULL; col=NULL; type=TYPE_UNKNOWN; len=0; return;};
00140 #define MAPKEY_END \
00141         attr=NULL; col=NULL; type=TYPE_UNKNOWN; len=0; \
00142 }
00143 #define MAP_BEGIN \
00144         public: static void Map(int i, const char *&attr, unsigned char Object::*&mem, const char *&col, char &type, unsigned int &len, bool &rw) { \
00145                 if (i<0) {attr=NULL; col=NULL; type=TYPE_UNKNOWN; len=0; rw=false; return;};
00146 #define MAP_END \
00147         attr=NULL; col=NULL; type=TYPE_UNKNOWN; len=0; rw=false; \
00148 }
00149 
00150 #define mapMember(A,M,C,T,N) \
00151 if (!i--) {attr=A; mem=(unsigned char Object::*)&(_THiS_CLaSS_::M); col=C; type=T; len=N; rw=true; return;};
00152 #define mapString(A,C,N) mapMember(#A,_##A,C,TYPE_STRING,N)
00153 #define mapPtr(A,C) mapMember(#A,_##A,C,TYPE_PTR,sizeof(long int))
00154 #define mapShort(A,C) mapMember(#A,_##A,C,TYPE_INT,sizeof(short int))
00155 #define mapUShort(A,C) mapMember(#A,_##A,C,TYPE_UNSIGNED,sizeof(unsigned short))
00156 #define mapInt(A,C) mapMember(#A,_##A,C,TYPE_INT,sizeof(int))
00157 #define mapUInt(A,C) mapMember(#A,_##A,C,TYPE_UNSIGNED,sizeof(unsigned int))
00158 #define mapLong(A,C) mapMember(#A,_##A,C,TYPE_INT,sizeof(long int))
00159 #define mapULong(A,C) mapMember(#A,_##A,C,TYPE_UNSIGNED,sizeof(unsigned long))
00160 #define mapFloat(A,C) mapMember(#A,_##A,C,TYPE_FLOAT,sizeof(float))
00161 #define mapDouble(A,C) mapMember(#A,_##A,C,TYPE_FLOAT,sizeof(double))
00162 #define mapChar(A,C) mapMember(#A,_##A,C,TYPE_CHAR,sizeof(char))
00163 #define mapBool(A,C) mapMember(#A,_##A,C,TYPE_INT,sizeof(bool))
00164 
00165 #define mapMemberRO(A,M,C,T,N) \
00166 if (!i--) {attr=A; mem=(unsigned char Object::*)&(_THiS_CLaSS_::M); col=C; type=T; len=N; rw=false; return;};
00167 #define mapStringRO(A,C,N) mapMember(#A,_##A,C,TYPE_STRING,N)
00168 #define mapPtrRO(A,C) mapMember(#A,_##A,C,TYPE_PTR,sizeof(long int))
00169 #define mapShortRO(A,C) mapMember(#A,_##A,C,TYPE_INT,sizeof(short int))
00170 #define mapUShortRO(A,C) mapMember(#A,_##A,C,TYPE_UNSIGNED,sizeof(unsigned short))
00171 #define mapIntRO(A,C) mapMember(#A,_##A,C,TYPE_INT,sizeof(int))
00172 #define mapUIntRO(A,C) mapMember(#A,_##A,C,TYPE_UNSIGNED,sizeof(unsigned int))
00173 #define mapLongRO(A,C) mapMember(#A,_##A,C,TYPE_INT,sizeof(long int))
00174 #define mapULongRO(A,C) mapMember(#A,_##A,C,TYPE_UNSIGNED,sizeof(unsigned long))
00175 #define mapFloatRO(A,C) mapMember(#A,_##A,C,TYPE_FLOAT,sizeof(float))
00176 #define mapDoubleRO(A,C) mapMember(#A,_##A,C,TYPE_FLOAT,sizeof(double))
00177 #define mapCharRO(A,C) mapMember(#A,_##A,C,TYPE_CHAR,sizeof(char))
00178 #define mapBoolRO(A,C) mapMember(#A,_##A,C,TYPE_INT,sizeof(bool))
00179 
00180 #endif //__PREPROC_H__

Generated on Sun Jul 14 20:51:15 2002 for POLiTe by doxygen1.2.16