MarlinMT  0.1.0
marlinmt::BookStoreManager Class Reference

BookStoreManager class. More...

#include <BookStoreManager.h>

Inherits marlinmt::Component.

Classes

struct  ObjectNotFound
 thrown when try to access not existing object. More...
 

Public Member Functions

 BookStoreManager ()
 Constructor. More...
 
 BookStoreManager (const BookStoreManager &)=delete
 
BookStoreManageroperator= (const BookStoreManager &)=delete
 
 BookStoreManager (BookStoreManager &&)=delete
 
BookStoreManageroperator= (BookStoreManager &&)=delete
 
void writeToDisk () const
 reads output File from global StoreOutputFile. More...
 
void initialize () override
 Initialize the book store manager. More...
 
template<typename HistT >
book::Handle< book::Entry< HistT > > bookHist (const std::filesystem::path &path, const std::string_view &name, const std::string_view &title, const std::array< const AxisConfig< typename HistT::Precision_t > *, HistT::Dimension > &axesconfig, const BookFlag_t &flags)
 Book a histogram 1D, float type. More...
 
void addToWrite (const book::EntryKey &key)
 add entry key to write list. More...
 
void removeFromWrite (const book::EntryKey &key)
 remove entry key from write list. More...
 
const book::EntryKeygetKey (const std::filesystem::path &path, const std::string_view &name) const
 receive key from Entry with given path and name. More...
 
template<typename T >
book::Handle< book::Entry< T > > getObject (const book::EntryKey &key) const
 access object managed by this store. More...
 
- Public Member Functions inherited from marlinmt::Component
 Component ()=delete
 No default constructor. More...
 
 Component (const Component &)=delete
 No copy or assignement. More...
 
Componentoperator= (const Component &)=delete
 
virtual ~Component ()=default
 Default destructor. More...
 
 Component (const std::string &type)
 Constructor with component type. More...
 
const std::string & type () const
 Get the component name. More...
 
const std::string & name () const
 Get the component name. More...
 
void setName (const std::string &n)
 Set the component name. More...
 
const std::string & description () const
 Get the component description. More...
 
void setDescription (const std::string &desc)
 Set the component description. More...
 
const Applicationapplication () const
 Get the application in which the component is registered. More...
 
Applicationapplication ()
 Get the application in which the component is registered. More...
 
template<class T >
Logging::StreamType log () const
 Log a message with specific log level. More...
 
Logging::StreamType debug () const
 Shortcut for log<DEBUG>() More...
 
Logging::StreamType message () const
 Shortcut for log<MESSAGE>() More...
 
Logging::StreamType warning () const
 Shortcut for log<WARNING>() More...
 
Logging::StreamType error () const
 Shortcut for log<ERROR>() More...
 
void setVerbosity (const std::string &level)
 Set the verbosity level. More...
 
const std::string & verbosity () const
 Get the verbosity level. More...
 
bool isInitialized () const
 Whether the component has been initialized. More...
 
void setup (Application *app)
 Setup the component. More...
 
void printParameters () const
 Print the component parameters. More...
 
template<class T >
void printParameters () const
 Print the component parameters at specific verbosity. More...
 
void setParameters (const ConfigSection &section, bool throwIfNotFound=false)
 Set the parameters from the configuration section. More...
 
void getParameters (ConfigSection &section, const std::set< std::string > &exclude={}) const
 Get the parameters from configurable object and populate the config section with. More...
 
- Public Member Functions inherited from marlinmt::Configurable
 Configurable ()=default
 
virtual ~Configurable ()=default
 
template<typename T >
std::shared_ptr< ParameterImpladdParameter (EParameterType paramType, const std::string &name, const std::string &desc, std::shared_ptr< T > value)
 Add a parameter. More...
 
template<typename T >
std::shared_ptr< ParameterImpladdParameter (EParameterType paramType, const std::string &name, const std::string &desc, std::shared_ptr< T > value, T defVal)
 Add a parameter. More...
 
template<typename T >
parameter (const std::string &name) const
 Get a parameter value. More...
 
template<typename T >
parameter (const std::string &name, const T &fallback) const
 Get a parameter value. More...
 
void checkParameter (const std::string &name) const
 Check if the parameter has been registered. More...
 
bool exists (const std::string &name) const
 Return true if the parameter has been registered. More...
 
bool isSet (const std::string &name) const
 Returns true if the parameter exists and is set, false otherwise. More...
 
void clear ()
 Remove all parameters. More...
 
void unset ()
 Unset all registered parameters. More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 

Private Attributes

book::BookStore _bookStore {true}
 The book store. More...
 
std::set< book::EntryKey_entriesToWrite {}
 List of entry keys for Entries which should be stored at end of lifetime. More...
 
StringParameter _outputFile {*this, "OutputFile", "The output file name for storage", "MarlinMT_"+details::convert<int>::to_string(::getpid())+".root"}
 Output file name to store objects. More...
 
StringParameter _defaultMemLayout {*this, "DefaultMemoryLayout", "The memory layout for objects", "Default"}
 Output file name to store objects. More...
 
BookFlag_t _defaultFlag { 0 }
 default flag, used if flag == BookFlags::Default. More...
 

Additional Inherited Members

- Public Types inherited from marlinmt::Component
using LoggerPtr = Logging::Logger
 
- Public Types inherited from marlinmt::Configurable
using ParameterMap = std::map< std::string, std::shared_ptr< ParameterImpl > >
 
using iterator = ParameterMap::iterator
 
using const_iterator = ParameterMap::const_iterator
 
- Protected Attributes inherited from marlinmt::Component
std::string _type {}
 The component type. More...
 
std::string _name {}
 The component name. More...
 
std::string _description {"No description"}
 The component description. More...
 
Application_application {nullptr}
 The application in which the component has been registered. More...
 
LoggerPtr _logger {nullptr}
 The logger instance. More...
 
StringParameter _verbosity { *this, "Verbosity", "The component verbosity level", "MESSAGE" }
 The verbosity level of the logger (parameter) More...
 
- Protected Attributes inherited from marlinmt::Configurable
ParameterMap _parameters {}
 The parameter map. More...
 

Detailed Description

BookStoreManager class.

Definition at line 21 of file BookStoreManager.h.

Constructor & Destructor Documentation

◆ BookStoreManager() [1/3]

marlinmt::BookStoreManager::BookStoreManager ( )

Constructor.

Definition at line 45 of file BookStoreManager.cc.

References marlinmt::Component::setName().

◆ BookStoreManager() [2/3]

marlinmt::BookStoreManager::BookStoreManager ( const BookStoreManager )
delete

◆ BookStoreManager() [3/3]

marlinmt::BookStoreManager::BookStoreManager ( BookStoreManager &&  )
delete

Member Function Documentation

◆ addToWrite()

void marlinmt::BookStoreManager::addToWrite ( const book::EntryKey key)

add entry key to write list.

Definition at line 167 of file BookStoreManager.cc.

References _entriesToWrite.

Referenced by bookHist(), and marlinmt::ProcessorApi::Book::write().

◆ bookHist()

template<typename HistT >
book::Handle< book::Entry< HistT > > marlinmt::BookStoreManager::bookHist ( const std::filesystem::path &  path,
const std::string_view &  name,
const std::string_view &  title,
const std::array< const AxisConfig< typename HistT::Precision_t > *, HistT::Dimension > &  axesconfig,
const BookFlag_t flags 
)

◆ getKey()

const book::EntryKey & marlinmt::BookStoreManager::getKey ( const std::filesystem::path &  path,
const std::string_view &  name 
) const

receive key from Entry with given path and name.

Parameters
pathabsolute path of Object
nameof Object
Exceptions
ObjectNotFoundif path don't lead to Object.
Returns
nullptr if path not exist or is not unique
EntryKey address else

Definition at line 179 of file BookStoreManager.cc.

References _bookStore, marlinmt::book::BookStore::findFirst(), marlinmt::book::WeakEntry::key(), marlinmt::Component::setName(), and marlinmt::book::WeakEntry::valid().

Referenced by bookHist(), and marlinmt::getObject().

◆ getObject()

template<typename T >
book::Handle< book::Entry< T > > marlinmt::BookStoreManager::getObject ( const book::EntryKey key) const

access object managed by this store.

For internal usage.

Parameters
keykey for Entry to Object
Returns
optional which contains on success a Handle for the Entry for the Object.

Definition at line 157 of file BookStoreManager.cc.

References _bookStore, marlinmt::book::BookStore::entry(), and marlinmt::book::EntryKey::type.

Referenced by marlinmt::getObject().

◆ initialize()

◆ operator=() [1/2]

BookStoreManager& marlinmt::BookStoreManager::operator= ( const BookStoreManager )
delete

◆ operator=() [2/2]

BookStoreManager& marlinmt::BookStoreManager::operator= ( BookStoreManager &&  )
delete

◆ removeFromWrite()

void marlinmt::BookStoreManager::removeFromWrite ( const book::EntryKey key)

remove entry key from write list.

Definition at line 173 of file BookStoreManager.cc.

References _entriesToWrite.

Referenced by marlinmt::ProcessorApi::Book::dontWrite().

◆ writeToDisk()

void marlinmt::BookStoreManager::writeToDisk ( ) const

reads output File from global StoreOutputFile.

if set to "" (empty) no output file will be generated.

Definition at line 52 of file BookStoreManager.cc.

References _bookStore, _entriesToWrite, _outputFile, marlinmt::ParameterBase< T >::get(), and marlinmt::book::BookStore::storeList().

Member Data Documentation

◆ _bookStore

book::BookStore marlinmt::BookStoreManager::_bookStore {true}
private

The book store.

Definition at line 106 of file BookStoreManager.h.

Referenced by bookHist(), getKey(), getObject(), and writeToDisk().

◆ _defaultFlag

BookFlag_t marlinmt::BookStoreManager::_defaultFlag { 0 }
private

default flag, used if flag == BookFlags::Default.

Default is shared, store. Change is steering file with: store::DefaultMemoryLayout and store::StoreByDefault.

Definition at line 115 of file BookStoreManager.h.

Referenced by bookHist(), and initialize().

◆ _defaultMemLayout

StringParameter marlinmt::BookStoreManager::_defaultMemLayout {*this, "DefaultMemoryLayout", "The memory layout for objects", "Default"}
private

Output file name to store objects.

Definition at line 112 of file BookStoreManager.h.

Referenced by initialize().

◆ _entriesToWrite

std::set<book::EntryKey> marlinmt::BookStoreManager::_entriesToWrite {}
private

List of entry keys for Entries which should be stored at end of lifetime.

Definition at line 108 of file BookStoreManager.h.

Referenced by addToWrite(), removeFromWrite(), and writeToDisk().

◆ _outputFile

StringParameter marlinmt::BookStoreManager::_outputFile {*this, "OutputFile", "The output file name for storage", "MarlinMT_"+details::convert<int>::to_string(::getpid())+".root"}
private

Output file name to store objects.

Definition at line 110 of file BookStoreManager.h.

Referenced by writeToDisk().


The documentation for this class was generated from the following files: