MarlinMT
0.1.0
|
Managed Access and creation of Objects. More...
#include <BookStore.h>
Classes | |
class | Identifier |
holds references for identify an entry. More... | |
Public Member Functions | |
BookStore (bool allowMoving=false) | |
template<class T > | |
Handle< Entry< typename T::Object_t > > | book (const std::filesystem::path &path, const std::string_view &name, const T &data) |
book new object. More... | |
template<typename T > | |
Handle< Entry< T > > | entry (const EntryKey &key) const |
get access to entry from key. More... | |
Selection | find (const Condition &cond) const |
select every Entry which matches the condition. More... | |
WeakEntry | findFirst (const Condition &cond) const |
find first Entry which match the condition. More... | |
void | remove (const EntryKey &key) |
removes an Entry from BookStore. More... | |
void | remove (const Selection &selection) |
removes every Entry from the selection from the BookStore. More... | |
void | clear () |
clears the store. More... | |
void | store (StoreWriter &writer) const |
saves all Objects in one Root-File. More... | |
template<typename Itr > | |
void | storeList (StoreWriter &writer, Itr begin, Itr end) const |
stores only Objects which key is listed. More... | |
void | storeSelection (StoreWriter &writer, const Selection &selection) const |
stores all objects from the selection. More... | |
Private Member Functions | |
std::shared_ptr< details::Entry > | addEntry (const std::shared_ptr< EntryBase > &entry, EntryKey key) |
register Entry in store. More... | |
const std::shared_ptr< details::Entry > & | getPtr (const EntryKey &key) const |
template<class T , typename... Args_t> | |
std::shared_ptr< details::Entry > | bookSingle (std::filesystem::path path, Args_t... ctor_p) |
creates an Entry for a default Object. More... | |
template<class T , void(*)(const std::shared_ptr< T > &, const std::shared_ptr< T > &) MERGE, typename... Args_t> | |
std::shared_ptr< details::Entry > | bookMultiCopy (std::size_t n, std::filesystem::path path, Args_t... ctor_p) |
creates an Entry for parallel access. More... | |
template<class T , typename... Args_t> | |
std::shared_ptr< details::Entry > | bookMultiShared (std::size_t n, std::filesystem::path path, Args_t... ctor_p) |
creates an Entry for parallel access. More... | |
const details::Entry & | get (std::size_t const idx) const |
get Entry from key. More... | |
const details::Entry & | get (const EntryKey &key) const |
get Entry from key. More... | |
details::Entry & | get (std::size_t const idx) |
get Entry from key. More... | |
details::Entry & | get (const EntryKey &key) |
get Entry from key. More... | |
Static Private Member Functions | |
static std::filesystem::path | normalizeDirPath (const std::filesystem::path &path) |
normalize and check path for internal usage. More... | |
Private Attributes | |
std::vector< std::shared_ptr< details::Entry > > | _entries {} |
stores Entries created by BookStore. More... | |
std::unordered_map< Identifier, std::size_t, Identifier::Hash > | _idToEntry {} |
stores path+name -> Entry Id More... | |
std::thread::id | _constructThread |
const bool | _allowMoving {false} |
when false only allow booking from construction thread. Avoid races. More... | |
Friends | |
template<typename , unsigned long long> | |
class | EntryData |
Managed Access and creation of Objects.
Definition at line 96 of file BookStore.h.
|
inlineexplicit |
Definition at line 232 of file BookStore.h.
|
private |
register Entry in store.
generate id for Entry.
Definition at line 23 of file BookStore.cc.
References marlinmt::book::EntryKey::idx, MARLIN_BOOK_THROW, and marlinmt::book::EntryKey::path.
Handle< Entry< typename T::Object_t > > marlinmt::book::BookStore::book | ( | const std::filesystem::path & | path, |
const std::string_view & | name, | ||
const T & | data | ||
) |
book new object.
path | to store object. |
name | of object. |
data | describing access and construction of object. |
BookStoreException | when:
|
Definition at line 389 of file BookStore.h.
References MARLIN_BOOK_THROW.
Referenced by marlinmt::BookStoreManager::bookHist().
|
private |
creates an Entry for parallel access.
Creates Multiple copy's of the object to avoid locks.
n | number of instances which should be created. (max level of pluralism) |
Definition at line 352 of file BookStore.h.
References marlinmt::book::Flags::Book::MultiCopy(), and marlinmt::book::EntryKey::path.
Referenced by marlinmt::book::EntryMultiShared< types::HistT< Config > >::handle().
|
private |
creates an Entry for parallel access.
Creates one object in Memory and modifiers.
n | number of Static Modifiers |
Definition at line 370 of file BookStore.h.
References marlinmt::book::Flags::Book::MultiShared(), and marlinmt::book::EntryKey::path.
Referenced by marlinmt::book::EntryMultiShared< types::HistT< Config > >::handle().
|
private |
creates an Entry for a default Object.
T | object which should be booked. |
Args_t | types of parameters to construct T. |
path | location to store the Entry. |
name | name of the Entry. |
ctor_p | parameters to construct the object. |
Definition at line 332 of file BookStore.h.
References marlinmt::book::EntryKey::path, and marlinmt::book::Flags::Book::Single().
Referenced by marlinmt::book::EntryMultiShared< types::HistT< Config > >::handle().
void marlinmt::book::BookStore::clear | ( | ) |
clears the store.
the handles keep a reference to the result.
Definition at line 81 of file BookStore.cc.
Handle< Entry< T > > marlinmt::book::BookStore::entry | ( | const EntryKey & | key | ) | const |
get access to entry from key.
Definition at line 491 of file BookStore.h.
Referenced by marlinmt::BookStoreManager::getObject().
select every Entry which matches the condition.
Definition at line 57 of file BookStore.cc.
find first Entry which match the condition.
Definition at line 63 of file BookStore.cc.
Referenced by marlinmt::BookStoreManager::getKey().
|
inlineprivate |
get Entry from key.
BookStoreException | key not exist in Store. |
Definition at line 197 of file BookStore.h.
References MARLIN_BOOK_THROW.
|
inlineprivate |
get Entry from key.
BookStoreException | key not exist in Store. |
Definition at line 209 of file BookStore.h.
|
inlineprivate |
get Entry from key.
BookStoreException | key not exist in Store. |
Definition at line 215 of file BookStore.h.
References MARLIN_BOOK_THROW.
|
inlineprivate |
get Entry from key.
BookStoreException | key not exist in Store. |
Definition at line 227 of file BookStore.h.
|
inlineprivate |
key | for Entry which is demanded. |
BookStoreException | key not exist in Store |
Definition at line 136 of file BookStore.h.
References marlinmt::book::EntryKey::idx, and MARLIN_BOOK_THROW.
|
staticprivate |
normalize and check path for internal usage.
BookStoreException | if path is no absolute path to a directory. |
path | absolute directory path. |
Definition at line 92 of file BookStore.cc.
References MARLIN_BOOK_THROW.
void marlinmt::book::BookStore::remove | ( | const EntryKey & | key | ) |
removes an Entry from BookStore.
the handles are keeping a reference to the result.
Definition at line 69 of file BookStore.cc.
void marlinmt::book::BookStore::remove | ( | const Selection & | selection | ) |
void marlinmt::book::BookStore::store | ( | StoreWriter & | writer | ) | const |
saves all Objects in one Root-File.
writer | used to serialize objects. |
BookStoreException | when: Sere kisser
|
Definition at line 39 of file BookStore.cc.
References marlinmt::book::StoreWriter::writeSelection().
void marlinmt::book::BookStore::storeList | ( | StoreWriter & | writer, |
Itr | begin, | ||
Itr | end | ||
) | const |
stores only Objects which key is listed.
writer | used to serialize objects. |
begin | of list with keys |
end | of list with keys (not included) |
Itr | Iterator type used for traversing keys |
Definition at line 471 of file BookStore.h.
References marlinmt::book::Selection::find().
Referenced by marlinmt::BookStoreManager::writeToDisk().
void marlinmt::book::BookStore::storeSelection | ( | StoreWriter & | writer, |
const Selection & | selection | ||
) | const |
stores all objects from the selection.
writer | used to serialize objects. |
selection | which includes objects to write. |
Definition at line 50 of file BookStore.cc.
References marlinmt::book::StoreWriter::writeSelection().
|
friend |
Definition at line 98 of file BookStore.h.
|
private |
when false only allow booking from construction thread. Avoid races.
Definition at line 325 of file BookStore.h.
|
private |
Definition at line 323 of file BookStore.h.
|
private |
stores Entries created by BookStore.
Definition at line 319 of file BookStore.h.
|
private |
stores path+name -> Entry Id
Definition at line 322 of file BookStore.h.