Class podio::CollectionBufferFactory

class CollectionBufferFactory

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.