Diffpack Documentation


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

Dpmacros.h

Go to the documentation of this file.
00001 
00007 #ifdef NULL
00008 #undef NULL
00009 #endif
00010 #define NULL 0
00011 
00012 
00013 
00014 #ifdef BCPP_BUILDER
00015 #ifdef name2
00016 #undef name2
00017 #endif
00018 #endif
00019 
00020 
00021 #ifndef name2
00022 #define name2(a,b) a ## b
00023 #endif
00024 #ifndef name3
00025 #define name3(a,b,c) a ## b ## c
00026 #endif
00027 #ifndef name4
00028 #define name4(a,b,c,d) a ## b ## c ## d
00029 #endif
00030 
00031 
00032 #include <math.h>
00033 
00034 #ifndef M_E
00035 #define M_E         2.7182818284590452354       /* e */
00036 #endif
00037 #ifndef M_LOG2E
00038 #define M_LOG2E     1.4426950408889634074       /* log 2e */
00039 #endif
00040 #ifndef M_LOG10E
00041 #define M_LOG10E    0.43429448190325182765      /* log 10e */
00042 #endif
00043 #ifndef M_LN2
00044 #define M_LN2       0.69314718055994530942      /* log e2 */
00045 #endif
00046 #ifndef M_LN10
00047 #define M_LN10      2.30258509299404568402      /* log e10 */
00048 #endif
00049 #ifndef M_PI
00050 #define M_PI        3.14159265358979323846      /* pi */
00051 #endif
00052 #ifndef M_PI_2
00053 #define M_PI_2      1.57079632679489661923      /* pi/2 */
00054 #endif
00055 #ifndef M_1_PI
00056 #define M_1_PI      0.31830988618379067154      /* 1/pi */
00057 #endif
00058 #ifndef M_PI_4
00059 #define M_PI_4      0.78539816339744830962      /* pi/4 */
00060 #endif
00061 #ifndef M_2_PI
00062 #define M_2_PI      0.63661977236758134308      /* 2/pi */
00063 #endif
00064 
00065 #undef  PI
00066 #define PI 3.141592653589793238462643383279502884197169399375105820974944592308
00067 #define SQUAREROOTTWO 1.4142135623730950488016887242096980785696718753769480732
00068 #define ONETHIRD 0.333333333333333333333333333333333333333333333333333333333333
00069 #define ONESIXTH 0.166666666666666666666666666666666666666666666666666666666666
00070 
00071 #ifndef PI2
00072 #define PI2  M_PI_2
00073 #endif
00074 
00075 
00076 #include <lapack_macros.h>
00077 #include <ctype.h>
00078 #include <string.h>
00079 #include <default_op.h>
00080 
00081 #define CAST_CONST_AWAY(Classname)  ((Classname*) this)
00082 #define ADDQUOTES(s) # s
00083 #define MAKESTRING(a) ADDQUOTES(a)
00084 
00085 
00086 
00087 /* expansion macro: Mat(Type) --> Mat(Type) */
00088 #define Mat(Type) name2(Mat(),Type) 
00089 /* expansion macro: Vec(Type) --> Vec(Type) */
00090 #define Vec(Type) name2(Vec(),Type) 
00091 
00092 #define MatSimple(Type) name2(MatSimple(),Type)
00093 #define VecSimple(Type) name2(VecSimple(),Type)
00094 #define VecSort(Type) name2(VecSort(),Type)
00095 
00096 #define SetOfNo(Type) name2(SetOfNo(),Type)
00097 #define SetSimplest(Type) name2(SetSimplest(),Type)
00098 
00099 #define DpList(Type),ItemType name2(ItemType_,Type)
00100 #define DpListItemPtr(Type) name2(DpListPtr_,Type)
00101 #define DpListItemInst(Type) name2(DpListInst_,Type)
00102 #define DpListItemHandle(Type) name2(DpListHandle_,Type)
00103 #define DpLists(DpListType) name2(DpLists(),DpListType)
00104 #define DpListsItem(DpListType) name2(DpListsItem(),DpListType)
00105 #define DpListBin(Type) name2(DpListBin(),Type)
00106 #define DpListBinH(Type) name2(DpListBinH,Type)
00107 
00108 #define StackCell(Type) name2(StackCell(),Type)
00109 #define Stack(Type) name2(Stack(),Type)
00110 
00111 
00112 #define MatSimplest(Type) name2(MatSimplest(),Type)
00113 #define VecSimplest(Type) name2(VecSimplest(),Type)
00114 
00115 #define MatSimplestH(Type) name2(MatSimplestH(),Type)
00116 #define VecSimplestH(Type) name2(VecSimplestH(),Type)
00117 #define MatSimpleH(Type) name2(MatSimpleH(),Type)
00118 #define VecSimpleH(Type) name2(VecSimpleH(),Type)
00119 #define Matrix(Type) name2(Matrix(),Type)
00120 #define HandleT_Matrix(Type) name2(HandleT_Matrix,Type)
00121 #define Vector(Type) name2(Vector(),Type)
00122 
00123 #define ArrayGenSimplest(Type) name2(ArrayGenSimplest(),Type)
00124 #define ArrayGenSimple(Type) name2(ArrayGenSimple(),Type)
00125 #define ArrayGen(Type) name2(ArrayGen(),Type)
00126 #define ArrayGenSel(Type) name2(ArrayGenSel(),Type)
00127 
00128 #define Interval(Type) name2(Interval(),Type)
00129 
00130 #define MatBand(Type) name2(MatBand(),Type)
00131 #define MatTri(Type) name2(MatTri(),Type)
00132 #define MatSparse(Type) name2(MatSparse(),Type)
00133 #define MatStructSparse(Type) name2(MatStructSparse,Type)
00134 #define MatDiag(Type) name2(MatDiag(),Type)
00135 #define MatEBE(Type) name2(MatEBE,Type)
00136 #define MatDense(Type) Mat(Type)
00137 
00138 #define MatSchur(Type) name2(MatSchur(),Type)
00139 #define MatSchurUDC(Type) name2(MatSchurUDC(),Type)
00140 #define splitMatrix(Type) name2(splitMatrix(),Type)
00141 
00142 #define Matrix(prm_Type) name2(Matrix(prm_),Type)
00143 #define Vector(prm_Type) name2(Vector(prm_),Type)
00144 #define Matrix2_prm(Type) name2(Matrix2_prm(),Type)
00145 
00146 
00147 #define Func(Type) name2(Func(),Type)
00148 
00149 #define StackCell(Type) name2(StackCell(),Type)
00150 #define Stack(Type) name2(Stack(),Type)
00151 
00152 
00153 #define Ptv(Type) name4(Ptv,d,Type)
00154 #define Ptv(Type)   name2(Ptv(),Type)
00155 #define Ptv1d(Type) name2(Ptv1d(),Type)
00156 #define Ptv2d(Type) name2(Ptv2d(),Type)
00157 #define Ptv3d(Type) name2(Ptv3d(),Type)
00158 #define Ptm(Type)   name2(Ptm(),Type)
00159 
00160 
00161 #define SetDistinct(Type) name2(SetDistinct(),Type)
00162 
00163 
00164 #ifndef F77HANDLING
00165 
00166 #define FORTRANname(X,UX) name2(X,_)
00167 #else
00168  #if F77HANDLING == 1
00169   
00170   #if defined(SGI_Cplusplus) || defined(SPARC_Cplusplus) || defined(__DECCXX) || defined(SUN4_Cplusplus) || defined(gpp_Cplusplus) || defined(egcs_Cplusplus) || defined(SOL_Cplusplus)
00171    #define FORTRANname(X,UX) name2(X,_)
00172   #elif defined(_CRAY)
00173    #define FORTRANname(X,UX) UX
00174   #else
00175    #define FORTRANname(X,UX) X
00176   #endif
00177  #elif F77HANDLING == 2
00178   
00179   
00180   #define FORTRANname(X,UX) externalpackmsg
00181  #endif
00182 #endif
00183 
00184 
00185 
00186 
00187 
00188 
00189 #define DBP(msg) { s_o<<"DBP " <<__FILE__<< "[" \
00190   <<__LINE__<<"]: "<<msg<<'\n'; s_o.flush(); }
00191 
00192 #ifdef DP_DEBUG
00193 #define DBP0(msg) DBP(msg)
00194 #else
00195 #define DBP0(msg) ;
00196 #endif
00197 
00198 #if DP_DEBUG >= 1
00199 #define DBP1(msg) DBP(msg)
00200 #else
00201 #define DBP1(msg) ;
00202 #endif
00203 
00204 #if DP_DEBUG >= 2
00205 #define DBP2(msg) DBP(msg)
00206 #else
00207 #define DBP2(msg) ;
00208 #endif
00209 
00210 #if DP_DEBUG >= 3
00211 #define DBP3(msg) DBP(msg)
00212 #else
00213 #define DBP3(msg) ;
00214 #endif
00215 
00216 #if DP_DEBUG >= 4
00217 #define DBP4(msg) DBP(msg)
00218 #else
00219 #define DBP4(msg) ;
00220 #endif
00221 
00222 #if DP_DEBUG >= 5
00223 #define DBP5(msg) DBP(msg)
00224 #else
00225 #define DBP5(msg) ;
00226 #endif
00227 
00228 #if DP_DEBUG >= 6
00229 #define DBP6(msg) DBP(msg)
00230 #else
00231 #define DBP6(msg) ;
00232 #endif
00233 
00234 
00235 
00236 
00237 #define CLASS_INFO \
00238  public:           \
00239   static  const TypeInfo  type_info;   \
00240   virtual const TypeInfo* getInfo () const   { return &type_info; }
00241 
00242 #define INIT_CLASS_INFO(Classname)  \
00243   const TypeInfo Classname :: type_info (MAKESTRING(Classname));
00244 
00245 #define INIT_CLASS_INFO1(Classname, Base1)  \
00246   const TypeInfo Classname :: type_info (MAKESTRING(Classname));
00247 
00248 #define INIT_CLASS_INFO2(Classname, Base1, Base2)  \
00249   const TypeInfo Classname :: type_info (MAKESTRING(Classname));
00250 
00251 /* These are probably the versions for the future:
00252 #define INIT_CLASS_INFO1(Classname, Base1)  \
00253   const TypeInfo Classname :: type_info (MAKESTRING(Classname), \
00254         & Base1 ::type_info );
00255 #define INIT_CLASS_INFO2(Classname, Base1, Base2)  \
00256   const TypeInfo Classname :: type_info (MAKESTRING(Classname), \
00257         &Base1 ::type_info, &Base2::type_info );
00258 */
00259 
00260 #define TYPEID_STR(Type) MAKESTRING(Type)
00261 
00262 #define TYPEID_NAME(ptr) \
00263   ptr->getInfo()->name()
00264 
00265 #define TYPEID_PTR(ptr,Type) \
00266   ptr->getInfo()->nameIs (TYPEID_STR(Type))
00267 
00268 #define TYPEID_REF(ref,Type) \
00269   ref.getInfo()->nameIs (TYPEID_STR(Type))
00270 
00271 
00272 
00273 #define cast2(Type) name2(cast2,Type)
00274 
00275 #define VIRTUAL_CAST(ToType) \
00276   virtual ToType* cast2(ToType) () const { return (ToType*) this; }
00277 
00278 #define DEF_VIRTUAL_CAST(ToType) \
00279   virtual ToType* cast2(ToType) () const { return NULL; }
00280 
00281 /*
00282    the CAST_* functions need a help macro in order to manage to expand
00283    all the internal macros (a bug in cpp?)
00284 */
00285 
00286 #define ___help_cast_ptr(arg)  arg() != NULL ?   arg()
00287 #define ___help_cast_ref(arg)  arg() != NULL ? *(arg())
00288 
00289 #define CAST_PTR(ptr,ToType) \
00290   ___help_cast_ptr(ptr->cast2(ToType)) \
00291   : (ToType*) errorFPret("macro CAST_PTR","File %s, line %d, cannot \
00292 cast pointer of type %s to %s",__FILE__,__LINE__, \
00293 ptr->getInfo()->name(), TYPEID_STR(ToType))
00294 
00295 
00296 #define CAST_REF(ref,ToType) \
00297   ___help_cast_ref(ref.cast2(ToType)) \
00298   : (ToType&) *errorFPret("macro CAST_REF","File %s, line %d, cannot \
00299 cast reference of type %s to %s",__FILE__,__LINE__, \
00300 ref.getInfo()->name(), TYPEID_STR(ToType))
00301 
00302 
00303 
00304 /* Handle macros: */
00305 #define Handle(Type) name2(Handle(),Type)
00306 
00307 
00308 #define EQ(String,ClassType)  eq(String,TYPEID_STR(ClassType))
00309 
00310 
00311 #define OBJECT_OK(funcname,obj,boolvar) \
00312   { if (!obj.ok()) \
00313   { errorFP(funcname,"%s is not ok",TYPEID_STR(obj)); boolvar=false; } }
00314 #define HANDLE_OK(funcname,h,boolvar) \
00315   { if (h.ok()) OBJECT_OK(funcname,h(),boolvar) \
00316     else { errorFP(funcname,"%s-handle is empty! You must create %s", \
00317                    TYPEID_STR(h),TYPEID_STR(h)); boolvar=false; } }
00318 
00319 
00320 
00321 #ifdef DP_DEBUG
00322 #define DPTRACE(msg)  dpTracer tr(msg);
00323 #else
00324 #define DPTRACE(msg)
00325 #endif
00326 
00327 
00328 
00329 
00330 #define DP_FUNCTION_NOT_DEFINED(func,cl)\
00331  errorFP(func,"This function is not implemented for class %s",cl)
00332 
00333 #define DP_FUNCTION_NO_MEANING(func,cl)\
00334  errorFP(func,"This function has no meaning for class %s",cl)
00335 
00336 
00337 
00338 
00339 

Copyright © 2003 inuTech GmbH. All rights reserved.