Project
Loading...
Searching...
No Matches
o2::framework::InputRecord Class Reference

The input API of the Data Processing Layer This class holds the inputs which are valid for processing. The user can get an instance for it via the ProcessingContext and can use it to retrieve the inputs, either by name or by index. A few utility methods are provided to automatically cast the (deserialized) inputs to known types. More...

#include <InputRecord.h>

Classes

class  Deleter
 
struct  InputPos
 
class  InputRecordIterator
 
class  Iterator
 

Public Types

using DataHeader = o2::header::DataHeader
 
using iterator = InputRecordIterator< DataRef >
 
using const_iterator = InputRecordIterator< const DataRef >
 

Public Member Functions

 InputRecord (std::vector< InputRoute > const &inputs, InputSpan &span, ServiceRegistryRef)
 
int getPos (const char *name) const
 
int getPos (const std::string &name) const
 
DataRef getByPos (int pos, int part=0) const
 
DataRef getFirstValid (bool throwOnFailure=false) const
 Get the ref of the first valid input. If requested, throw an error if none is found.
 
size_t getNofParts (int pos) const
 
DataRef getDataRefByString (const char *bindingName, int part=0) const
 
template<typename R >
requires std::is_convertible_v<R, char const*>
DataRef getRef (R binding, int part=0) const
 
template<typename R >
requires requires(R r) { r.c_str(); }
DataRef getRef (R binding, int part=0) const
 
template<typename R >
requires std::is_convertible_v<R, DataRef>
DataRef getRef (R ref, int part=0) const
 
template<typename T = DataRef, typename R >
decltype(auto) get (R binding, int part=0) const
 
template<typename T = DataRef, typename R >
requires std::same_as<T, CCDBMetadataExtractor>
std::map< std::string, std::string > & get (R binding, int part=0) const
 
bool isValid (std::string const &s) const
 Helper method to be used to check if a given part of the InputRecord is present.
 
bool isValid (char const *s) const
 Helper method to be used to check if a given part of the InputRecord is present.
 
bool isValid (int pos) const
 
size_t size () const
 
size_t countValidInputs () const
 
const_iterator begin () const
 
const_iterator end () const
 
InputSpanspan ()
 

Static Public Member Functions

static InputPos getPos (std::vector< InputRoute > const &routes, ConcreteDataMatcher matcher)
 
static DataRef getByPos (std::vector< InputRoute > const &routes, InputSpan const &span, int pos, int part=0)
 

Detailed Description

The input API of the Data Processing Layer This class holds the inputs which are valid for processing. The user can get an instance for it via the ProcessingContext and can use it to retrieve the inputs, either by name or by index. A few utility methods are provided to automatically cast the (deserialized) inputs to known types.

The @ref get(binding) method is implemeted for the following types:
  • (a) DataRef holding header and payload information, this is also the default get method without template parameter
  • (b) std::string
  • (c) const char* this is meant for C-style strings which are 0 terminated, there is no length information
  • (d) TableConsumer
  • (f) span over messageable type T
  • (g) std::vector of messageable type or type with ROOT dictionary
  • (h) messageable type T
  • (i) pointer type T* for types with ROOT dictionary or messageable types
The return type of get(binding) is:
  • (a) DataRef object
  • (b) std::string copy of the payload
  • (c) const char* to payload content
  • (d) unique_ptr of TableConsumer
  • (e) object by move
  • (f) span object over original payload
  • (g) vector by move
  • (h) reference to object
  • (i) object with pointer-like behavior (unique_ptr)
Examples
   auto& v1 = get<int>("input1");
   auto v2 = get<vector<int>>("input2");
   auto v3 = get<TList*>("input3");
   auto v4 = get<vector<TParticle>>("input4");
Validity of inputs
Not all input slots are always valid if a custom completion policy is chosen. Validity can be checked using method isValid.

Iterator functionality is implemented to iterate over the list of DataRef objects, including begin() and end() methods.

   for (auto const& ref : inputs) {
     // do something with DataRef object ref
   }

Definition at line 101 of file InputRecord.h.

Member Typedef Documentation

◆ const_iterator

◆ DataHeader

◆ iterator

Constructor & Destructor Documentation

◆ InputRecord()

o2::framework::InputRecord::InputRecord ( std::vector< InputRoute > const &  inputs,
InputSpan span,
ServiceRegistryRef  registry 
)

Definition at line 36 of file InputRecord.cxx.

Member Function Documentation

◆ begin()

const_iterator o2::framework::InputRecord::begin ( ) const
inline

Definition at line 702 of file InputRecord.h.

◆ countValidInputs()

size_t o2::framework::InputRecord::countValidInputs ( ) const
Returns
the total number of valid inputs in the InputRecord. Invalid inputs might happen if the CompletionPolicy allows incomplete records to be consumed or processed.

Definition at line 163 of file InputRecord.cxx.

◆ end()

const_iterator o2::framework::InputRecord::end ( ) const
inline

Definition at line 707 of file InputRecord.h.

◆ get() [1/2]

template<typename T = DataRef, typename R >
decltype(auto) o2::framework::InputRecord::get ( R  binding,
int  part = 0 
) const
inline

Get the object of specified type T for the binding R. If R is a string like object, we look up by name the InputSpec and return the data associated to the given label. If R is a DataRef, we extract the result object from the Payload, following the information provided by the Header. The actual operation and cast depends on the target data type and the serialization type of the incoming data. By default we return a DataRef, which is the pair of pointers to the header and payload of the O2 Message. See Inputrecord class description for supported types.

Parameters
refDataRef with pointers to input spec, header, and payload

substitution for container of non-messageable objects with ROOT dictionary Notice that this will return a copy of the actual contents of the buffer, because the buffer is actually serialised. The extracted container is swaped to local, container, C++11 and beyond will implicitly apply return value optimization.

Returns
std container object

Definition at line 248 of file InputRecord.h.

◆ get() [2/2]

template<typename T = DataRef, typename R >
requires std::same_as<T, CCDBMetadataExtractor>
std::map< std::string, std::string > & o2::framework::InputRecord::get ( R  binding,
int  part = 0 
) const
inline

Definition at line 472 of file InputRecord.h.

◆ getByPos() [1/2]

DataRef o2::framework::InputRecord::getByPos ( int  pos,
int  part = 0 
) const

Definition at line 81 of file InputRecord.cxx.

◆ getByPos() [2/2]

DataRef o2::framework::InputRecord::getByPos ( std::vector< InputRoute > const &  routes,
InputSpan const &  span,
int  pos,
int  part = 0 
)
static

Definition at line 86 of file InputRecord.cxx.

◆ getDataRefByString()

DataRef o2::framework::InputRecord::getDataRefByString ( const char bindingName,
int  part = 0 
) const
inline

Definition at line 205 of file InputRecord.h.

◆ getFirstValid()

DataRef o2::framework::InputRecord::getFirstValid ( bool  throwOnFailure = false) const

Get the ref of the first valid input. If requested, throw an error if none is found.

Definition at line 115 of file InputRecord.cxx.

◆ getNofParts()

size_t o2::framework::InputRecord::getNofParts ( int  pos) const

Definition at line 130 of file InputRecord.cxx.

◆ getPos() [1/3]

int o2::framework::InputRecord::getPos ( const char name) const

Definition at line 45 of file InputRecord.cxx.

◆ getPos() [2/3]

int o2::framework::InputRecord::getPos ( const std::string &  name) const

Definition at line 76 of file InputRecord.cxx.

◆ getPos() [3/3]

InputRecord::InputPos o2::framework::InputRecord::getPos ( std::vector< InputRoute > const &  routes,
ConcreteDataMatcher  matcher 
)
static

Definition at line 61 of file InputRecord.cxx.

◆ getRef() [1/3]

template<typename R >
requires std::is_convertible_v<R, char const*>
DataRef o2::framework::InputRecord::getRef ( R  binding,
int  part = 0 
) const
inline

Definition at line 217 of file InputRecord.h.

◆ getRef() [2/3]

template<typename R >
requires requires(R r) { r.c_str(); }
DataRef o2::framework::InputRecord::getRef ( R  binding,
int  part = 0 
) const
inline

Definition at line 224 of file InputRecord.h.

◆ getRef() [3/3]

template<typename R >
requires std::is_convertible_v<R, DataRef>
DataRef o2::framework::InputRecord::getRef ( R  ref,
int  part = 0 
) const
inline

Definition at line 231 of file InputRecord.h.

◆ isValid() [1/3]

bool o2::framework::InputRecord::isValid ( char const *  s) const

Helper method to be used to check if a given part of the InputRecord is present.

Definition at line 142 of file InputRecord.cxx.

◆ isValid() [2/3]

bool o2::framework::InputRecord::isValid ( int  pos) const

Definition at line 151 of file InputRecord.cxx.

◆ isValid() [3/3]

bool o2::framework::InputRecord::isValid ( std::string const &  s) const
inline

Helper method to be used to check if a given part of the InputRecord is present.

Definition at line 515 of file InputRecord.h.

◆ size()

size_t o2::framework::InputRecord::size ( ) const
Returns
the total number of inputs in the InputRecord. Notice that these will include both valid and invalid inputs (i.e. inputs which have not arrived yet), depending on the CompletionPolicy you have (using the default policy all inputs will be valid).

Definition at line 137 of file InputRecord.cxx.

◆ span()

InputSpan & o2::framework::InputRecord::span ( )
inline

Definition at line 712 of file InputRecord.h.


The documentation for this class was generated from the following files: