Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 2 additions & 41 deletions include/podio/RNTupleReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<podio::version::Version> 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<std::string> getAvailableDatamodels() const {
return m_datamodelHolder.getAvailableDatamodels();
}

private:
/**
* Initialize the given category by filling the maps with metadata information
Expand All @@ -152,9 +116,6 @@ class RNTupleReader {

std::unique_ptr<root_compat::RNTupleReader> m_metadata{};

podio::version::Version m_fileVersion{};
DatamodelDefinitionHolder m_datamodelHolder{};

std::unordered_map<std::string_view, std::vector<std::unique_ptr<root_compat::RNTupleReader>>> m_readers{};
std::unordered_map<std::string, std::unique_ptr<root_compat::RNTupleReader>> m_metadata_readers{};
std::vector<std::string> m_filenames{};
Expand Down
42 changes: 2 additions & 40 deletions include/podio/ROOTReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<podio::version::Version> 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<std::string_view> 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<std::string> getAvailableDatamodels() const {
return m_datamodelHolder.getAvailableDatamodels();
}
std::optional<std::map<std::string, SizeStats>> getSizeStats(std::string_view category);

private:
Expand Down Expand Up @@ -201,9 +166,6 @@ class ROOTReader {
std::unique_ptr<TChain> m_metaChain{nullptr}; ///< The metadata tree
std::unordered_map<std::string_view, CategoryInfo> m_categories{}; ///< All categories
std::vector<std::string> m_availCategories{}; ///< All available categories from this file

podio::version::Version m_fileVersion{0, 0, 0};
DatamodelDefinitionHolder m_datamodelHolder{};
};

} // namespace podio
Expand Down
44 changes: 2 additions & 42 deletions include/podio/SIOReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sio/definitions.h>

Expand All @@ -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
Expand Down Expand Up @@ -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<podio::version::Version> 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<std::string_view> 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<std::string> getAvailableDatamodels() const {
return m_datamodelHolder.getAvailableDatamodels();
}

private:
void readPodioHeader();

Expand All @@ -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
Expand Down
62 changes: 62 additions & 0 deletions include/podio/utilities/ReaderCommon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#ifndef PODIO_UTILITIES_READERCOMMON_H
#define PODIO_UTILITIES_READERCOMMON_H

#include "podio/podioVersion.h"
#include "podio/utilities/DatamodelRegistryIOHelpers.h"

#include <optional>
#include <string>
#include <string_view>
#include <vector>

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<podio::version::Version> 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<std::string> getAvailableDatamodels() const {
return m_datamodelHolder.getAvailableDatamodels();
}

protected:
podio::version::Version m_fileVersion{};
DatamodelDefinitionHolder m_datamodelHolder{};
};

} // namespace podio

#endif // PODIO_UTILITIES_READERCOMMON_H
Loading