-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename the SIO default reader / writer
- Loading branch information
Showing
9 changed files
with
165 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,10 @@ | ||
#ifndef PODIO_SIOFRAMEREADER_H | ||
#define PODIO_SIOFRAMEREADER_H | ||
|
||
#include "podio/SIOBlock.h" | ||
#include "podio/SIOFrameData.h" | ||
#include "podio/podioVersion.h" | ||
#include "podio/utilities/DatamodelRegistryIOHelpers.h" | ||
|
||
#include <sio/definitions.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <string_view> | ||
#include <unordered_map> | ||
#include "podio/SIOReader.h" | ||
|
||
namespace podio { | ||
|
||
class CollectionIDTable; | ||
|
||
class SIOFrameReader { | ||
|
||
public: | ||
SIOFrameReader(); | ||
~SIOFrameReader() = default; | ||
|
||
// non copyable | ||
SIOFrameReader(const SIOFrameReader&) = delete; | ||
SIOFrameReader& operator=(const SIOFrameReader&) = delete; | ||
|
||
/** | ||
* Read the next data entry from which a Frame can be constructed for the | ||
* given name. In case there are no more entries left for this name or in | ||
* case there is no data for this name, this returns a nullptr. | ||
*/ | ||
std::unique_ptr<podio::SIOFrameData> readNextEntry(const std::string& name); | ||
|
||
/** | ||
* Read the specified data entry from which a Frame can be constructed for | ||
* the given name. In case the entry does not exist for this name or in | ||
* case there is no data for this name, this returns a nullptr. | ||
*/ | ||
std::unique_ptr<podio::SIOFrameData> readEntry(const std::string& name, const unsigned entry); | ||
|
||
/// Returns number of entries for the given name | ||
unsigned getEntries(const std::string& name) const; | ||
|
||
void openFile(const std::string& filename); | ||
|
||
/// Get the build version of podio that has been used to write the current file | ||
podio::version::Version currentFileVersion() const { | ||
return m_fileVersion; | ||
} | ||
|
||
/// Get the names of all the available Frame categories in the current file(s) | ||
std::vector<std::string_view> getAvailableCategories() const; | ||
|
||
/// Get the datamodel definition for the given name | ||
const std::string_view getDatamodelDefinition(const std::string& name) const { | ||
return m_datamodelHolder.getDatamodelDefinition(name); | ||
} | ||
|
||
/// Get all names of the datamodels that ara available from this reader | ||
std::vector<std::string> getAvailableDatamodels() const { | ||
return m_datamodelHolder.getAvailableDatamodels(); | ||
} | ||
|
||
private: | ||
void readPodioHeader(); | ||
|
||
/// read the TOC record | ||
bool readFileTOCRecord(); | ||
|
||
void readEDMDefinitions(); | ||
|
||
sio::ifstream m_stream{}; ///< The stream from which we read | ||
|
||
/// Count how many times each an entry of this name has been read already | ||
std::unordered_map<std::string, unsigned> m_nameCtr{}; | ||
|
||
/// 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 | ||
using SIOFrameReader [[deprecated("Will be removed in v1.0 switch podio::SIOReader")]] = podio::SIOReader; | ||
} | ||
|
||
#endif // PODIO_SIOFRAMEREADER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,10 @@ | ||
#ifndef PODIO_SIOFRAMEWRITER_H | ||
#define PODIO_SIOFRAMEWRITER_H | ||
|
||
#include "podio/SIOBlock.h" | ||
#include "podio/utilities/DatamodelRegistryIOHelpers.h" | ||
|
||
#include <sio/definitions.h> | ||
|
||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
#include "podio/SIOWriter.h" | ||
|
||
namespace podio { | ||
|
||
class Frame; | ||
|
||
class SIOFrameWriter { | ||
public: | ||
SIOFrameWriter(const std::string& filename); | ||
~SIOFrameWriter(); | ||
|
||
SIOFrameWriter(const SIOFrameWriter&) = delete; | ||
SIOFrameWriter& operator=(const SIOFrameWriter&) = delete; | ||
|
||
/** Write the given Frame with the given category | ||
*/ | ||
void writeFrame(const podio::Frame& frame, const std::string& category); | ||
|
||
/** Write the given Frame with the given category only storing the collections | ||
* that are desired via collsToWrite | ||
*/ | ||
void writeFrame(const podio::Frame& frame, const std::string& category, const std::vector<std::string>& collsToWrite); | ||
|
||
void finish(); | ||
|
||
private: | ||
sio::ofstream m_stream{}; ///< The output file stream | ||
SIOFileTOCRecord m_tocRecord{}; ///< The "table of contents" of the written file | ||
DatamodelDefinitionCollector m_datamodelCollector{}; | ||
bool m_finished{false}; ///< Has finish been called already? | ||
}; | ||
} // namespace podio | ||
using SIOFrameWriter [[deprecated("Will be removed in v1.0 switch podio::SIOWriter")]] = podio::SIOWriter; | ||
} | ||
|
||
#endif // PODIO_SIOFRAMEWRITER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#ifndef PODIO_SIOREADER_H | ||
#define PODIO_SIOREADER_H | ||
|
||
#include "podio/SIOBlock.h" | ||
#include "podio/SIOFrameData.h" | ||
#include "podio/podioVersion.h" | ||
#include "podio/utilities/DatamodelRegistryIOHelpers.h" | ||
|
||
#include <sio/definitions.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <string_view> | ||
#include <unordered_map> | ||
|
||
namespace podio { | ||
|
||
class CollectionIDTable; | ||
|
||
class SIOReader { | ||
|
||
public: | ||
SIOReader(); | ||
~SIOReader() = default; | ||
|
||
// non copyable | ||
SIOReader(const SIOReader&) = delete; | ||
SIOReader& operator=(const SIOReader&) = delete; | ||
|
||
/** | ||
* Read the next data entry from which a Frame can be constructed for the | ||
* given name. In case there are no more entries left for this name or in | ||
* case there is no data for this name, this returns a nullptr. | ||
*/ | ||
std::unique_ptr<podio::SIOFrameData> readNextEntry(const std::string& name); | ||
|
||
/** | ||
* Read the specified data entry from which a Frame can be constructed for | ||
* the given name. In case the entry does not exist for this name or in | ||
* case there is no data for this name, this returns a nullptr. | ||
*/ | ||
std::unique_ptr<podio::SIOFrameData> readEntry(const std::string& name, const unsigned entry); | ||
|
||
/// Returns number of entries for the given name | ||
unsigned getEntries(const std::string& name) const; | ||
|
||
void openFile(const std::string& filename); | ||
|
||
/// Get the build version of podio that has been used to write the current file | ||
podio::version::Version currentFileVersion() const { | ||
return m_fileVersion; | ||
} | ||
|
||
/// Get the names of all the available Frame categories in the current file(s) | ||
std::vector<std::string_view> getAvailableCategories() const; | ||
|
||
/// Get the datamodel definition for the given name | ||
const std::string_view getDatamodelDefinition(const std::string& name) const { | ||
return m_datamodelHolder.getDatamodelDefinition(name); | ||
} | ||
|
||
/// Get all names of the datamodels that ara available from this reader | ||
std::vector<std::string> getAvailableDatamodels() const { | ||
return m_datamodelHolder.getAvailableDatamodels(); | ||
} | ||
|
||
private: | ||
void readPodioHeader(); | ||
|
||
/// read the TOC record | ||
bool readFileTOCRecord(); | ||
|
||
void readEDMDefinitions(); | ||
|
||
sio::ifstream m_stream{}; ///< The stream from which we read | ||
|
||
/// Count how many times each an entry of this name has been read already | ||
std::unordered_map<std::string, unsigned> m_nameCtr{}; | ||
|
||
/// 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 | ||
|
||
#endif // PODIO_SIOREADER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef PODIO_SIOWRITER_H | ||
#define PODIO_SIOWRITER_H | ||
|
||
#include "podio/SIOBlock.h" | ||
#include "podio/utilities/DatamodelRegistryIOHelpers.h" | ||
|
||
#include <sio/definitions.h> | ||
|
||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
namespace podio { | ||
|
||
class Frame; | ||
|
||
class SIOWriter { | ||
public: | ||
SIOWriter(const std::string& filename); | ||
~SIOWriter(); | ||
|
||
SIOWriter(const SIOWriter&) = delete; | ||
SIOWriter& operator=(const SIOWriter&) = delete; | ||
|
||
/** Write the given Frame with the given category | ||
*/ | ||
void writeFrame(const podio::Frame& frame, const std::string& category); | ||
|
||
/** Write the given Frame with the given category only storing the collections | ||
* that are desired via collsToWrite | ||
*/ | ||
void writeFrame(const podio::Frame& frame, const std::string& category, const std::vector<std::string>& collsToWrite); | ||
|
||
void finish(); | ||
|
||
private: | ||
sio::ofstream m_stream{}; ///< The output file stream | ||
SIOFileTOCRecord m_tocRecord{}; ///< The "table of contents" of the written file | ||
DatamodelDefinitionCollector m_datamodelCollector{}; | ||
bool m_finished{false}; ///< Has finish been called already? | ||
}; | ||
} // namespace podio | ||
|
||
#endif // PODIO_SIOWRITER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.