1 #include "otsdaq/ConfigurationInterface/ConfigurationInterface.h"
2 #include "otsdaq/ConfigurationInterface/DatabaseConfigurationInterface.h"
3 #include "otsdaq/ConfigurationInterface/FileConfigurationInterface.h"
5 #include "otsdaq/Macros/CoutMacros.h"
6 #include "otsdaq/MessageFacility/MessageFacility.h"
15 #define DEBUG_CONFIGURATION true
19 bool ConfigurationInterface::theMode_ =
true;
20 bool ConfigurationInterface::theVersionTrackingEnabled_ =
true;
22 const std::string ConfigurationInterface::GROUP_METADATA_TABLE_NAME =
"TableGroupMetadata";
25 ConfigurationInterface::ConfigurationInterface() {}
32 if(theInstance_ != 0 && dynamic_cast<FileConfigurationInterface*>(theInstance_) == 0)
43 if(theInstance_ != 0 && dynamic_cast<DatabaseConfigurationInterface*>(theInstance_) == 0)
59 bool ConfigurationInterface::isVersionTrackingEnabled() {
return ConfigurationInterface::theVersionTrackingEnabled_; }
62 void ConfigurationInterface::setVersionTrackingEnabled(
bool setValue) { ConfigurationInterface::theVersionTrackingEnabled_ = setValue; }
73 if(!temporaryVersion.isTemporaryVersion() || !configuration->isStored(temporaryVersion))
75 std::cout << __COUT_HDR_FL__ <<
"Invalid temporary version number: " << temporaryVersion << std::endl;
79 if(!ConfigurationInterface::isVersionTrackingEnabled())
81 newVersion = TableVersion::SCRATCH;
83 bool rewriteableExists =
false;
85 std::set<TableVersion> versions = getVersions(configuration);
86 if(newVersion == TableVersion::INVALID)
89 *(versions.rbegin()) !=
TableVersion(TableVersion::SCRATCH))
90 newVersion = TableVersion::getNextVersion(*(versions.rbegin()));
91 else if(versions.size() > 1)
92 newVersion = TableVersion::getNextVersion(*(--(versions.rbegin())));
94 newVersion = TableVersion::DEFAULT;
95 std::cout << __COUT_HDR_FL__ <<
"Next available version number is " << newVersion << std::endl;
106 else if(versions.find(newVersion) != versions.end())
108 std::cout << __COUT_HDR_FL__ <<
"newVersion(" << newVersion <<
") already exists!" << std::endl;
109 rewriteableExists = newVersion == TableVersion::SCRATCH;
112 if(!rewriteableExists || ConfigurationInterface::isVersionTrackingEnabled())
114 __SS__ << (
"New version already exists!") << std::endl;
115 std::cout << __COUT_HDR_FL__ << ss.str();
120 std::cout << __COUT_HDR_FL__ <<
"Version number to save is " << newVersion << std::endl;
123 configuration->changeVersionAndActivateView(temporaryVersion, newVersion);
128 saveActiveVersion(configuration, !ConfigurationInterface::isVersionTrackingEnabled() && rewriteableExists);