9#include <framework/core/SwitchDataStoreModule.h>
10#include <framework/datastore/DataStore.h>
21 setDescription(
"Internal module used by Path.add_independent_path(). This shouldn't appear in 'basf2 -m' output. If it does, check REG_MODULE() handling.");
23 addParam(
"toID",
m_to,
"active DataStore id after this module", std::string(
""));
25 "should data be copied to DataStore 'toID'? This should be true only when toID refers to a _new_ DataStore ID",
false);
26 addParam(
"mergeBack",
m_mergeBack,
"if given, copy the given objects/arrays over even if doCopy is fals.", std::vector<std::string> {});
29SwitchDataStoreModule::~SwitchDataStoreModule() =
default;
41 B2FATAL(
"identical from/to parameter value " <<
m_from);
43 B2FATAL(
"doCopy is set for default DataStore ID! This would likely cause corruption.");
45 B2FATAL(
"doCopy is not set ?");
void createNewDataStoreID(const std::string &id)
creates new datastore with given id, copying the registered objects/arrays from the current one.
void copyEntriesTo(const std::string &id, const std::vector< std::string > &entrylist_event={}, bool mergeEntries=false)
copy entries (not contents) of current DataStore to the DataStore with given ID.
void switchID(const std::string &id)
switch to DataStore with given ID.
void copyContentsTo(const std::string &id, const std::vector< std::string > &entrylist_event={})
copy contents (actual array / object contents) of current DataStore to the DataStore with given ID.
std::string currentID() const
returns ID of current DataStore.
static DataStore & Instance()
Instance of singleton Store.
void setDescription(const std::string &description)
Sets the description of the module.
std::string m_from
active DataStore ID before this module.
virtual void initialize() override
Initialize the Module.
virtual void event() override
This method is the core of the module.
bool m_doCopy
should data be copied to m_to?
virtual void endRun() override
This method is called if the current run ends.
virtual void terminate() override
This method is called at the end of the event processing.
SwitchDataStoreModule()
Constructor.
virtual void beginRun() override
Called when entering a new run.
std::vector< std::string > m_mergeBack
list of obj/arrays (of event durability) that should be copied to m_to regardless of m_doCopy.
std::string m_to
active DataStore ID after this module.
void init(const std::string &to, bool doCopy, const std::vector< std::string > &mergeBack)
setter for Path.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.