10#include <framework/database/PayloadMetadata.h>
13#include <unordered_map>
22 namespace Conditions {
60 std::unordered_map<std::string, std::vector<std::tuple<std::string, IntervalOfValidity>>>
m_payloads;
72 static std::string
payloadFilename(
const std::string& path,
const std::string& name,
const std::string& revision);
76 bool writePayload(
const std::string& fileName,
const std::string& name,
const TObject*
object);
89 const std::function<
bool(
const std::string&)>& writer);
Class to store and retrieve temporary payloads.
bool storePayload(const std::string &name, const std::string &fileName, const IntervalOfValidity &iov)
Store an existing file as payload with given name and interval of validity.
bool m_initialized
Remember whether we read the file already.
std::string m_payloadDir
Directory containing the storage file as absolute file name.
bool writePayload(const std::string &fileName, const std::string &name, const TObject *object)
Write a payload file from the given object and name.
static std::string payloadFilename(const std::string &path, const std::string &name, const std::string &revision)
Build the filename for a new payload with a given name and revision in a directory.
std::unordered_map< std::string, std::vector< std::tuple< std::string, IntervalOfValidity > > > m_payloads
Map of known payloads to a list of known revisions and their interval of validity.
void read()
Read the given storage file, done lazily on first access to get() after construction or call to reset...
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store a TObject instance as a payload with given name and interval of validity.
bool store(const std::string &name, const IntervalOfValidity &iov, const std::string &source, const std::function< bool(const std::string &)> &writer)
Try to store a new payload with the given name and interval of validity.
bool get(const EventMetaData &event, PayloadMetadata &info)
Try to fill the PayloadMetaData for the given EventMetaData, return true on success,...
std::string m_filename
Storage file where to look for payloads.
std::string m_absoluteFilename
Storage file where to look for payloads converted to an absolute path to be robust against directory ...
void reset()
Reset the list of known payloads.
A class that describes the interval of experiments/runs for which an object in the database is valid.
Abstract base class for different kinds of events.