diff --git a/doc/Doxyfile b/doc/Doxyfile index d0cb5066a..9599ed292 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -155,7 +155,7 @@ ALWAYS_DETAILED_SEC = NO # operators of the base classes will not be shown. # The default value is: NO. -INLINE_INHERITED_MEMB = NO +INLINE_INHERITED_MEMB = YES # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the diff --git a/include/podio/RNTupleReader.h b/include/podio/RNTupleReader.h index 80b731b3e..38969925b 100644 --- a/include/podio/RNTupleReader.h +++ b/include/podio/RNTupleReader.h @@ -2,8 +2,7 @@ #define PODIO_RNTUPLEREADER_H #include "podio/ROOTFrameData.h" -#include "podio/podioVersion.h" -#include "podio/utilities/DatamodelRegistryIOHelpers.h" +#include "podio/utilities/ReaderCommon.h" #include "podio/utilities/RootHelpers.h" #include @@ -32,7 +31,7 @@ namespace root_compat { /// /// The RNTupleReader provides the data as ROOTFrameData from which a podio::Frame /// can be constructed. It can be used to read files written by the RNTupleWriter. -class RNTupleReader { +class RNTupleReader : public ReaderCommon { public: RNTupleReader() = default; @@ -103,41 +102,6 @@ class RNTupleReader { /// @returns The number of entries that are available for the category unsigned getEntries(std::string_view name) const; - /// Get the build version of podio that has been used to write the current - /// file - /// - /// @returns The podio build version - podio::version::Version currentFileVersion() const { - return m_fileVersion; - } - - /// Get the (build) version of a datamodel that has been used to write the - /// current file - /// - /// @param name The name of the datamodel - /// - /// @returns The (build) version of the datamodel if available or an empty - /// optional - std::optional currentFileVersion(std::string_view name) const { - return m_datamodelHolder.getDatamodelVersion(name); - } - - /// Get the datamodel definition for the given name - /// - /// @param name The name of the datamodel - /// - /// @returns The high level definition of the datamodel in JSON format - const std::string_view getDatamodelDefinition(std::string_view name) const { - return m_datamodelHolder.getDatamodelDefinition(name); - } - - /// Get all names of the datamodels that are available from this reader - /// - /// @returns The names of the datamodels - std::vector getAvailableDatamodels() const { - return m_datamodelHolder.getAvailableDatamodels(); - } - private: /** * Initialize the given category by filling the maps with metadata information @@ -152,9 +116,6 @@ class RNTupleReader { std::unique_ptr m_metadata{}; - podio::version::Version m_fileVersion{}; - DatamodelDefinitionHolder m_datamodelHolder{}; - std::unordered_map>> m_readers{}; std::unordered_map> m_metadata_readers{}; std::vector m_filenames{}; diff --git a/include/podio/ROOTReader.h b/include/podio/ROOTReader.h index f59c2941d..be32bcb9d 100644 --- a/include/podio/ROOTReader.h +++ b/include/podio/ROOTReader.h @@ -2,8 +2,7 @@ #define PODIO_ROOTREADER_H #include "podio/ROOTFrameData.h" -#include "podio/podioVersion.h" -#include "podio/utilities/DatamodelRegistryIOHelpers.h" +#include "podio/utilities/ReaderCommon.h" #include "podio/utilities/ReaderUtils.h" #include "podio/utilities/RootHelpers.h" @@ -46,7 +45,7 @@ struct CollectionReadBuffers; /// /// The ROOTReader provides the data as ROOTFrameData from which a podio::Frame /// can be constructed. It can be used to read files written by the ROOTWriter. -class ROOTReader { +class ROOTReader : public ReaderCommon { public: ROOTReader() = default; @@ -112,45 +111,11 @@ class ROOTReader { /// @returns The number of entries that are available for the category unsigned getEntries(std::string_view name) const; - /// Get the build version of podio that has been used to write the current - /// file - /// - /// @returns The podio build version - podio::version::Version currentFileVersion() const { - return m_fileVersion; - } - - /// Get the (build) version of a datamodel that has been used to write the - /// current file - /// - /// @param name The name of the datamodel - /// - /// @returns The (build) version of the datamodel if available or an empty - /// optional - std::optional currentFileVersion(std::string_view name) const { - return m_datamodelHolder.getDatamodelVersion(name); - } - /// Get the names of all the available Frame categories in the current file(s). /// /// @returns The names of the available categories from the file std::vector getAvailableCategories() const; - /// Get the datamodel definition for the given name - /// - /// @param name The name of the datamodel - /// - /// @returns The high level definition of the datamodel in JSON format - const std::string_view getDatamodelDefinition(std::string_view name) const { - return m_datamodelHolder.getDatamodelDefinition(name); - } - - /// Get all names of the datamodels that are available from this reader - /// - /// @returns The names of the datamodels - std::vector getAvailableDatamodels() const { - return m_datamodelHolder.getAvailableDatamodels(); - } std::optional> getSizeStats(std::string_view category); private: @@ -201,9 +166,6 @@ class ROOTReader { std::unique_ptr m_metaChain{nullptr}; ///< The metadata tree std::unordered_map m_categories{}; ///< All categories std::vector m_availCategories{}; ///< All available categories from this file - - podio::version::Version m_fileVersion{0, 0, 0}; - DatamodelDefinitionHolder m_datamodelHolder{}; }; } // namespace podio diff --git a/include/podio/SIOReader.h b/include/podio/SIOReader.h index e91ee2e46..51fdefad9 100644 --- a/include/podio/SIOReader.h +++ b/include/podio/SIOReader.h @@ -3,8 +3,7 @@ #include "podio/SIOBlock.h" #include "podio/SIOFrameData.h" -#include "podio/podioVersion.h" -#include "podio/utilities/DatamodelRegistryIOHelpers.h" +#include "podio/utilities/ReaderCommon.h" #include @@ -22,7 +21,7 @@ class CollectionIDTable; /// /// The SIOReader provides the data as SIOFrameData from which a podio::Frame /// can be constructed. It can be used to read files written by the SIOWriter. -class SIOReader { +class SIOReader : public ReaderCommon { public: /// Create an SIOReader @@ -83,46 +82,11 @@ class SIOReader { /// @param filename The path to the file to read from void openFile(const std::string& filename); - /// Get the build version of podio that has been used to write the current - /// file - /// - /// @returns The podio build version - podio::version::Version currentFileVersion() const { - return m_fileVersion; - } - - /// Get the (build) version of a datamodel that has been used to write the - /// current file - /// - /// @param name The name of the datamodel - /// - /// @returns The (build) version of the datamodel if available or an empty - /// optional - std::optional currentFileVersion(std::string_view name) const { - return m_datamodelHolder.getDatamodelVersion(name); - } - /// Get the names of all the available Frame categories in the current file. /// /// @returns The names of the available categores from the file std::vector getAvailableCategories() const; - /// Get the datamodel definition for the given name - /// - /// @param name The name of the datamodel - /// - /// @returns The high level definition of the datamodel in JSON format - const std::string_view getDatamodelDefinition(std::string_view name) const { - return m_datamodelHolder.getDatamodelDefinition(name); - } - - /// Get all names of the datamodels that are available from this reader - /// - /// @returns The names of the datamodels - std::vector getAvailableDatamodels() const { - return m_datamodelHolder.getAvailableDatamodels(); - } - private: void readPodioHeader(); @@ -138,10 +102,6 @@ class SIOReader { /// Table of content record where starting points of named entries can be read from SIOFileTOCRecord m_tocRecord{}; - /// The podio version that has been used to write the file - podio::version::Version m_fileVersion{0}; - - DatamodelDefinitionHolder m_datamodelHolder{}; }; } // namespace podio diff --git a/include/podio/utilities/ReaderCommon.h b/include/podio/utilities/ReaderCommon.h new file mode 100644 index 000000000..31698e358 --- /dev/null +++ b/include/podio/utilities/ReaderCommon.h @@ -0,0 +1,62 @@ +#ifndef PODIO_UTILITIES_READERCOMMON_H +#define PODIO_UTILITIES_READERCOMMON_H + +#include "podio/podioVersion.h" +#include "podio/utilities/DatamodelRegistryIOHelpers.h" + +#include +#include +#include +#include + +namespace podio { + +/// Common base class for podio reader classes providing the shared members and +/// functionality related to the file version and the datamodel definitions. +/// +/// The population of the members is left to the derived reader classes. +class ReaderCommon { +public: + /// Get the build version of podio that has been used to write the current + /// file + /// + /// @returns The podio build version + podio::version::Version currentFileVersion() const { + return m_fileVersion; + } + + /// Get the (build) version of a datamodel that has been used to write the + /// current file + /// + /// @param name The name of the datamodel + /// + /// @returns The (build) version of the datamodel if available or an empty + /// optional + std::optional currentFileVersion(std::string_view name) const { + return m_datamodelHolder.getDatamodelVersion(name); + } + + /// Get the datamodel definition for the given name + /// + /// @param name The name of the datamodel + /// + /// @returns The high level definition of the datamodel in JSON format + const std::string_view getDatamodelDefinition(std::string_view name) const { + return m_datamodelHolder.getDatamodelDefinition(name); + } + + /// Get all names of the datamodels that are available from this reader + /// + /// @returns The names of the datamodels + std::vector getAvailableDatamodels() const { + return m_datamodelHolder.getAvailableDatamodels(); + } + +protected: + podio::version::Version m_fileVersion{}; + DatamodelDefinitionHolder m_datamodelHolder{}; +}; + +} // namespace podio + +#endif // PODIO_UTILITIES_READERCOMMON_H