PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
podio::Frame Class Reference

#include <Frame.h>

Public Member Functions

 Frame ()
 
template<typename FrameDataT >
 Frame (std::unique_ptr< FrameDataT >)
 
template<typename FrameDataT , typename = EnableIfRValue<FrameDataT>>
 Frame (FrameDataT &&)
 
 Frame (const Frame &)=delete
 
Frameoperator= (const Frame &)=delete
 
 Frame (Frame &&)=default
 
Frameoperator= (Frame &&)=default
 
 ~Frame ()=default
 
template<typename CollT , typename = EnableIfCollection<CollT>>
const CollT & get (const std::string &name) const
 
const podio::CollectionBaseget (const std::string &name) const
 
template<typename CollT , typename = EnableIfCollectionRValue<CollT>>
const CollT & put (CollT &&coll, const std::string &name)
 
void put (std::unique_ptr< podio::CollectionBase > coll, const std::string &name)
 
template<typename T , typename = podio::EnableIfValidGenericDataType<T>>
void putParameter (const std::string &key, T value)
 
void putParameter (const std::string &key, std::string value)
 
void putParameter (const std::string &key, std::vector< std::string > values)
 
template<typename T , typename = std::enable_if_t<detail::isInTuple<T, SupportedGenericDataTypes>>>
void putParameter (const std::string &key, std::initializer_list< T > &&values)
 
template<typename T , typename = podio::EnableIfValidGenericDataType<T>>
podio::GenericDataReturnType< T > getParameter (const std::string &key) const
 
const podio::GenericParametersgetParameters () const
 
template<typename T , typename = podio::EnableIfValidGenericDataType<T>>
std::vector< std::string > getParameterKeys () const
 
std::vector< std::string > getAvailableCollections () const
 
const podio::GenericParametersgetGenericParametersForWrite () const
 
const podio::CollectionBasegetCollectionForWrite (const std::string &name) const
 
podio::CollectionIDTable getCollectionIDTableForWrite () const
 

Detailed Description

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

Definition at line 68 of file Frame.h.

Constructor & Destructor Documentation

◆ Frame() [1/5]

podio::Frame::Frame ( )
inline

Empty Frame constructor

Definition at line 285 of file Frame.h.

285 : Frame(std::make_unique<detail::EmptyFrameData>()) {
286}

◆ Frame() [2/5]

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

Frame constructor from (almost) arbitrary raw data

Definition at line 289 of file Frame.h.

289 : m_self(std::make_unique<FrameModel<FrameDataT>>(std::move(data))) {
290}

◆ Frame() [3/5]

template<typename FrameDataT , typename >
podio::Frame::Frame ( FrameDataT &&  data)

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

Definition at line 293 of file Frame.h.

293 : Frame(std::make_unique<FrameDataT>(std::move(data))) {
294}

◆ Frame() [4/5]

podio::Frame::Frame ( const Frame )
delete

◆ Frame() [5/5]

podio::Frame::Frame ( Frame &&  )
default

◆ ~Frame()

podio::Frame::~Frame ( )
default

Frame destructor

Member Function Documentation

◆ get() [1/2]

template<typename CollT , typename >
const CollT & podio::Frame::get ( const std::string &  name) const

Get a collection from the Frame

Definition at line 297 of file Frame.h.

297 {
298 const auto* coll = dynamic_cast<const CollT*>(m_self->get(name));
299 if (coll) {
300 return *coll;
301 }
302 // TODO: Handle non-existing collections
303 static const auto emptyColl = CollT();
304 return emptyColl;
305}

Referenced by checkFrame().

◆ get() [2/2]

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

Get a collection from the Frame. This is the pointer-to-base version for type-erased access (e.g. python interface)

Definition at line 307 of file Frame.h.

307 {
308 return m_self->get(name);
309}

◆ getAvailableCollections()

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

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

Definition at line 252 of file Frame.h.

252 {
253 return m_self->availableCollections();
254 }

Referenced by podio::ROOTFrameWriter::writeFrame(), and podio::SIOFrameWriter::writeFrame().

◆ getCollectionForWrite()

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

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

Definition at line 269 of file Frame.h.

269 {
270 const auto* coll = m_self->get(name);
271 if (coll) {
272 coll->prepareForWrite();
273 }
274
275 return coll;
276 }

Referenced by podio::ROOTFrameWriter::writeFrame(), and podio::SIOFrameWriter::writeFrame().

◆ getCollectionIDTableForWrite()

podio::CollectionIDTable podio::Frame::getCollectionIDTableForWrite ( ) const
inline

Definition at line 278 of file Frame.h.

278 {
279 return m_self->getIDTable();
280 }

Referenced by podio::ROOTFrameWriter::writeFrame(), and podio::SIOFrameWriter::writeFrame().

◆ getGenericParametersForWrite()

const podio::GenericParameters & podio::Frame::getGenericParametersForWrite ( ) const
inline

Get the GenericParameters for writing

Definition at line 262 of file Frame.h.

262 {
263 return m_self->parameters();
264 }

◆ getParameter()

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

Retrieve parameters via key from the internal store. Return type will either by a const reference or a value depending on the desired type.

Definition at line 232 of file Frame.h.

232 {
233 return m_self->parameters().getValue<T>(key);
234 }

Referenced by checkFrame().

◆ getParameterKeys()

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

Get the keys of all stored parameters for a given type

Definition at line 245 of file Frame.h.

245 {
246 return m_self->parameters().getKeys<T>();
247 }

◆ getParameters()

const podio::GenericParameters & podio::Frame::getParameters ( ) const
inline

Get all parameters that are stored in this Frame

Definition at line 238 of file Frame.h.

238 {
239 return m_self->parameters();
240 }

Referenced by podio::ROOTFrameWriter::writeFrame(), and podio::SIOFrameWriter::writeFrame().

◆ operator=() [1/2]

Frame & podio::Frame::operator= ( const Frame )
delete

◆ operator=() [2/2]

Frame & podio::Frame::operator= ( Frame &&  )
default

◆ put() [1/2]

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

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

Definition at line 319 of file Frame.h.

319 {
320 const auto* retColl = static_cast<const CollT*>(m_self->put(std::make_unique<CollT>(std::move(coll)), name));
321 if (retColl) {
322 return *retColl;
323 }
324 // TODO: Handle collision case
325 static const auto emptyColl = CollT();
326 return emptyColl;
327}

Referenced by makeFrame().

◆ put() [2/2]

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

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

Definition at line 311 of file Frame.h.

311 {
312 const auto* retColl = m_self->put(std::move(coll), name);
313 if (!retColl) {
314 // TODO: Handle collisions
315 }
316}

◆ putParameter() [1/4]

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

Add a vector of values into the parameters of the Frame. Overload for catching on-the-fly conversions of initializer_lists of values.

Definition at line 224 of file Frame.h.

224 {
225 putParameter<std::vector<T>>(key, std::move(values));
226 }

◆ putParameter() [2/4]

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

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.

Definition at line 208 of file Frame.h.

208 {
209 putParameter<std::string>(key, std::move(value));
210 }

◆ putParameter() [3/4]

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

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.

Definition at line 216 of file Frame.h.

216 {
217 putParameter<std::vector<std::string>>(key, std::move(values));
218 }

◆ putParameter() [4/4]

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

Add a value to the parameters of the Frame (if the type is supported). Copy the value into the internal store

Definition at line 201 of file Frame.h.

201 {
202 m_self->parameters().setValue(key, value);
203 }

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