1 #include "otsdaq/ConfigurationInterface/ConfigurationInterface.h"
2 #include "otsdaq/ConfigurationInterface/MakeConfigurationInterface.h"
4 #include "otsdaq/Macros/CoutMacros.h"
5 #include "otsdaq/MessageFacility/MessageFacility.h"
14 #define DEBUG_CONFIGURATION true
18 ConfigurationInterface::CONFIGURATION_MODE ConfigurationInterface::theMode_ =
19 ConfigurationInterface::CONFIGURATION_MODE::DO_NOT_CREATE;
20 bool ConfigurationInterface::theVersionTrackingEnabled_ =
true;
22 const std::string ConfigurationInterface::GROUP_METADATA_TABLE_NAME =
30 ConfigurationInterface::CONFIGURATION_MODE mode )
32 if(mode == CONFIGURATION_MODE::DO_NOT_CREATE)
34 if(theInstance_ ==
nullptr)
37 <<
"WARNING -- returning a nullptr ConfigurationInterface::theInstance_"
42 auto instanceType = (mode == CONFIGURATION_MODE::XML_FILE) ?
"File" :
"Database";
46 theInstance_ =
nullptr;
48 if(theInstance_ ==
nullptr)
50 theInstance_ = makeConfigurationInterface(instanceType);
58 bool ConfigurationInterface::isVersionTrackingEnabled()
60 return ConfigurationInterface::theVersionTrackingEnabled_;
64 void ConfigurationInterface::setVersionTrackingEnabled(
bool setValue)
66 ConfigurationInterface::theVersionTrackingEnabled_ = setValue;
70 const ConfigurationInterface::CONFIGURATION_MODE& ConfigurationInterface::getMode()
72 return ConfigurationInterface::theMode_;
88 std::cout << __COUT_HDR_FL__
89 <<
"Invalid temporary version number: " << temporaryVersion
94 if(!ConfigurationInterface::isVersionTrackingEnabled())
96 newVersion = TableVersion::SCRATCH;
98 bool rewriteableExists =
false;
100 std::set<TableVersion> versions = getVersions(table);
101 if(newVersion == TableVersion::INVALID)
105 *(versions.rbegin()) !=
TableVersion(TableVersion::SCRATCH))
107 else if(versions.size() >
111 newVersion = TableVersion::DEFAULT;
112 std::cout << __COUT_HDR_FL__ <<
"Next available version number is " << newVersion
124 else if(versions.find(newVersion) != versions.end())
126 std::cout << __COUT_HDR_FL__ <<
"newVersion(" << newVersion <<
") already exists!"
128 rewriteableExists = newVersion == TableVersion::SCRATCH;
131 if(!rewriteableExists || ConfigurationInterface::isVersionTrackingEnabled())
133 __SS__ << (
"New version already exists!") << std::endl;
134 std::cout << __COUT_HDR_FL__ << ss.str();
139 std::cout << __COUT_HDR_FL__ <<
"Version number to save is " << newVersion
143 table->changeVersionAndActivateView(temporaryVersion, newVersion);
149 table, !ConfigurationInterface::isVersionTrackingEnabled() && rewriteableExists);
ConfigurationInterface(void)
Protected constructor.
TableVersion saveNewVersion(TableBase *configuration, TableVersion temporaryVersion, TableVersion newVersion=TableVersion())
static TableVersion getNextVersion(const TableVersion &version=TableVersion())
bool isTemporaryVersion(void) const