00001
00002 #include "cafe/ConfigDumper.hpp"
00003
00004 #include <algorithm>
00005 #include <fstream>
00006
00007 #include "cafe/Event.hpp"
00008 #include "cafe/Config.hpp"
00009
00010 namespace cafe {
00011
00012 ConfigDumper::ConfigDumper(const char *name)
00013 : Processor(name)
00014 {
00015 Config config(name);
00016
00017 _dumpToScreen = static_cast<bool>(config.get("DumpToScreen", 1));
00018 _dumpToROOTDir = static_cast<bool>(config.get("DumpToROOTDir", 1));
00019
00020 if (_dumpToROOTDir)
00021 _dumpName = config.get("DumpName","configDB");
00022 }
00023
00024 void ConfigDumper::begin()
00025 {
00026 Config config(name());
00027
00028 if (_dumpToScreen) {
00029 out() << "========================================" << std::endl;
00030 out() << "ConfigDumper[" << name() << "]:"
00031 << " Dumping configuration DB to screen" << std::endl;
00032 config.dumpConfig(out());
00033 out() << "========================================" << std::endl;
00034 }
00035
00036 return;
00037 }
00038
00039 void ConfigDumper::finish()
00040 {
00041 if (_dumpToROOTDir) {
00042 out() << "========================================" << std::endl;
00043 out() << "ConfigDumper[" << name() << "]:"
00044 << " Dumping configuration to current ROOT directory" << std::endl;
00045 out() << " (using name '" << _dumpName << "')" << std::endl;
00046 if (TDirectory* dir = getDirectory()) {
00047 Config config(name());
00048 config.dumpConfig(dir,_dumpName);
00049 } else {
00050
00051 err() << fullName() << ": No valid directory" << std::endl;
00052 }
00053 out() << "========================================" << std::endl;
00054 }
00055
00056 return;
00057 }
00058 }
00059
00060 ClassImp(cafe::ConfigDumper)
00061