PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
CollectionIDTable.h
Go to the documentation of this file.
1#ifndef PODIO_COLLECTIONIDTABLE_H
2#define PODIO_COLLECTIONIDTABLE_H
3
4#include <memory>
5#include <mutex>
6#include <string>
7#include <vector>
8
9namespace podio {
10
12
13public:
15 ~CollectionIDTable() = default;
16
21
22 /// constructor from existing ID:name mapping
23 CollectionIDTable(std::vector<int>&& ids, std::vector<std::string>&& names);
24
25 CollectionIDTable(const std::vector<int>& ids, const std::vector<std::string>& names);
26
27 /// return collection ID for given name
28 int collectionID(const std::string& name) const;
29
30 /// return name for given collection ID
31 const std::string name(int collectionID) const;
32
33 /// Check if collection name is known
34 bool present(const std::string& name) const;
35
36 /// return registered names
37 const std::vector<std::string>& names() const {
38 return m_names;
39 };
40
41 /// return the ids
42 const std::vector<int>& ids() const {
43 return m_collectionIDs;
44 }
45
46 /// register new name to the table
47 /// returns assigned collection ID
48 int add(const std::string& name);
49
50 /// Prints collection information
51 void print() const;
52
53 /// Does this table hold any information?
54 bool empty() const {
55 return m_names.empty();
56 }
57
58private:
59 std::vector<int> m_collectionIDs{};
60 std::vector<std::string> m_names{};
61 mutable std::unique_ptr<std::mutex> m_mutex{nullptr};
62};
63
64} // namespace podio
65#endif
CollectionIDTable(CollectionIDTable &&)=default
void print() const
Prints collection information.
bool present(const std::string &name) const
Check if collection name is known.
int add(const std::string &name)
bool empty() const
Does this table hold any information?
const std::vector< int > & ids() const
return the ids
CollectionIDTable & operator=(const CollectionIDTable &)=delete
int collectionID(const std::string &name) const
return collection ID for given name
const std::vector< std::string > & names() const
return registered names
CollectionIDTable & operator=(CollectionIDTable &&)=default
const std::string name(int collectionID) const
return name for given collection ID
CollectionIDTable(const CollectionIDTable &)=delete