1 #include "otsdaq/ConfigurationInterface/FileConfigurationInterface.h"
7 #include "otsdaq/ConfigurationInterface/ConfigurationHandler.h"
8 #include "otsdaq/Macros/CoutMacros.h"
9 #include "otsdaq/MessageFacility/MessageFacility.h"
10 #include "otsdaq/TableCore/TableBase.h"
15 void FileConfigurationInterface::fill(
TableBase* configuration,
TableVersion version)
const { ConfigurationHandler::readXML(configuration, version); }
22 auto versions = getVersions(configuration);
25 return *(versions.rbegin());
30 void FileConfigurationInterface::saveActiveVersion(
const TableBase* configuration,
bool )
const { ConfigurationHandler::writeXML(configuration); }
33 std::set<TableVersion> FileConfigurationInterface::getVersions(
const TableBase* configuration)
const
35 std::string configDir = ConfigurationHandler::getXMLDir(configuration);
36 std::cout << __COUT_HDR_FL__ <<
"ConfigurationDir: " << configDir << std::endl;
41 if((dp = opendir(configDir.c_str())) == 0)
43 __SS__ <<
"ERROR:(" << errno <<
"). Can't open directory: " << configDir << std::endl;
44 __COUT_ERR__ << ss.str();
48 const unsigned char isDir = 0x4;
52 std::string::const_iterator it;
54 std::set<TableVersion> dirNumbers;
56 while((dirp = readdir(dp)) != 0)
58 if(dirp->d_type == isDir && dirp->d_name[0] !=
'.')
60 dirName = dirp->d_name;
64 while(it != dirName.end() && std::isdigit(*it))
67 if(dirName.empty() || it != dirName.end())
69 std::cout << __COUT_HDR_FL__ <<
"WARNING: there is a non numeric directory in " << configDir <<
" called " << dirName
70 <<
" please remove it from there since only numeric "
71 "directories are considered."
76 dirNumbers.insert(
TableVersion(strtol(dirp->d_name, 0, 10)));