PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
DatamodelRegistryIOHelpers.h
Go to the documentation of this file.
1#ifndef PODIO_UTILITIES_DATAMODELREGISTRYIOHELPERS_H
2#define PODIO_UTILITIES_DATAMODELREGISTRYIOHELPERS_H
3
6
7#include <set>
8#include <string>
9#include <tuple>
10#include <vector>
11
12namespace podio {
13
14/**
15 * Helper class to collect the datamodel (JSON) definitions that should be
16 * written.
17 */
19public:
20 /**
21 * Register the datamodel definition of the EDM this collection is from to be
22 * written.
23 *
24 * @param coll A collection of an EDM
25 * @param name The name under which this collection is stored on file
26 */
27 void registerDatamodelDefinition(const podio::CollectionBase* coll, const std::string& name);
28
29 /// Get all the names and JSON definitions that need to be written
30 std::vector<std::tuple<std::string, std::string>> getDatamodelDefinitionsToWrite() const;
31
32private:
33 std::set<size_t> m_edmDefRegistryIdcs{}; ///< The indices in the EDM definition registry that need to be written
34};
35
36/**
37 * Helper class to hold and provide the datamodel (JSON) definitions for reader
38 * classes.
39 */
41public:
42 /// The "map" type that is used internally
43 using MapType = std::vector<std::tuple<std::string, std::string>>;
44 /// Constructor from an existing collection of names and datamodel definitions
45 DatamodelDefinitionHolder(MapType&& definitions) : m_availEDMDefs(std::move(definitions)) {
46 }
47
54
55 /**
56 * Get the datamodel definition for the given datamodel name.
57 *
58 * Returns an empty model definition if no model is stored under the given
59 * name.
60 *
61 * @param name The name of the datamodel
62 */
63 const std::string_view getDatamodelDefinition(const std::string& name) const;
64
65 /**
66 * Get all names of the datamodels that have been read from file
67 */
68 std::vector<std::string> getAvailableDatamodels() const;
69
70protected:
72};
73
74} // namespace podio
75
76#endif // PODIO_UTILITIES_DATAMODELREGISTRYIOHELPERS_H
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)
DatamodelDefinitionHolder & operator=(const DatamodelDefinitionHolder &)=delete
std::vector< std::string > getAvailableDatamodels() const
std::vector< std::tuple< std::string, std::string > > MapType
The "map" type that is used internally.
const std::string_view getDatamodelDefinition(const std::string &name) const
DatamodelDefinitionHolder(const DatamodelDefinitionHolder &)=delete
DatamodelDefinitionHolder & operator=(DatamodelDefinitionHolder &&)=default
DatamodelDefinitionHolder(MapType &&definitions)
Constructor from an existing collection of names and datamodel definitions.
DatamodelDefinitionHolder(DatamodelDefinitionHolder &&)=default