Global registry holding information about datamodels and datatypes defined therein that are currently known by podio (i.e. which have been dynamically loaded).
This is a singleton which is (statically) populated during dynamic loading of generated EDMs. In this context an EDM refers to the shared library that is compiled from the generated code from a datamodel definition in YAML format. When we refer to a datamodel in this context we talk about the entity as a whole, i.e. its definition in a YAML file, but also the concrete implementation as an EDM, as well as all other information that is related to it. In the API of this registry this will be used, unless we want to highlight that we are referring to a specific part of a datamodel.
Definition at line 25 of file DatamodelRegistry.h.
const std::string_view podio::DatamodelRegistry::getDatamodelDefinition |
( |
size_t |
index | ) |
const |
Get the defintion (in JSON format) of the datamodel wth the given index.
If no datamodel is found under the given index, an empty datamodel definition, i.e. an empty JSON object ("{}"), is returned.
- Parameters
-
index | The datamodel definition index that can be obtained from each collection |
Definition at line 44 of file DatamodelRegistry.cc.
44 {
45 if (index >= m_definitions.size()) {
46 std::cerr << "PODIO WARNING: Cannot find the definition for the EDM with the index " << index << std::endl;
47 static constexpr std::string_view emptyDef = "{}";
48 return emptyDef;
49 }
50
51 return m_definitions[index].second;
52}
const std::string_view podio::DatamodelRegistry::getDatamodelDefinition |
( |
std::string_view |
name | ) |
const |
Get the definition (in JSON format) of the datamodel with the given edmName.
If no datamodel with the given name can be found, an empty datamodel definition, i.e. an empty JSON object ("{}"), is returned.
- Parameters
-
name | The name of the datamodel |
Definition at line 32 of file DatamodelRegistry.cc.
32 {
33 const auto it = std::find_if(m_definitions.cbegin(), m_definitions.cend(),
34 [&name](const auto& kvPair) { return kvPair.first == name; });
35 if (it == m_definitions.cend()) {
36 std::cerr << "PODIO WARNING: Cannot find the definition for the EDM with the name " << name << std::endl;
37 static constexpr std::string_view emptyDef = "{}";
38 return emptyDef;
39 }
40
41 return it->second;
42}