 |
Belle II Software
release-05-02-19
|
12 #include <framework/database/PayloadMetadata.h>
15 #include <unordered_map>
24 namespace Conditions {
41 class TestingPayloadStorage {
47 bool get(
const EventMetaData& event, PayloadMetadata& info);
51 bool storeData(
const std::string& name, TObject*
object,
const IntervalOfValidity& iov);
55 bool storePayload(
const std::string& name,
const std::string& fileName,
const IntervalOfValidity& iov);
62 std::unordered_map<std::string, std::vector<std::tuple<size_t, IntervalOfValidity>>>
m_payloads;
74 static std::string
payloadFilename(
const std::string& path,
const std::string& name,
int revision);
78 bool writePayload(
const std::string& fileName,
const std::string& name,
const TObject*
object);
84 bool store(
const std::string& name,
const IntervalOfValidity& iov,
const std::function<
bool(
const std::string&)>& writer);
A class that describes the interval of experiments/runs for which an object in the database is valid.
bool m_initialized
Remember whether we read the file already.
std::string m_filename
Storage file where to look for payloads.
void read()
Read the given storage file, done lazily on first access to get() after construction or call to reset...
std::string m_payloadDir
Directory containing the storage file as absolute file name.
Abstract base class for different kinds of events.
bool get(const EventMetaData &event, PayloadMetadata &info)
Try to fill the PayloadMetaData for the given EventMetaData, return true on success,...
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 writePayload(const std::string &fileName, const std::string &name, const TObject *object)
Write a payload file from the given object and name.
std::string m_absoluteFilename
Storage file where to look for payloads converted to an absolute path to be robust against directory ...
bool store(const std::string &name, const IntervalOfValidity &iov, const std::function< bool(const std::string &)> &writer)
Try to store a new payload with the given name and interval of validity.
static std::string payloadFilename(const std::string &path, const std::string &name, int 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< size_t, IntervalOfValidity > > > m_payloads
Map of known payloads to a list of known revisions and their interval of validity.
void reset()
Reset the list of known payloads.
TestingPayloadStorage(const std::string &filename)
Create a new instance to work on a given filename.
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.