File indexing completed on 2025-01-30 10:17:26
0001 #ifndef PODIO_UTILITIES_DATAMODELREGISTRYIOHELPERS_H
0002 #define PODIO_UTILITIES_DATAMODELREGISTRYIOHELPERS_H
0003
0004 #include "podio/CollectionBase.h"
0005 #include "podio/DatamodelRegistry.h"
0006
0007 #include <set>
0008 #include <string>
0009 #include <tuple>
0010 #include <vector>
0011
0012 namespace podio {
0013
0014
0015
0016 class DatamodelDefinitionCollector {
0017 public:
0018
0019
0020
0021
0022
0023 void registerDatamodelDefinition(const podio::CollectionBase* coll, const std::string& name);
0024
0025
0026 std::vector<std::tuple<std::string, std::string>> getDatamodelDefinitionsToWrite() const;
0027
0028 private:
0029 std::set<size_t> m_edmDefRegistryIdcs{};
0030 };
0031
0032
0033
0034 class DatamodelDefinitionHolder {
0035 public:
0036
0037 using MapType = std::vector<std::tuple<std::string, std::string>>;
0038
0039 using VersionList = std::vector<std::tuple<std::string, podio::version::Version>>;
0040
0041
0042 DatamodelDefinitionHolder(MapType&& definitions, VersionList&& versions) :
0043 m_availEDMDefs(std::move(definitions)), m_edmVersions(std::move(versions)) {
0044 }
0045
0046 DatamodelDefinitionHolder() = default;
0047 ~DatamodelDefinitionHolder() = default;
0048 DatamodelDefinitionHolder(const DatamodelDefinitionHolder&) = delete;
0049 DatamodelDefinitionHolder& operator=(const DatamodelDefinitionHolder&) = delete;
0050 DatamodelDefinitionHolder(DatamodelDefinitionHolder&&) = default;
0051 DatamodelDefinitionHolder& operator=(DatamodelDefinitionHolder&&) = default;
0052
0053
0054
0055
0056
0057
0058
0059 const std::string_view getDatamodelDefinition(const std::string& name) const;
0060
0061
0062 std::vector<std::string> getAvailableDatamodels() const;
0063
0064 std::optional<podio::version::Version> getDatamodelVersion(const std::string& name) const;
0065
0066 protected:
0067 MapType m_availEDMDefs{};
0068 VersionList m_edmVersions{};
0069 };
0070
0071 }
0072
0073 #endif