PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
DatamodelRegistryIOHelpers.cc
Go to the documentation of this file.
2#include <iterator>
3
4namespace podio {
5
7 const std::string& name) {
8 const auto edmIndex = coll->getDatamodelRegistryIndex();
10 std::cerr << "No EDM definition available for collection " << name << std::endl;
11 } else {
13 m_edmDefRegistryIdcs.insert(edmIndex);
14 }
15 }
16}
17
18std::vector<std::tuple<std::string, std::string>> DatamodelDefinitionCollector::getDatamodelDefinitionsToWrite() const {
19 std::vector<std::tuple<std::string, std::string>> edmDefinitions;
20 edmDefinitions.reserve(m_edmDefRegistryIdcs.size());
21 for (const auto& index : m_edmDefRegistryIdcs) {
22 const auto& edmRegistry = podio::DatamodelRegistry::instance();
23 edmDefinitions.emplace_back(edmRegistry.getDatamodelName(index), edmRegistry.getDatamodelDefinition(index));
24 }
25
26 return edmDefinitions;
27}
28
29const std::string_view DatamodelDefinitionHolder::getDatamodelDefinition(const std::string& name) const {
30 const auto it = std::find_if(m_availEDMDefs.cbegin(), m_availEDMDefs.cend(),
31 [&name](const auto& entry) { return std::get<0>(entry) == name; });
32
33 if (it != m_availEDMDefs.cend()) {
34 return std::get<1>(*it);
35 }
36
37 return "{}";
38}
39
40std::vector<std::string> DatamodelDefinitionHolder::getAvailableDatamodels() const {
41 std::vector<std::string> defs{};
42 defs.reserve(m_availEDMDefs.size());
43 std::transform(m_availEDMDefs.cbegin(), m_availEDMDefs.cend(), std::back_inserter(defs),
44 [](const auto& elem) { return std::get<0>(elem); });
45
46 return defs;
47}
48
49} // namespace podio
virtual size_t getDatamodelRegistryIndex() const =0
Get the index in the DatatypeRegistry of the EDM this collection belongs to.
std::vector< std::tuple< std::string, std::string > > getDatamodelDefinitionsToWrite() const
Get all the names and JSON definitions that need to be written.
void registerDatamodelDefinition(const podio::CollectionBase *coll, const std::string &name)
std::vector< std::string > getAvailableDatamodels() const
const std::string_view getDatamodelDefinition(const std::string &name) const
static const DatamodelRegistry & instance()
Get the registry.
static constexpr size_t NoDefinitionAvailable
Dedicated index value for error checking, used to default init the generated RegistryIndex.
static constexpr size_t NoDefinitionNecessary