Namespace podio

namespace podio

Typedefs

template<typename T>
using UVecPtr = std::unique_ptr<std::vector<T>>
using CollRefCollection = std::vector<UVecPtr<podio::ObjectID>>
using VectorMembersInfo = std::vector<std::pair<std::string, void*>>
using RelationNameMapping = std::vector<std::tuple<std::string_view, std::vector<std::string_view>, std::vector<std::string_view>>>

Type alias for storing the names of all Relations and VectorMembers for all datatypes of an EDM.

Populated for each EDM at code generation time. The structure is of each element in the outer vector is:

  • get<0>: The name of the datatype

  • get<1>: The names of all Relations, where OneToManyRelations comes before OneToOneRelations (in the order as they appear in the YAML file)

  • get<2>: The names of all VectorMembers (in the order of the file YAML)

template<typename T>
using EnableIfCollection = typename std::enable_if_t<isCollection<T>>

Alias template for enabling overloads only for Collections.

template<typename T>
using EnableIfCollectionRValue = typename std::enable_if_t<isCollection<T> && !std::is_lvalue_reference_v<T>>

Alias template for enabling overloads only for Collection r-values.

template<typename T>
using EnableIfRValue = typename std::enable_if_t<!std::is_lvalue_reference_v<T>>

Alias template for enabling overloads for r-values.

using SupportedGenericDataTypes = std::tuple<int, float, std::string, double>

The types which are supported in the GenericParameters.

template<typename T>
using EnableIfValidGenericDataType = typename std::enable_if_t<isSupportedGenericDataType<T>>

Alias template to be used for enabling / disabling template overloads that should only be present for actually supported data types.

template<typename T>
using GenericDataReturnType = typename detail::GenericDataReturnTypeHelper<T>::type

Alias template for determining the appropriate return type for the passed in type.

using SchemaVersionT = uint32_t

The type used for schema versions throughout.

using SupportedUserDataTypes = std::tuple<float, double, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t>

tuple of basic types supported in user vector

template<typename T>
using EnableIfSupportedUserType = std::enable_if_t<detail::isInTuple<T, SupportedUserDataTypes>>

Alias template to be used to enable template specializations only for the types listed in the SupportedUserDataTypes list.

Enums

enum class Backend

Values:

enumerator ROOT
enumerator SIO

Functions

template<typename FrameDataT>
std::optional<podio::CollectionReadBuffers> unpack(FrameDataT *data, const std::string &name)
inline std::string collMetadataParamName(const std::string &collName, const std::string &paramName)

Create a parameterName that encodes the collection name and the parameter Name into one string.

This codifies a convention that was decided on to store collection level parameters. These are parameters / metadata that are valid for all collections of a given name in a file, e.g. CellID encoding strings. These parameters are usually stored in a dedicated metadata Frame inside a file, see the predefined category names in the Category namespace.

Parameters:
  • collName – the name of the collection

  • paramName – the name of the parameter

Returns:

A single key string that combines the collection and parameter name

inline std::ostream &operator<<(std::ostream &os, const podio::ObjectID &id)
template<typename devT, typename PODData>
void handlePODDataSIO(devT &device, PODData *data, size_t size)
template<typename MapLikeT>
void writeMapLike(sio::write_device &device, const MapLikeT &map)

Write anything that iterates like an std::map.

template<typename MapLikeT>
void readMapLike(sio::read_device &device, MapLikeT &map)

Read anything that iterates like an std::map.

template<typename BasicType, typename = EnableIfSupportedUserType<BasicType>>
constexpr const char *userDataTypeName()

helper template to provide readable type names for basic types with macro PODIO_ADD_USER_TYPE(type)

template<typename BasicType, typename = EnableIfSupportedUserType<BasicType>>
constexpr const char *userDataCollTypeName()

Helper template to provide the fully qualified name of a UserDataCollection.

Implementations are populated by the PODIO_ADD_USER_TYPE macro.

template<typename BasicType, typename = EnableIfSupportedUserType<BasicType>>
std::ostream &operator<<(std::ostream &o, const podio::UserDataCollection<BasicType> &coll)

Variables

template<typename T>
static constexpr bool isSupportedGenericDataType = detail::isAnyOrVectorOf<T, SupportedGenericDataTypes>

Static bool for determining if a type T is a supported GenericParameters type.

template<typename T>
static constexpr bool isCollection = std::is_base_of_v<CollectionBase, T>

Alias template for checking whether a passed type T inherits from podio::CollectionBase.

class CollectionBase
#include <podio/CollectionBase.h>

Subclassed by podio::UserDataCollection< BasicType, typename >

Public Functions

CollectionBase(const CollectionBase&) = delete

No copy c’tor because collections are move-only.

CollectionBase &operator=(const CollectionBase&) = delete

No copy assignment because collections are move-only.

virtual void prepareForWrite() const = 0

prepare buffers for serialization

virtual void prepareAfterRead() = 0

re-create collection from buffers after read

virtual bool setReferences(const ICollectionProvider *collectionProvider) = 0

initialize references after read

virtual void setID(uint32_t id) = 0

set collection ID

virtual uint32_t getID() const = 0

get collection ID

virtual podio::CollectionWriteBuffers getBuffers() = 0

Get the collection buffers for this collection.

virtual bool isValid() const = 0

check for validity of the container after read

virtual size_t size() const = 0

number of elements in the collection

virtual bool empty() const = 0

Is the collection empty.

virtual const std::string_view getTypeName() const = 0

fully qualified type name

virtual const std::string_view getValueTypeName() const = 0

fully qualified type name of elements - with namespace

virtual const std::string_view getDataTypeName() const = 0

fully qualified type name of stored POD elements - with namespace

virtual SchemaVersionT getSchemaVersion() const = 0

schema version of the collection

virtual ~CollectionBase() = default

destructor

virtual void clear() = 0

clear the collection and all internal states

virtual bool isSubsetCollection() const = 0

check if this collection is a subset collection

virtual void setSubsetCollection(bool setSubset = true) = 0

declare this collection to be a subset collection

virtual void print(std::ostream &os = std::cout, bool flush = true) const = 0

print this collection to the passed stream

virtual size_t getDatamodelRegistryIndex() const = 0

Get the index in the DatatypeRegistry of the EDM this collection belongs to.

class CollectionBufferFactory
#include <podio/CollectionBufferFactory.h>

The CollectionBufferFactory allows to create buffers of known datatypes, which can then be populated by e.g.

readers. In order to support schema evolution, the buffers have a version and this factory will also require a schema version to create buffers.

It is implemented as a singleton, which is populated at the time a shared datamodel library is loaded. It is assumed that that happens early on in the startup of an application, such that only a single thread will access the factory instance for registering datatypes. Since the necessary creation functions are part of the core datamodel library, this should be very easy to achieve by simply linking to that library. Once the factory is populated it can be safely accessed from multiple threads concurrently to obtain buffers.

Public Functions

CollectionBufferFactory(CollectionBufferFactory const&) = delete

The buffer factory is a singleton so we disable all copy and move constructors explicitly.

CollectionBufferFactory &operator=(CollectionBufferFactory const&) = delete
CollectionBufferFactory(CollectionBufferFactory&&) = delete
CollectionBufferFactory &operator=(CollectionBufferFactory&&) = delete
~CollectionBufferFactory() = default
std::optional<podio::CollectionReadBuffers> createBuffers(const std::string &collType, SchemaVersionT version, bool subsetColl) const

Create buffers for a given collection type of a given schema version.

Parameters:
  • collType – The collection type name (e.g. from collection->getTypeName())

  • version – The schema version the created buffers should have

  • subsetColl – Should the buffers be for a subset collection or not

Returns:

CollectionReadBuffers if a creation function for this collection type has been registered, otherwise an empty optional

void registerCreationFunc(const std::string &collType, SchemaVersionT version, const CreationFuncT &creationFunc)

Register a creation function for a given collection type and schema version.

Parameters:
  • collType – The collection type name (i.e. what collection->getTypeName() returns)

  • version – The schema version for which this creation function is valid

  • creationFunc – The function that when invoked returns buffers for this collection type and schema version. The signature has to be podio::CollectionReadBuffers(bool) where the boolean parameter steers whether the buffers are for a subset collection or not.

Public Static Functions

static CollectionBufferFactory &mutInstance()

Mutable instance only used for the initial registration of functions during library loading.

static CollectionBufferFactory const &instance()

Get the factory instance.

class CollectionIDTable
#include <podio/CollectionIDTable.h>

Public Functions

CollectionIDTable()
~CollectionIDTable() = default
CollectionIDTable(const CollectionIDTable&) = delete
CollectionIDTable &operator=(const CollectionIDTable&) = delete
CollectionIDTable(CollectionIDTable&&) = default
CollectionIDTable &operator=(CollectionIDTable&&) = default
CollectionIDTable(std::vector<uint32_t> &&ids, std::vector<std::string> &&names)

constructor from existing ID:name mapping

CollectionIDTable(const std::vector<uint32_t> &ids, const std::vector<std::string> &names)
std::optional<uint32_t> collectionID(const std::string &name) const

return collection ID for given name

std::optional<const std::string> name(uint32_t collectionID) const

return name for given collection ID

bool present(const std::string &name) const

Check if collection name is known.

bool present(uint32_t collectionID) const

Check if collection ID is known.

inline const std::vector<std::string> &names() const

return registered names

inline const std::vector<uint32_t> &ids() const

return the ids

uint32_t add(const std::string &name)

register new name to the table returns assigned collection ID

void print() const

Prints collection information.

inline bool empty() const

Does this table hold any information?

struct CollectionReadBuffers
#include <podio/CollectionBuffers.h>

Public Types

using CreateFuncT = std::function<std::unique_ptr<podio::CollectionBase>(podio::CollectionReadBuffers, bool)>
using RecastFuncT = std::function<void(CollectionReadBuffers&)>
using DeleteFuncT = std::function<void(CollectionReadBuffers&)>

Public Functions

inline CollectionReadBuffers(void *d, CollRefCollection *ref, VectorMembersInfo *vec, SchemaVersionT version, std::string_view typ, CreateFuncT &&createFunc, RecastFuncT &&recastFunc, DeleteFuncT &&deleteFunc)
CollectionReadBuffers() = default
CollectionReadBuffers(const CollectionReadBuffers&) = default
CollectionReadBuffers &operator=(const CollectionReadBuffers&) = default
inline CollectionReadBuffers(CollectionWriteBuffers buffers)
template<typename DataT>
inline std::vector<DataT> *dataAsVector()

Public Members

void *data = {nullptr}
CollRefCollection *references = {nullptr}
VectorMembersInfo *vectorMembers = {nullptr}
SchemaVersionT schemaVersion = {0}
std::string_view type = {}
CreateFuncT createCollection = {}
RecastFuncT recast = {}
DeleteFuncT deleteBuffers = {}

Public Static Functions

template<typename T>
static inline std::vector<T> *asVector(void *raw)
struct CollectionWriteBuffers
#include <podio/CollectionBuffers.h>

Simple helper struct that bundles all the potentially necessary buffers that are necessary to represent a collection for I/O purposes.

Public Functions

template<typename DataT>
inline std::vector<DataT> *dataAsVector()

Public Members

void *data = {nullptr}
void *vecPtr = {nullptr}
CollRefCollection *references = {nullptr}
VectorMembersInfo *vectorMembers = {nullptr}

Public Static Functions

template<typename T>
static inline std::vector<T> *asVector(void *raw)
class DatamodelDefinitionCollector
#include <podio/utilities/DatamodelRegistryIOHelpers.h>

Helper class to collect the datamodel (JSON) definitions that should be written.

Public Functions

void registerDatamodelDefinition(const podio::CollectionBase *coll, const std::string &name)

Register the datamodel definition of the EDM this collection is from to be written.

Parameters:
  • coll – A collection of an EDM

  • name – The name under which this collection is stored on file

std::vector<std::tuple<std::string, std::string>> getDatamodelDefinitionsToWrite() const

Get all the names and JSON definitions that need to be written.

class DatamodelDefinitionHolder
#include <podio/utilities/DatamodelRegistryIOHelpers.h>

Helper class to hold and provide the datamodel (JSON) definitions for reader classes.

Public Types

using MapType = std::vector<std::tuple<std::string, std::string>>

The “map” type that is used internally.

Public Functions

inline DatamodelDefinitionHolder(MapType &&definitions)

Constructor from an existing collection of names and datamodel definitions.

DatamodelDefinitionHolder() = default
~DatamodelDefinitionHolder() = default
DatamodelDefinitionHolder(const DatamodelDefinitionHolder&) = delete
DatamodelDefinitionHolder &operator=(const DatamodelDefinitionHolder&) = delete
DatamodelDefinitionHolder(DatamodelDefinitionHolder&&) = default
DatamodelDefinitionHolder &operator=(DatamodelDefinitionHolder&&) = default
const std::string_view getDatamodelDefinition(const std::string &name) const

Get the datamodel definition for the given datamodel name.

Returns an empty model definition if no model is stored under the given name.

Parameters:

name – The name of the datamodel

std::vector<std::string> getAvailableDatamodels() const

Get all names of the datamodels that have been read from file.

class DatamodelRegistry
#include <podio/DatamodelRegistry.h>

Global registry holding information about datamodels and datatypes defined therein that are currently known by podio (i.e.

which have been dynamically loaded).

This is a singleton which is (statically) populated during dynamic loading of generated EDMs. In this context an EDM refers to the shared library that is compiled from the generated code from a datamodel definition in YAML format. When we refer to a datamodel in this context we talk about the entity as a whole, i.e. its definition in a YAML file, but also the concrete implementation as an EDM, as well as all other information that is related to it. In the API of this registry this will be used, unless we want to highlight that we are referring to a specific part of a datamodel.

Public Functions

~DatamodelRegistry() = default
DatamodelRegistry(const DatamodelRegistry&) = delete
DatamodelRegistry &operator=(const DatamodelRegistry&) = delete
DatamodelRegistry(DatamodelRegistry&&) = delete
DatamodelRegistry &operator=(const DatamodelRegistry&&) = delete
const std::string_view getDatamodelDefinition(std::string_view name) const

Get the definition (in JSON format) of the datamodel with the given edmName.

If no datamodel with the given name can be found, an empty datamodel definition, i.e. an empty JSON object (“{}”), is returned.

Parameters:

name – The name of the datamodel

const std::string_view getDatamodelDefinition(size_t index) const

Get the defintion (in JSON format) of the datamodel wth the given index.

If no datamodel is found under the given index, an empty datamodel definition, i.e. an empty JSON object (“{}”), is returned.

Parameters:

index – The datamodel definition index that can be obtained from each collection

const std::string &getDatamodelName(size_t index) const

Get the name of the datamodel that is stored under the given index.

If no datamodel is found under the given index, an empty string is returned

Parameters:

index – The datamodel definition index that can be obtained from each collection

size_t registerDatamodel(std::string name, std::string_view definition, const podio::RelationNameMapping &relationNames)

Register a datamodel return the index in the registry.

This is the hook that is called during dynamic loading of an EDM to register information for this EDM. If an EDM has already been registered under this name, than the index to the existing EDM in the registry will be returned.

Parameters:
  • name – The name of the EDM that should be registered

  • definition – The datamodel definition from which this EDM has been generated in JSON format

  • relationNames – the names of the relations and vector members for all datatypes that are defined for this EDM

RelationNames getRelationNames(std::string_view typeName) const

Get the names of the relations and vector members of a datatype.

Public Static Functions

static const DatamodelRegistry &instance()

Get the registry.

static DatamodelRegistry &mutInstance()

Public Static Attributes

static constexpr size_t NoDefinitionNecessary = -1

Dedicated index value for collections that don’t have a datamodel definition (e.g.

UserDataCollection)

static constexpr size_t NoDefinitionAvailable = -2

Dedicated index value for error checking, used to default init the generated RegistryIndex.

class Frame
#include <podio/Frame.h>

Frame class that serves as a container of collection and meta data.

Public Functions

inline Frame()

Empty Frame constructor.

template<typename FrameDataT>
Frame(std::unique_ptr<FrameDataT>)

Frame constructor from (almost) arbitrary raw data.

template<typename FrameDataT, typename = EnableIfRValue<FrameDataT>>
Frame(FrameDataT&&)

Frame constructor from (almost) arbitrary raw data.

This r-value overload is mainly present for enabling the python bindings, where cppyy seems to strip the std::unique_ptr somewhere in the process

Frame(const Frame&) = delete
Frame &operator=(const Frame&) = delete
Frame(Frame&&) = default
Frame &operator=(Frame&&) = default
~Frame() = default

Frame destructor.

template<typename CollT, typename = EnableIfCollection<CollT>>
const CollT &get(const std::string &name) const

Get a collection from the Frame.

inline const podio::CollectionBase *get(const std::string &name) const

Get a collection from the Frame.

This is the pointer-to-base version for type-erased access (e.g. python interface)

template<typename CollT, typename = EnableIfCollectionRValue<CollT>>
const CollT &put(CollT &&coll, const std::string &name)

(Destructively) move a collection into the Frame and get a const reference back for further use

inline void put(std::unique_ptr<podio::CollectionBase> coll, const std::string &name)

Move a collection into the Frame handing over ownership to the Frame.

template<typename T, typename = podio::EnableIfValidGenericDataType<T>>
inline void putParameter(const std::string &key, T value)

Add a value to the parameters of the Frame (if the type is supported).

Copy the value into the internal store

inline void putParameter(const std::string &key, std::string value)

Add a string value to the parameters of the Frame by copying it.

Dedicated overload for enabling the on-the-fly conversion on the string literals.

inline void putParameter(const std::string &key, std::vector<std::string> values)

Add a vector of strings to the parameters of the Frame (via copy).

Dedicated overload for enabling on-the-fly conversions of initializer_list of string literals.

template<typename T, typename = std::enable_if_t<detail::isInTuple<T, SupportedGenericDataTypes>>>
inline void putParameter(const std::string &key, std::initializer_list<T> &&values)

Add a vector of values into the parameters of the Frame.

Overload for catching on-the-fly conversions of initializer_lists of values.

template<typename T, typename = podio::EnableIfValidGenericDataType<T>>
inline podio::GenericDataReturnType<T> getParameter(const std::string &key) const

Retrieve parameters via key from the internal store.

Return type will either by a const reference or a value depending on the desired type.

inline const podio::GenericParameters &getParameters() const

Get all parameters that are stored in this Frame.

template<typename T, typename = podio::EnableIfValidGenericDataType<T>>
inline std::vector<std::string> getParameterKeys() const

Get the keys of all stored parameters for a given type.

inline std::vector<std::string> getAvailableCollections() const

Get all currently available collections (including potentially unpacked ones from raw data)

inline const podio::GenericParameters &getGenericParametersForWrite() const

Get the GenericParameters for writing.

inline const podio::CollectionBase *getCollectionForWrite(const std::string &name) const

Get a collection for writing (in a prepared and “ready-to-write” state)

inline podio::CollectionIDTable getCollectionIDTableForWrite() const
class GenericParameters
#include <podio/GenericParameters.h>

GenericParameters objects allow to store generic named parameters of type int, float and string or vectors of these types.

They can be used to store (user) meta data that is run, event or collection dependent. (based on lcio::LCParameters)

Author

F. Gaede, DESY

Date

Apr 2020

Public Types

template<typename T>
using MapType = std::map<std::string, std::vector<T>>

Public Functions

GenericParameters()
GenericParameters(const GenericParameters&)

GenericParameters are copyable NOTE: This is currently mainly done to keep the ROOT I/O happy, because that needs a copy constructor.

GenericParameters &operator=(const GenericParameters&) = delete
GenericParameters(GenericParameters&&) = default

GenericParameters are default moveable.

GenericParameters &operator=(GenericParameters&&) = default
~GenericParameters() = default
template<typename T, typename = EnableIfValidGenericDataType<T>>
GenericDataReturnType<T> getValue(const std::string&) const

Get the value that is stored under the given key, by const reference or by value depending on the desired type.

template<typename T, typename = EnableIfValidGenericDataType<T>>
void setValue(const std::string &key, T value)

Store (a copy of) the passed value under the given key.

inline void setValue(const std::string &key, std::string value)

Overload for catching const char* setting for string values.

inline void setValue(const std::string &key, std::vector<std::string> values)

Overload for catching initializer list setting of string vector values.

template<typename T, typename = std::enable_if_t<detail::isInTuple<T, SupportedGenericDataTypes>>>
inline void setValue(const std::string &key, std::initializer_list<T> &&values)

Overload for catching initializer list setting for vector values.

template<typename T, typename = EnableIfValidGenericDataType<T>>
size_t getN(const std::string &key) const

Get the number of elements stored under the given key for a type.

template<typename T, typename = EnableIfValidGenericDataType<T>>
std::vector<std::string> getKeys() const

Get all available keys for a given type.

inline void clear()

erase all elements

void print(std::ostream &os = std::cout, bool flush = true)
inline bool empty() const

Check if no parameter is stored (i.e. if all internal maps are empty)

template<typename T>
inline const MapType<detail::GetVectorType<T>> &getMap() const

Get a reference to the internal map for a given type.

Friends

friend void writeGenericParameters(sio::write_device &device, const GenericParameters &parameters)
friend void readGenericParameters(sio::read_device &device, GenericParameters &parameters, sio::version_type version)
class ICollectionProvider
#include <podio/ICollectionProvider.h>

Public Functions

virtual ~ICollectionProvider() = default

destructor

virtual bool get(uint32_t collectionID, CollectionBase *&collection) const = 0

access a collection by ID. returns true if successful

class ObjectID
#include <podio/ObjectID.h>

Public Functions

inline bool operator==(const ObjectID &other) const

index and collectionID uniquely defines the object.

this operator is necessary for meaningful comparisons in python

inline bool operator!=(const ObjectID &other) const

Public Members

int index = {untracked}

index of object in collection

uint32_t collectionID = {static_cast<uint32_t>(untracked)}

ID of the collection.

Public Static Attributes

static const int untracked = -1

not part of a collection

static const int invalid = -2

invalid or non-available object

struct RelationNames
#include <podio/DatamodelRegistry.h>

Information on the names of the OneTo[One|Many]Relations as well as the VectorMembers of a datatype.

The contents are populated by the code generation, where we simply generate static vectors that we make available as const& here.

Public Members

const std::vector<std::string_view> &relations

The names of the relations (OneToMany before OneToOne)

const std::vector<std::string_view> &vectorMembers

The names of the vector members.

template<typename ReferenceType>
class RelationRange
#include <podio/RelationRange.h>

A simple helper class that allows to return related objects in a way that makes it possible to use the return type in a range-based for loop.

Public Types

using ConstIteratorType = typename std::vector<ReferenceType>::const_iterator

Public Functions

RelationRange() = delete
inline RelationRange(ConstIteratorType begin, ConstIteratorType end)
inline ConstIteratorType begin() const

begin of the range (necessary for range-based for loop)

inline ConstIteratorType end() const

end of the range (necessary for range-based for loop)

inline size_t size() const

convenience overload for size

inline bool empty() const

convenience overload to check if the range is empty

inline ReferenceType operator[](size_t i) const

Indexed access.

inline ReferenceType at(size_t i) const

Indexed access with range check.

class ROOTFrameData
#include <podio/ROOTFrameData.h>

Public Types

using BufferMap = std::unordered_map<std::string, podio::CollectionReadBuffers>

Public Functions

ROOTFrameData() = delete
inline ~ROOTFrameData()
ROOTFrameData(ROOTFrameData&&) = default
ROOTFrameData &operator=(ROOTFrameData&&) = default
ROOTFrameData(const ROOTFrameData&) = delete
ROOTFrameData &operator=(const ROOTFrameData&) = delete
inline ROOTFrameData(BufferMap &&buffers, CollIDPtr &&idTable, podio::GenericParameters &&params)
inline std::optional<podio::CollectionReadBuffers> getCollectionBuffers(const std::string &name)
inline podio::CollectionIDTable getIDTable() const
inline std::unique_ptr<podio::GenericParameters> getParameters()
inline std::vector<std::string> getAvailableCollections() const
class ROOTFrameReader
#include <podio/ROOTFrameReader.h>

This class has the function to read available data from disk and to prepare collections and buffers.

Public Functions

ROOTFrameReader() = default
~ROOTFrameReader() = default
ROOTFrameReader(const ROOTFrameReader&) = delete
ROOTFrameReader &operator=(const ROOTFrameReader&) = delete
void openFile(const std::string &filename)

Open a single file for reading.

Parameters:

filename – The name of the input file

void openFiles(const std::vector<std::string> &filenames)

Open multiple files for reading and then treat them as if they are one file.

NOTE: All of the files are assumed to have the same structure. Specifically this means:

  • The same categories are available from all files

  • The collections that are contained in the individual categories are the same across all files

This usually boils down to “the files have been written with the same

settings”, e.g. they are outputs of a batched process.

Parameters:

filenames – The filenames of all input files that should be read

std::unique_ptr<podio::ROOTFrameData> readNextEntry(const std::string &name)

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::ROOTFrameData> readEntry(const std::string &name, const unsigned entry)

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.

unsigned getEntries(const std::string &name) const

Returns number of entries for the given name.

inline podio::version::Version currentFileVersion() const

Get the build version of podio that has been used to write the current file.

std::vector<std::string_view> getAvailableCategories() const

Get the names of all the available Frame categories in the current file(s)

inline const std::string_view getDatamodelDefinition(const std::string &name) const

Get the datamodel definition for the given name.

inline std::vector<std::string> getAvailableDatamodels() const

Get all names of the datamodels that ara available from this reader.

class ROOTFrameWriter
#include <podio/ROOTFrameWriter.h>

Public Functions

ROOTFrameWriter(const std::string &filename)
~ROOTFrameWriter()
ROOTFrameWriter(const ROOTFrameWriter&) = delete
ROOTFrameWriter &operator=(const ROOTFrameWriter&) = delete
void writeFrame(const podio::Frame &frame, const std::string &category)

Store the given frame with the given category.

Store all available collections from the Frame.

NOTE: The contents of the first Frame that is written in this way determines the contents that will be written for all subsequent Frames.

void writeFrame(const podio::Frame &frame, const std::string &category, const std::vector<std::string> &collsToWrite)

Store the given Frame with the given category.

Store only the collections that are passed.

NOTE: The contents of the first Frame that is written in this way determines the contents that will be written for all subsequent Frames.

void finish()

Write the current file, including all the necessary metadata to read it again.

std::tuple<std::vector<std::string>, std::vector<std::string>> checkConsistency(const std::vector<std::string> &collsToWrite, const std::string &category) const

Check whether the collsToWrite are consistent with the state of the passed category.

Return two vectors of collection names. The first one contains all the names that were missing from the collsToWrite but were present in the category. The second one contains the names that are present in the collsToWrite only. If both vectors are empty the category and the passed collsToWrite are consistent.

NOTE: This will only be a meaningful check if the first Frame of the passed category has already been written. Also, this check is rather expensive as it has to effectively do two set differences.

class ROOTLegacyReader
#include <podio/ROOTLegacyReader.h>

A root reader for reading legacy podio root files that have been written using the legacy, non Frame based I/O model.

This reader grants Frame based access to those files, by mimicking the Frame I/O functionality and the interfaces of those readers.

NOTE: Since there was only one category (“events”) for those legacy podio files this reader will really only work if you try to read that category, and will simply return no data if you try to read anything else.

Public Functions

ROOTLegacyReader() = default
~ROOTLegacyReader() = default
ROOTLegacyReader(const ROOTLegacyReader&) = delete
ROOTLegacyReader &operator=(const ROOTLegacyReader&) = delete
void openFile(const std::string &filename)
void openFiles(const std::vector<std::string> &filenames)
std::unique_ptr<podio::ROOTFrameData> readNextEntry(const std::string&)

Read the next data entry from which a Frame can be constructed.

In case there are no more entries left, this returns a nullptr.

NOTE: the category name has to be “events” in this case, as only that category is available for legacy files.

std::unique_ptr<podio::ROOTFrameData> readEntry(const std::string&, const unsigned entry)

Read the specified data entry from which a Frame can be constructed In case the entry does not exist, this returns a nullptr.

NOTE: the category name has to be “events” in this case, as only that category is available for legacy files.

unsigned getEntries(const std::string&) const

Returns number of entries for a given category.

inline podio::version::Version currentFileVersion() const

Get the build version of podio that has been used to write the current file.

std::vector<std::string_view> getAvailableCategories() const

Get the names of all the available Frame categories in the current file(s)

class ROOTNTupleReader
#include <podio/ROOTNTupleReader.h>

This class has the function to read available data from disk and to prepare collections and buffers.

Public Functions

ROOTNTupleReader() = default
~ROOTNTupleReader() = default
ROOTNTupleReader(const ROOTNTupleReader&) = delete
ROOTNTupleReader &operator=(const ROOTNTupleReader&) = delete
void openFile(const std::string &filename)
void openFiles(const std::vector<std::string> &filename)
std::unique_ptr<podio::ROOTFrameData> readNextEntry(const std::string &name)

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::ROOTFrameData> readEntry(const std::string &name, const unsigned entry)

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::vector<std::string_view> getAvailableCategories() const

Get the names of all the available Frame categories in the current file(s)

unsigned getEntries(const std::string &name)

Returns number of entries for the given name.

inline podio::version::Version currentFileVersion() const

Get the build version of podio that has been used to write the current file.

inline const std::string_view getDatamodelDefinition(const std::string &name) const

Get the datamodel definition for the given name.

inline std::vector<std::string> getAvailableDatamodels() const

Get all names of the datamodels that ara available from this reader.

void closeFile()
class ROOTNTupleWriter
#include <podio/ROOTNTupleWriter.h>

Public Functions

ROOTNTupleWriter(const std::string &filename)
~ROOTNTupleWriter()
ROOTNTupleWriter(const ROOTNTupleWriter&) = delete
ROOTNTupleWriter &operator=(const ROOTNTupleWriter&) = delete
template<typename T>
void fillParams(GenericParameters &params, ROOT::Experimental::REntry *entry)
void writeFrame(const podio::Frame &frame, const std::string &category)
void writeFrame(const podio::Frame &frame, const std::string &category, const std::vector<std::string> &collsToWrite)
void finish()
std::tuple<std::vector<std::string>, std::vector<std::string>> checkConsistency(const std::vector<std::string> &collsToWrite, const std::string &category) const

Check whether the collsToWrite are consistent with the state of the passed category.

Return two vectors of collection names. The first one contains all the names that were missing from the collsToWrite but were present in the category. The second one contains the names that are present in the collsToWrite only. If both vectors are empty the category and the passed collsToWrite are consistent.

NOTE: This will only be a meaningful check if the first Frame of the passed category has already been written. Also, this check is rather expensive as it has to effectively do two set differences.

class SchemaEvolution
#include <podio/SchemaEvolution.h>

The SchemaEvolution holds evolution functions that allow to transform CollectionReadBuffers of known datatypes from a previous schema version to the current schema version.

From the evolved buffers it is then possible to create collections.

It is implemented as a singleton that is populated at the time shared datamodel libraries (or their schema evolution libraries) are loaded. It is assumed that this happens early on in the startup of any application, such that the registration still happens on a single thread. After this initialization evolutions can be done from multiple threads.

Public Types

enum class Priority

Enum to make it possible to prioritize evolution functions during registration, making AutoGenerated lower priority than UserDefined.

Values:

enumerator AutoGenerated
enumerator UserDefined

Public Functions

SchemaEvolution(const SchemaEvolution&) = delete

The SchemaEvolution is a singleton so we disable all copy and move constructors explicitly.

SchemaEvolution &operator=(const SchemaEvolution&) = delete
SchemaEvolution(SchemaEvolution&&) = delete
SchemaEvolution &operator=(SchemaEvolution&&) = delete
~SchemaEvolution() = default
podio::CollectionReadBuffers evolveBuffers(const podio::CollectionReadBuffers &oldBuffers, SchemaVersionT fromVersion, const std::string &collType) const

Evolve the passed in buffers to the current version of the datatype that can be constructed from them.

Internally this will first check if the schema version of the buffers is already the current one and in that case immediately return the passed in buffers again as they do not need schema evolution. If that is not the case it will look up the correct evolution function for the passed in version and call that on the passed in buffers.

Parameters:
  • oldBuffers – The buffers to be evolved

  • fromVersion – The schema version of the buffers

  • collType – The fully qualified collection type

Returns:

CollectionReadBuffers that have been evolved to the current version. NOTE that these could also be the input buffers.

void registerEvolutionFunc(const std::string &collType, SchemaVersionT fromVersion, SchemaVersionT currentVersion, const EvolutionFuncT &evolutionFunc, Priority priority = Priority::UserDefined)

Register an evolution function for a given collection type and given versions from where to where the evolution applies.

Several assumptions are in place here:

  • The current version has to be the same for all invocations for a given datatype.

  • An evolution function has to be registered for all possible versions from 1 to N - 1, where N is the current version

  • An evolution function can only be registered once for a given datatype and fromVersion

  • For auto generated code the passed in priority has to be AutoGenerated otherwise it might override user defined functions

  • Even if a datatype does not require schema evolution it has to register an evolution function (e.g. the noOpSchemaEvolution below) in order to be known to the internal map.

Parameters:
  • collType – The fully qualified collection data type

  • fromVersion – The version from which this evolution function should apply

  • currentVersion – The current schema version for the data type

  • evolutionFunc – The evolution function that evolves passed in buffers from fromVersion to currentVersion

  • priority – The priority of this evolution function. Defaults to UserDefined which overrides auto generated functionality.

Public Static Functions

static SchemaEvolution &mutInstance()

Mutable instance only used for the initial registration of functions during library loading.

static SchemaEvolution const &instance()

Get the instance for evolving buffers.

static podio::CollectionReadBuffers noOpSchemaEvolution(podio::CollectionReadBuffers &&buffers, SchemaVersionT)

A no-op schema evolution function that returns the buffers unchanged.

This can be used for registering an evolution function for datatypes that do not require schema evolution, but need to register themselves with SchemaEvolution

class SIOBlock : public sio::block
#include <podio/SIOBlock.h>

Base class for sio::block handlers used with PODIO.

Subclassed by podio::SIOBlockUserData< BasicType, typename >

Public Functions

inline SIOBlock(const std::string &nam, sio::version_type vers)
SIOBlock() = delete
SIOBlock(const SIOBlock&) = delete
SIOBlock &operator=(const SIOBlock&) = delete
inline podio::CollectionBase *getCollection()
inline podio::CollectionReadBuffers getBuffers() const
inline std::string name()
inline void setSubsetCollection(bool subsetColl)
inline void setCollection(podio::CollectionBase *col)
virtual SIOBlock *create(const std::string &name) const = 0
class SIOBlockFactory
#include <podio/SIOBlock.h>

factory for creating sio::blocks for a given type of EDM-collection

Public Functions

inline void registerBlockForCollection(const std::string &type, SIOBlock *b)
std::shared_ptr<SIOBlock> createBlock(const podio::CollectionBase *col, const std::string &name) const
std::shared_ptr<SIOBlock> createBlock(const std::string &typeStr, const std::string &name, const bool isRefColl = false) const

Public Static Functions

static inline SIOBlockFactory &instance()
class SIOBlockLibraryLoader
#include <podio/SIOBlock.h>

Public Static Functions

static inline SIOBlockLibraryLoader &instance()
template<typename BasicType, typename = EnableIfSupportedUserType<BasicType>>
class SIOBlockUserData : public podio::SIOBlock
#include <podio/SIOBlockUserData.h>

Public Functions

inline SIOBlockUserData()
inline SIOBlockUserData(const std::string &name)
inline void read(sio::read_device &device, sio::version_type version) override
inline void write(sio::write_device &device) override
inline virtual SIOBlock *create(const std::string &name) const override
class SIOCollectionIDTableBlock : public sio::block
#include <podio/SIOBlock.h>

A dedicated block for handling the I/O of the CollectionIDTable.

Public Functions

inline SIOCollectionIDTableBlock()
inline SIOCollectionIDTableBlock(std::vector<std::string> &&names, std::vector<uint32_t> &&ids, std::vector<std::string> &&types, std::vector<short> &&isSubsetColl)
SIOCollectionIDTableBlock(const SIOCollectionIDTableBlock&) = delete
SIOCollectionIDTableBlock &operator=(const SIOCollectionIDTableBlock&) = delete
void read(sio::read_device &device, sio::version_type version) override
void write(sio::write_device &device) override
inline podio::CollectionIDTable getTable()
inline const std::vector<std::string> &getTypeNames() const
inline const std::vector<short> &getSubsetCollectionBits() const
class SIOEventMetaDataBlock : public sio::block
#include <podio/SIOBlock.h>

A block for handling the EventMeta data.

Public Functions

inline SIOEventMetaDataBlock()
SIOEventMetaDataBlock(const SIOEventMetaDataBlock&) = delete
SIOEventMetaDataBlock &operator=(const SIOEventMetaDataBlock&) = delete
void read(sio::read_device &device, sio::version_type version) override
void write(sio::write_device &device) override

Public Members

podio::GenericParameters *metadata = {nullptr}
class SIOFileTOCRecord
#include <podio/SIOBlock.h>

Public Types

using PositionType = sio_helpers::position_type

Public Functions

void addRecord(const std::string &name, PositionType startPos)
size_t getNRecords(const std::string &name) const
PositionType getPosition(const std::string &name, unsigned iEntry = 0) const

Get the position of the iEntry-th record with the given name.

If no entry with the given name is recorded, return 0. Note there is no internal check on whether the given name actually has iEntry records. Use getNRecords to check for that if necessary.

std::vector<std::string_view> getRecordNames() const

Get all the record names that are stored in this TOC record.

struct SIOFileTOCRecordBlock : public sio::block
#include <podio/SIOBlock.h>

Public Functions

inline SIOFileTOCRecordBlock()
inline SIOFileTOCRecordBlock(SIOFileTOCRecord *r)
SIOFileTOCRecordBlock(const SIOFileTOCRecordBlock&) = delete
SIOFileTOCRecordBlock &operator=(const SIOFileTOCRecordBlock&) = delete
void read(sio::read_device &device, sio::version_type version) override
void write(sio::write_device &device) override

Public Members

SIOFileTOCRecord *record = {nullptr}
class SIOFrameData
#include <podio/SIOFrameData.h>

The Frame data container for the SIO backend.

It is constructed from the compressed sio::buffers that is read from file and does all the necessary unpacking and decompressing internally after construction.

Public Functions

SIOFrameData() = delete
~SIOFrameData() = default
SIOFrameData(const SIOFrameData&) = delete
SIOFrameData &operator=(const SIOFrameData&) = delete
SIOFrameData(SIOFrameData&&) = default
SIOFrameData &operator=(SIOFrameData&&) = default
inline SIOFrameData(sio::buffer &&collBuffers, std::size_t dataSize, sio::buffer &&tableBuffer, std::size_t tableSize)

Constructor from the collBuffers containing the collection data and a tableBuffer containing the necessary information for unpacking the collections.

The two size parameters denote the uncompressed size of the respective buffers.

std::optional<podio::CollectionReadBuffers> getCollectionBuffers(const std::string &name)
inline podio::CollectionIDTable getIDTable()
std::unique_ptr<podio::GenericParameters> getParameters()
std::vector<std::string> getAvailableCollections()
class SIOFrameReader
#include <podio/SIOFrameReader.h>

Public Functions

SIOFrameReader()
~SIOFrameReader() = default
SIOFrameReader(const SIOFrameReader&) = delete
SIOFrameReader &operator=(const SIOFrameReader&) = delete
std::unique_ptr<podio::SIOFrameData> readNextEntry(const std::string &name)

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> readEntry(const std::string &name, const unsigned entry)

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.

unsigned getEntries(const std::string &name) const

Returns number of entries for the given name.

void openFile(const std::string &filename)
inline podio::version::Version currentFileVersion() const

Get the build version of podio that has been used to write the current file.

std::vector<std::string_view> getAvailableCategories() const

Get the names of all the available Frame categories in the current file(s)

inline const std::string_view getDatamodelDefinition(const std::string &name) const

Get the datamodel definition for the given name.

inline std::vector<std::string> getAvailableDatamodels() const

Get all names of the datamodels that ara available from this reader.

class SIOFrameWriter
#include <podio/SIOFrameWriter.h>

Public Functions

SIOFrameWriter(const std::string &filename)
~SIOFrameWriter()
SIOFrameWriter(const SIOFrameWriter&) = delete
SIOFrameWriter &operator=(const SIOFrameWriter&) = delete
void writeFrame(const podio::Frame &frame, const std::string &category)

Write the given Frame with the given category.

void writeFrame(const podio::Frame &frame, const std::string &category, const std::vector<std::string> &collsToWrite)

Write the given Frame with the given category only storing the collections that are desired via collsToWrite.

void finish()
class SIOLegacyReader
#include <podio/SIOLegacyReader.h>

A SIO reader for reading legacy podio .sio files that have been written using the legacy, non Frame based I/O model.

This reader grants Frame based access to those files, by mimicking Frame I/O functionality and the interfaces of those readers.

NOTE: Since there was only one category (“events”) for those legacy podio files this reader will really only work if you try to read that category, and will simply return no data if you try to read anything else.

Public Functions

SIOLegacyReader()
~SIOLegacyReader() = default
SIOLegacyReader(const SIOLegacyReader&) = delete
SIOLegacyReader &operator=(const SIOLegacyReader&) = delete
std::unique_ptr<podio::SIOFrameData> readNextEntry(const std::string&)

Read the next data entry from which a Frame can be constructed.

In case there are no more entries left, this returns a nullptr.

NOTE: the category name has to be “events” in this case, as only that category is available for legacy files.

std::unique_ptr<podio::SIOFrameData> readEntry(const std::string&, const unsigned entry)

Read the specified data entry from which a Frame can be constructed In case the entry does not exist, this returns a nullptr.

NOTE: the category name has to be “events” in this case, as only that category is available for legacy files.

unsigned getEntries(const std::string &name) const

Returns the number of.

void openFile(const std::string &filename)
inline podio::version::Version currentFileVersion() const

Get the build version of podio that has been used to write the current file.

std::vector<std::string_view> getAvailableCategories() const

Get the names of all the available Frame categories in the current file(s)

template<typename KeyT, typename ValueT>
struct SIOMapBlock : public sio::block
#include <podio/SIOBlock.h>

A block to serialize anything that behaves similar in iterating as a map<KeyT, ValueT>, e.g.

vector<tuple<KeyT, ValueT>>, which is what is used internally to represent the data to be written.

Public Functions

inline SIOMapBlock()
inline SIOMapBlock(std::vector<std::tuple<KeyT, ValueT>> &&data)
SIOMapBlock(const SIOMapBlock&) = delete
SIOMapBlock &operator=(const SIOMapBlock&) = delete
inline void read(sio::read_device &device, sio::version_type) override
inline void write(sio::write_device &device) override

Public Members

std::vector<std::tuple<KeyT, ValueT>> mapData = {}
class SIONumberedMetaDataBlock : public sio::block
#include <podio/SIOBlock.h>

A block for handling the run and collection meta data.

Public Functions

inline SIONumberedMetaDataBlock(const std::string &name)
SIONumberedMetaDataBlock(const SIONumberedMetaDataBlock&) = delete
SIONumberedMetaDataBlock &operator=(const SIONumberedMetaDataBlock&) = delete
void read(sio::read_device &device, sio::version_type version) override
void write(sio::write_device &device) override

Public Members

std::map<int, GenericParameters> *data = {nullptr}
struct SIOVersionBlock : public sio::block
#include <podio/SIOBlock.h>

Public Functions

inline SIOVersionBlock()
inline SIOVersionBlock(podio::version::Version v)
inline void write(sio::write_device &device) override
inline void read(sio::read_device &device, sio::version_type) override

Public Members

podio::version::Version version = {}
template<typename BasicType, typename = EnableIfSupportedUserType<BasicType>>
class UserDataCollection : public podio::CollectionBase
#include <podio/UserDataCollection.h>

Collection of basic types for additional user data not defined in the EDM.

The data is stored in an std::vector<basic_type>. Supported are all basic types supported in PODIO, i.e. float, double and 8-64 bit fixed size signed and unsigned integers -

See also

SupportedUserDataTypes.

Author

F.Gaede, DESY

Date

Sep 2021

Public Functions

UserDataCollection() = default
inline UserDataCollection(std::vector<BasicType> &&vec)

Constructor from an existing vector (which will be moved from!)

UserDataCollection(const UserDataCollection&) = delete
UserDataCollection &operator=(const UserDataCollection&) = delete
UserDataCollection(UserDataCollection&&) = default
UserDataCollection &operator=(UserDataCollection&&) = default
~UserDataCollection() = default
inline virtual void prepareForWrite() const override

prepare buffers for serialization

inline virtual void prepareAfterRead() override

re-create collection from buffers after read

inline virtual bool setReferences(const ICollectionProvider*) override

initialize references after read

inline virtual void setID(uint32_t id) override

set collection ID

inline virtual uint32_t getID() const override

get collection ID

inline virtual podio::CollectionWriteBuffers getBuffers() override

Get the collection buffers for this collection.

inline virtual bool isValid() const override

check for validity of the container after read

inline virtual size_t size() const override

number of elements in the collection

inline virtual bool empty() const override

Is the collection empty.

inline virtual const std::string_view getTypeName() const override

fully qualified type name

inline virtual const std::string_view getValueTypeName() const override

fully qualified type name of elements - with namespace

inline virtual const std::string_view getDataTypeName() const override

fully qualified type name of stored POD elements - with namespace

inline virtual void clear() override

clear the collection and all internal states

inline virtual bool isSubsetCollection() const override

check if this collection is a subset collection - no subset possible

inline virtual void setSubsetCollection(bool) override

declare this collection to be a subset collection - no effect

inline virtual SchemaVersionT getSchemaVersion() const final

The schema version is fixed manually.

inline virtual void print(std::ostream &os = std::cout, bool flush = true) const override

Print this collection to the passed stream.

inline virtual size_t getDatamodelRegistryIndex() const override

Get the index in the DatatypeRegistry of the EDM this collection belongs to.

inline std::vector<BasicType>::iterator begin()
inline std::vector<BasicType>::iterator end()
inline std::vector<BasicType>::const_iterator begin() const
inline std::vector<BasicType>::const_iterator end() const
inline std::vector<BasicType>::reference operator[](size_t idx)
inline std::vector<BasicType>::const_reference operator[](size_t idx) const
inline void resize(size_t count)
inline void push_back(const BasicType &value)
inline std::vector<BasicType> &vec()

access to the actual data vector

inline const std::vector<BasicType> &vec() const

const access to the actual data vector

Public Static Attributes

static constexpr SchemaVersionT schemaVersion = 1

The schema version of UserDataCollections.

static constexpr auto typeName = userDataCollTypeName<BasicType>()
static constexpr auto valueTypeName = userDataTypeName<BasicType>()
static constexpr auto dataTypeName = userDataTypeName<BasicType>()
namespace Category

This namespace mimics an enum (at least in its usage) and simply defines either commonly used category names, or category names that form a convention.

Variables

constexpr const auto Event = "events"

The event category.

constexpr const auto Run = "runs"

The run category.

constexpr const auto Metadata = "metadata"

The metadata category that is used to store a single Frame that holds data that is valid for a whole file, e.g.

collection level parameters

namespace root_utils
struct CollectionBranches
#include <podio/CollectionBranches.h>

Small helper struct to collect all branches that are necessary to read or write a collection.

Needed to cache the branch pointers and avoid having to get them from a TTree/TChain for every event.

Public Members

TBranch *data = {nullptr}
std::vector<TBranch*> refs = {}
std::vector<TBranch*> vecs = {}
std::vector<std::string> refNames = {}

The names of the relation branches.

std::vector<std::string> vecNames = {}

The names of the vector member branches.

namespace sio_helpers

Typedefs

using position_type = uint32_t

Variables

static constexpr uint32_t SIOTocMarker = 0xc001fea7

marker for showing that a TOC has been stored in the file

static constexpr int SIOTocInfoSize = sizeof(uint64_t)

the number of bits necessary to store the SIOTocMarker and the actual position of the start of the SIOFileTOCRecord

static constexpr const char *SIOTocRecordName = "podio_SIO_TOC_Record"

The name of the TOCRecord.

static constexpr const char *SIOEDMDefinitionName = "podio_SIO_EDMDefinitions"

The name of the record containing the EDM definitions in json format.

namespace utils

Functions

template<typename T>
void swap(MaybeSharedPtr<T> &a, MaybeSharedPtr<T> &b)

Variables

static constexpr auto MarkOwned = detail::MarkOwnedTag{}
template<typename T>
class MaybeSharedPtr
#include <podio/utilities/MaybeSharedPtr.h>

“Semi-smart” pointer class for pointers that at some point during their lifetime might hand over management to another entity.

E.g. Objects that are added to a collection will hand over the management of their Obj* to collection. In such a case two things need to be considered:

  • Other Objects with the same Obj* instance should not delete the managed Obj*, even if the last Object goes out of scope

  • Even if the managed Obj* is gone (e.g. collection has gone out of scope or was cleared), the remaining Object instances should still be able to gracefully destruct, even if they are at this point merely an “empty husk” The MaybeSharedPtr achieves this by having an optional control block that controls the lifetime of itself and potentially the managed Obj*.

Public Functions

MaybeSharedPtr() = delete

There are no empty MaybeSharedPtrs.

inline explicit MaybeSharedPtr(T *p)

Constructor from raw pointer.

Assumes someone else manages the pointer already

inline explicit MaybeSharedPtr(T *p, detail::MarkOwnedTag)

Constructor from a raw pointer assuming ownership in the process.

inline MaybeSharedPtr(const MaybeSharedPtr &other)

Copy constructor.

inline MaybeSharedPtr &operator=(MaybeSharedPtr other)

Assignment operator.

inline MaybeSharedPtr(MaybeSharedPtr &&other)

Move constructor.

inline ~MaybeSharedPtr()

Destructor.

inline T *get() const

Get a raw pointer to the managed pointer.

Do not change anything concerning the management of the pointer

inline T *release()

Get a raw pointer to the managed pointer and assume ownership.

inline operator bool() const
inline T *operator->()
inline const T *operator->() const
inline T &operator*()
inline const T &operator*() const

Friends

template<typename U>
friend void swap(MaybeSharedPtr<U> &a, MaybeSharedPtr<U> &b)
namespace version

Functions

inline std::ostream &operator<<(std::ostream &os, const Version &v)
static constexpr Version decode_version(unsigned long version) noexcept

Decode a version from a 64 bit unsigned.

Variables

static constexpr Version build_version = {podio_VERSION_MAJOR, podio_VERSION_MINOR, podio_VERSION_PATCH}

The current build version.

struct Version
#include <podio/podioVersion.h>

Version class consisting of 3 16 bit unsigned integers to hold the major, minor and patch version.

Provides constexpr comparison operators that allow to use this class in constexpr-if clauses.

Public Members

uint16_t major = {0}
uint16_t minor = {0}
uint16_t patch = {0}

Friends

friend std::ostream &operator<<(std::ostream&, const Version &v)