10#include <framework/utilities/EnvironmentVariables.h>
11#include <framework/dataobjects/FileMetaData.h>
13#include <boost/python/list.hpp>
14#include <boost/python/tuple.hpp>
20namespace Belle2::Conditions {
37 void append(
const std::string& element);
45 std::variant<std::vector<std::string>, boost::python::list>
m_value;
308 template<
class T>
static void fillFromEnv(T& target,
const std::string& envName,
const std::string& defaultValue)
311 for (
const std::string& v : values) target.append(v);
317 throw std::runtime_error(
"Database already initialized, please reset before changing the configuration object");
Class to enable configuration of the conditions database access in C++ and python.
void appendMetadataProvider(const std::string &provider)
Append a metadata provider to the list.
bool m_overrideEnabled
is the globaltag override enabled?
void setTestingPayloadLocations(const std::vector< std::string > &list)
Set the list of local text files to look for testing payloads.
CppOrPyList m_globalTags
the list with all user globaltags
void setPayloadLocations(const std::vector< std::string > &list)
Set the list of payload locations.
void prependGlobalTag(const std::string &globalTag)
preprend a globaltag
boost::python::tuple getDefaultGlobalTagsPy() const
Get the tuple of default globaltags as python version.
void setGlobalTags(const std::vector< std::string > &list)
Set the list of globaltags.
std::vector< std::string > getMetadataProviders()
Get the list of metadata providers.
void appendGlobalTag(const std::string &globalTag)
Append a globaltag.
Configuration()
Initialize default values.
void prependMetadataProvider(const std::string &provider)
Prepend a metadata provider to the list.
void setMetadataProviders(const std::vector< std::string > &list)
Set the list of metadata providers.
void setInitialized(bool value)
Set by the Database singleton upon initialization and cleanup.
void ensureEditable() const
Check whether the configuration object can be edited or if the database has been initialized already.
void setGlobaltagCallbackPy(const boost::python::object &obj)
Set a callback function from python which will be called when processing starts and should return the...
std::vector< std::string > getTestingPayloadLocations()
Get the list of testing payload locations.
void disableGlobalTagReplay()
Disable global tag replay.
void prependPayloadLocation(const std::string &location)
Prepend a payload to the list of locations.
boost::python::list getGlobalTagsPy()
Get the list of user globaltags as python version.
static Configuration & getInstance()
Get a reference to the instance which will be used when the Database is initialized.
void setMetadataProvidersPy(const boost::python::list &list)
Set the list of metadata providers in python.
boost::python::list getTestingPayloadLocationsPy()
Get the list of text files containing test payloads in python.
std::vector< std::string > getFinalListOfTags()
Get the final list of globaltags to be used for processing.
static void fillFromEnv(T &target, const std::string &envName, const std::string &defaultValue)
Fill a target object from a list of environment variables.
std::string m_newPayloadFile
the file to put the newly created payload information
std::vector< FileMetaData > m_inputMetadata
the file metadata of all input files if globaltag replay is requested by input module
void setDownloadCacheDirectory(const std::string &directory)
Set the directory where to place downloaded payloads.
void setPayloadLocationsPy(const boost::python::list &list)
Set the list of payload locations in python.
CppOrPyList m_metadataProviders
the list with all the metadata providers
void setInputMetadata(const std::vector< FileMetaData > &inputMetadata)
To be called by input modules with the list of all input FileMetaData.
std::set< std::string > m_usableTagStates
the tag states accepted for processing
void setInputGlobaltags(const std::vector< std::string > &inputTags)
To be called by input modules with the tags to be added from input files.
boost::python::list getMetadataProvidersPy()
Get the list of metadata providers in python.
std::string getNewPayloadLocation() const
Get the filename where to save newly created payload information.
CppOrPyList m_testingPayloadLocations
the files with testing payloads to use during processing
void overrideGlobalTags()
Enable globaltag override: If this is called once than overrideEnabled() will return true and getFina...
std::vector< std::string > getGlobalTags()
Get the list of user globaltags.
std::vector< std::string > getBaseTags() const
Get the base globaltags to be used in addition to user globaltags.
void setTestingPayloadLocationsPy(const boost::python::list &list)
Set the list of text files containing test payloads in python.
std::optional< std::vector< std::string > > m_inputGlobaltags
the list of globaltags from all the input files to be used in addition to the user globaltags
void prependTestingPayloadLocation(const std::string &filename)
Prepend a local text file with testing payloads to the list.
void setNewPayloadLocation(const std::string &filename)
Set the file where to save newly created payload information.
void appendPayloadLocation(const std::string &location)
Append a payload to the list of locations.
boost::python::list getPayloadLocationsPy()
Get the list og payload locations in python.
static void exposePythonAPI()
expose this class to python
std::string m_defaultMetadataProviderUrl
default URL where to look for the metadata provider
void setDownloadLockTimeout(size_t timeout)
Set the timout we try to lock a file in the download cache directory for downloading.
std::string getDefaultMetadataProviderUrl()
Get the default URL where to look for the metadata provider.
CppOrPyList m_payloadLocations
the list with all the payload locations
std::vector< std::string > getDefaultGlobalTags() const
Get the std::vector of default globaltags.
std::string getDownloadCacheDirectory() const
Get the directory where to place downloaded payloads.
void overrideGlobalTagsPy(const boost::python::list &globalTags)
Enable globaltag override and set the list of user globaltags in one go.
void reset()
Reset to default values.
const std::set< std::string > & getUsableTagStates() const
Get the set of usable globaltag states allowed to be used for processing.
std::vector< std::string > getPayloadLocations()
Get the list of payload locations.
void setGlobalTagsPy(const boost::python::list &globalTags)
Set the list of globaltags from python.
bool overrideEnabled() const
Check if override is enabled by previous calls to overrideGlobalTags()
std::optional< boost::python::object > m_callback
the callback function to determine the final final list of globaltags
size_t getDownloadLockTimeout() const
Get the timout we try to lock a file in the download cache directory for downloading.
std::string m_downloadCacheDirectory
the directory to put newly downloaded payloads
void appendTestingPayloadLocation(const std::string &filename)
Add a local text file with testing payloads.
size_t m_downloadLockTimeout
the timeout when trying to lock files in the download directory
bool m_databaseInitialized
bool indicating whether the database has been initialized, in which case any changes to the configura...
void setUsableTagStates(const std::set< std::string > &states)
Set the set of usable globaltag states to be allowed for processing.
Wrapper class for a list of strings to either be held in a std::vector or in a python list.
void prepend(const std::string &element)
Prepend an element to whatever representation we currently have.
void shallowCopy(const boost::python::object &source)
shallow copy all elements of the source object into the python representation.
void append(const std::string &element)
Append an element to whatever representation we currently have.
boost::python::list & ensurePy()
Return the python list version.
std::vector< std::string > & ensureCpp()
Return the C++ vector version.
std::variant< std::vector< std::string >, boost::python::list > m_value
Store either a std::vector or a python list of strings.
static std::vector< std::string > getOrCreateList(const std::string &name, const std::string &fallback, const std::string &separators=" \t\n\r")
Get a list of values from an environment variable or the given fallback string if the variable is not...