// // This file include and define the macro to be able to use all the // available managers. // #ifdef USE_HBOOK #include "HepTuple/HepHBookFileManager.h" #endif #ifdef USE_HISTOSCOPE #include "HepTuple/HepHistoFileManager.h" #endif #ifdef USE_ROOT #include "HepTuple/HepRootFileManager.h" #endif #include "ZMutility/iostream" #include "ZMutility/fstream" typedef enum _file_types { HBOOK, HISTO, Root } file_types; file_types file_type = HBOOK; #define PARSE \ if ( argc > 1 ) { \ if ( string(argv[argc-1]) == string("-histo") ) { \ file_type = HISTO; \ } else if ( string(argv[argc-1]) == string("-root") ) { \ file_type = Root; \ } \ } bool is_new(std::string name) { std::string filename; switch (file_type) { case HBOOK: filename = name.append(".rz"); break; case HISTO: filename = name.append(".hs"); break; case Root : filename = name.append(".root"); break; }; std::ifstream test(filename.c_str(),std::ios::in); bool newFile = !test; test.close(); return (newFile); } #ifdef USE_HBOOK #define OPEN_HBOOK_FILE(NAME) \ new HepHBookFileManager( ( string(NAME)+".rz" ).c_str() ) #else #define OPEN_HBOOK_FILE(NAME) \ (HepFileManager*) NULL #endif #ifdef USE_HISTOSCOPE #define OPEN_HISTO_FILE(NAME) \ new HepHistoFileManager( ( string(NAME)+".hs" ).c_str() ) #else #define OPEN_HISTO_FILE(NAME) \ (HepFileManager*) NULL #endif #ifdef USE_ROOT #define OPEN_ROOT_FILE(NAME) \ new HepRootFileManager( ( string(NAME)+".root" ).c_str() ) #else #define OPEN_ROOT_FILE(NAME) \ (HepFileManager*) NULL #endif #define OPEN_FILE(NAME) \ ( file_type == HBOOK ) ? ( OPEN_HBOOK_FILE(NAME) ) : \ ( file_type == HISTO ) ? ( OPEN_HISTO_FILE(NAME) ) : \ ( file_type == Root ) ? ( OPEN_ROOT_FILE(NAME) ) : \ ( (HepFileManager*) NULL )