00001 #ifndef __StarChairDefs_h
00002 #include <assert.h>
00003 #include "TDatime.h"
00004 #define __StarChairDefs_h
00005 #define DEBUGTABLE(STRUCT) \
00006 St_db_Maker *dbMk = (St_db_Maker *) StMaker::GetChain()->Maker("db"); \
00007 if (dbMk && dbMk->Debug() ) { \
00008 TDatime t[2]; \
00009 dbMk->GetValidity(table,t); \
00010 Int_t Nrows = table->GetNRows(); \
00011 LOG_WARN << "St_" << # STRUCT << "C::instance found table " << table->GetName() \
00012 << " with NRows = " << Nrows << " in db" << endm; \
00013 LOG_WARN << "Validity:" << t[0].GetDate() << "/" << t[0].GetTime() \
00014 << " ----- " << t[1].GetDate() << "/" << t[1].GetTime() << endm; \
00015 if (Nrows > 10) Nrows = 10; \
00016 if (table->GetRowSize() < 256) table->Print(0,Nrows); \
00017 }
00018 #define MakeString(PATH) # PATH
00019 #define MakeChairInstance(STRUCT,PATH) \
00020 ClassImp(St_ ## STRUCT ## C); \
00021 St_ ## STRUCT ## C *St_ ## STRUCT ## C::fgInstance = 0; \
00022 St_ ## STRUCT ## C *St_ ## STRUCT ## C::instance() { \
00023 if (fgInstance) return fgInstance; \
00024 St_ ## STRUCT *table = (St_ ## STRUCT *) StMaker::GetChain()->GetDataBase(MakeString(PATH)); \
00025 if (! table) { \
00026 LOG_WARN << "St_" << # STRUCT << "C::instance " << MakeString(PATH) << "\twas not found" << endm; \
00027 assert(table); \
00028 } \
00029 DEBUGTABLE(STRUCT); \
00030 fgInstance = new St_ ## STRUCT ## C(table); \
00031 return fgInstance; \
00032 }
00033 #define MakeChairOptionalInstance(STRUCT,PATH) \
00034 ClassImp(St_ ## STRUCT ## C); \
00035 St_ ## STRUCT ## C *St_ ## STRUCT ## C::fgInstance = 0; \
00036 St_ ## STRUCT ## C *St_ ## STRUCT ## C::instance() { \
00037 if (fgInstance) return fgInstance; \
00038 St_ ## STRUCT *table = (St_ ## STRUCT *) StMaker::GetChain()->GetDataBase(MakeString(PATH)); \
00039 if (! table) { \
00040 table = new St_ ## STRUCT(# STRUCT ,0); \
00041 table->Mark(); \
00042 LOG_WARN << "St_" << # STRUCT << "C::instance create optional " << # STRUCT << " table" << endm; \
00043 } \
00044 assert(table); DEBUGTABLE(STRUCT); \
00045 fgInstance = new St_ ## STRUCT ## C(table); \
00046 return fgInstance; \
00047 }
00048 #define MakeChairInstance2(STRUCT,CLASS,PATH) \
00049 ClassImp(CLASS); \
00050 CLASS *CLASS::fgInstance = 0; \
00051 CLASS *CLASS::instance() { \
00052 if (fgInstance) return fgInstance; \
00053 St_ ## STRUCT *table = (St_ ## STRUCT *) StMaker::GetChain()->GetDataBase(MakeString(PATH)); \
00054 assert(table); DEBUGTABLE(STRUCT); \
00055 fgInstance = new CLASS(table); \
00056 return fgInstance; \
00057 }
00058 #endif