10 m_cachedCollections.resize(128);
14 for (
auto& coll : m_collections) {
21 if ((collection =
getFast(
id)) !=
nullptr) {
25 auto val = m_retrievedIDs.insert(
id);
27 if (val.second ==
true) {
29 auto name = m_table->name(
id);
30 success = doGet(name, collection,
true);
31 if (collection !=
nullptr) {
32 if (m_cachedCollections.size() < (
unsigned)
id + 1) {
33 m_cachedCollections.resize(
id + 1);
35 m_cachedCollections[id] = collection;
40 auto name = m_table->name(
id);
41 success = doGet(name, collection,
false);
49 m_collections.push_back({name, coll});
50 auto id = m_table->add(name);
58bool EventStore::doGet(
const std::string& name,
CollectionBase*& collection,
bool setReferences)
const {
59 auto result = std::find_if(begin(m_collections), end(m_collections),
60 [&name](
const CollPair& item) ->
bool {
return name == item.first; });
61 if (result != end(m_collections)) {
62 auto tmp = result->second;
67 }
else if (m_reader !=
nullptr) {
69 if (setReferences ==
true) {
74 if (collectionRegistered(name) ==
false) {
75 m_collections.emplace_back(std::make_pair(name, tmp));
91 if (m_evtMD.
empty() && m_reader !=
nullptr) {
93 m_evtMD = std::move(*tmp);
101 if (m_runMDMap.empty() && m_reader !=
nullptr) {
103 m_runMDMap = std::move(*tmp);
106 return m_runMDMap[runID];
111 if (m_colMDMap.empty() && m_reader !=
nullptr) {
113 m_colMDMap = std::move(*tmp);
116 return m_colMDMap[colID];
120 for (
auto& coll : m_collections) {
121 coll.second->clear();
127 for (
auto& coll : m_collections) {
128 coll.second->clear();
137 m_collections.clear();
138 m_cachedCollections.clear();
139 m_cachedCollections.resize(128);
140 m_retrievedIDs.clear();
143bool EventStore::collectionRegistered(
const std::string& name)
const {
144 auto result = std::find_if(begin(m_collections), end(m_collections),
145 [&name](
const CollPair& item) ->
bool {
return name == item.first; });
146 return (result != end(m_collections));
virtual void setID(unsigned id)=0
set collection ID
virtual bool setReferences(const ICollectionProvider *collectionProvider)=0
initialize references after read
void registerCollection(const std::string &name, podio::CollectionBase *coll)
register an existing collection
virtual bool isValid() const final
bool get(const std::string &name, const T *&collection)
access a collection by name. returns true if successful
GenericParameters & getRunMetaData(int runID) override
return the run meta data for the given runID
void clearCaches()
Clears only the cache containers (use at end of event if ownership of read objects is transferred)
void clear()
clears itself; deletes collections (use at end of event processing)
CollectionBase * getFast(int id) const
fast access to cached collections
GenericParameters & getEventMetaData() override
return the event meta data for the current event
std::pair< std::string, CollectionBase * > CollPair
Collection entry. Each collection is identified by a name.
void clearCollections()
empties collections.
void setReader(IReader *reader)
set the reader
GenericParameters & getCollectionMetaData(int colID) override
return the collection meta data for the given colID
bool empty() const
Check if no parameter is stored (i.e. if all internal maps are empty)
void clear()
erase all elements
virtual CollectionBase * readCollection(const std::string &name)=0
virtual std::shared_ptr< CollectionIDTable > getCollectionIDTable()=0
Get CollectionIDTable of read-in data.
virtual bool isValid() const =0
Check if reader is valid.
virtual std::map< int, GenericParameters > * readRunMetaData()=0
virtual GenericParameters * readEventMetaData()=0
read event meta data from file
virtual std::map< int, GenericParameters > * readCollectionMetaData()=0
std::map< int, GenericParameters > ColMDMap
std::map< int, GenericParameters > RunMDMap