Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:18:32

0001 #ifndef PODIO_UTILITIES_READERCOMMON_H
0002 #define PODIO_UTILITIES_READERCOMMON_H
0003 
0004 #include "podio/podioVersion.h"
0005 #include "podio/utilities/DatamodelRegistryIOHelpers.h"
0006 
0007 #include <optional>
0008 #include <string>
0009 #include <string_view>
0010 #include <vector>
0011 
0012 namespace podio {
0013 
0014 /// Common base class for podio reader classes providing the shared members and
0015 /// functionality related to the file version and the datamodel definitions.
0016 ///
0017 /// The population of the members is left to the derived reader classes.
0018 class ReaderCommon {
0019 public:
0020   /// Get the build version of podio that has been used to write the current
0021   /// file
0022   ///
0023   /// @returns The podio build version
0024   podio::version::Version currentFileVersion() const {
0025     return m_fileVersion;
0026   }
0027 
0028   /// Get the (build) version of a datamodel that has been used to write the
0029   /// current file
0030   ///
0031   /// @param name The name of the datamodel
0032   ///
0033   /// @returns The (build) version of the datamodel if available or an empty
0034   ///          optional
0035   std::optional<podio::version::Version> currentFileVersion(std::string_view name) const {
0036     return m_datamodelHolder.getDatamodelVersion(name);
0037   }
0038 
0039   /// Get the datamodel definition for the given name
0040   ///
0041   /// @param name The name of the datamodel
0042   ///
0043   /// @returns The high level definition of the datamodel in JSON format
0044   const std::string_view getDatamodelDefinition(std::string_view name) const {
0045     return m_datamodelHolder.getDatamodelDefinition(name);
0046   }
0047 
0048   /// Get all names of the datamodels that are available from this reader
0049   ///
0050   /// @returns The names of the datamodels
0051   std::vector<std::string> getAvailableDatamodels() const {
0052     return m_datamodelHolder.getAvailableDatamodels();
0053   }
0054 
0055   /// Get the names of all the available Frame categories in the current file(s).
0056   ///
0057   /// @returns The names of the available categories from the file
0058   std::vector<std::string_view> getAvailableCategories() const {
0059     return std::vector<std::string_view>(m_availableCategories.cbegin(), m_availableCategories.cend());
0060   }
0061 
0062 protected:
0063   podio::version::Version m_fileVersion{};
0064   DatamodelDefinitionHolder m_datamodelHolder{};
0065   std::vector<std::string> m_availableCategories{};
0066 };
0067 
0068 } // namespace podio
0069 
0070 #endif // PODIO_UTILITIES_READERCOMMON_H