15 #include <sys/types.h> 20 #define INSTANCIATIONS_HIST(type) \ 21 template book::Handle<book::Entry<type>> BookStoreManager::getObject<type>(\ 22 const book::EntryKey&) const ;\ 24 template book::Handle<book::Entry<type>> BookStoreManager::bookHist<type>(\ 25 const std::filesystem::path&,\ 26 const std::string_view&,\ 27 const std::string_view&,\ 29 const AxisConfig<typename type::Precision_t>*,\ 61 if( config.hasSection(
"bookstore") ) {
62 const auto §ion = config.
section(
"bookstore") ;
66 static const std::map<std::string, BookFlag_t> flags {
75 if( 1 ==
application().cmdLineParseResult()._nthreads ) {
79 auto iter = flags.find( memLayoutStr ) ;
80 if( flags.end() == iter ) {
83 memoryLayout = iter->second ;
90 template<
typename HistT>
92 const std::filesystem::path &path,
93 const std::string_view &
name,
94 const std::string_view &title,
115 Entry_t res = getObject<HistT>(
getKey(path, name)) ;
117 if ( key.flags != flagsToPass
118 || key.type != std::type_index(
typeid(
HistT))) {
136 _logger->log<ERROR>() <<
"Single Memory layout can't be used" 137 " with concurrency! \n" 138 "\tuse MarlinMT for workflows without concurrency";
159 if (key.
type == std::type_index(
typeid(T))) {
180 const std::filesystem::path &path,
181 const std::string_view &
name)
const 185 .setPath(path.string())
static constexpr std::size_t Dimension
Dimension of the histogram.
Data selection to identify and manage an Entry.
constexpr Flag_t MemoryLayout(Flags::value(Flags::Book::Single)|Flags::value(Flags::Book::MultiShared)|Flags::value(Flags::Book::MultiCopy))
Mask for Flags with memory layout options.
StringParameter _defaultMemLayout
Output file name to store objects.
const std::string & name() const
Get the component name.
BookStoreManager()
Constructor.
bool valid() const
check if WeakEntry is usable.
Container for data to construct and setup booked object.
unsigned int nthreads(const std::string &str)
const EntryKey & key() const
get key from Entry.
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.
void setName(const std::string &n)
Set the component name.
void setParameters(const ConfigSection §ion, bool throwIfNotFound=false)
Set the parameters from the configuration section.
WeakEntry findFirst(const Condition &cond) const
find first Entry which match the condition.
LoggerPtr _logger
The logger instance.
const CmdLineParseResult & cmdLineParseResult() const
Get the command line parsing result (after init)
constexpr Flag_t Store(1U<< 3U)
store object in file at end of lifetime
Flag type for flags in marlinmt::book.
std::set< book::EntryKey > _entriesToWrite
List of entry keys for Entries which should be stored at end of lifetime.
void initialize() override
Initialize the book store manager.
Handle< Entry< T > > entry(const EntryKey &key) const
get access to entry from key.
void writeToDisk() const
reads output File from global StoreOutputFile.
Generalized histogram class.
#define MARLINMT_THROW(message)
constexpr Flag_t MultiShared(1U<< 1U)
create one instance witch concurrent access.
unsigned int _nthreads
The number of threads.
book::Handle< book::Entry< T > > getObject(const book::EntryKey &key) const
access object managed by this store.
Wrapper for weak pointer to Entry.
void removeFromWrite(const book::EntryKey &key)
remove entry key from write list.
collection for Axis Description
Handle< Entry< typename T::Object_t > > book(const std::filesystem::path &path, const std::string_view &name, const T &data)
book new object.
ConfigSection & section(const std::string &sn)
Get a section by name.
bool contains(const Flag_t &f) const
check if the flags is a subset of the other.
const Application & application() const
Get the application in which the component is registered.
void storeList(StoreWriter &writer, Itr begin, Itr end) const
stores only Objects which key is listed.
T get() const
Get the parameter value.
thrown when try to access not existing object.
INSTANCIATIONS_HIST(Hist1F)
helper to create a Condition.
constexpr Flag_t MultiCopy(1U<< 2U)
create multiple instances of booked object (if possible) to avoid sync points
void to_lower(std::string &str)
constexpr Flag_t Default(0)
use default arguments
const book::EntryKey & getKey(const std::filesystem::path &path, const std::string_view &name) const
receive key from Entry with given path and name.
void addToWrite(const book::EntryKey &key)
add entry key to write list.
BookFlag_t _defaultFlag
default flag, used if flag == BookFlags::Default.
book::BookStore _bookStore
The book store.
constexpr Flag_t Single(1U<< 0U)
vanilla object.
const Configuration & configuration() const
Get the main application configuration object.
std::type_index type
Type of object stored in Entry.
StringParameter _outputFile
Output file name to store objects.