PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
podio::UserDataCollection< BasicType, typename > Class Template Reference

#include <UserDataCollection.h>

+ Inheritance diagram for podio::UserDataCollection< BasicType, typename >:

Public Member Functions

 UserDataCollection ()=default
 
 UserDataCollection (std::vector< BasicType > &&vec)
 Constructor from an existing vector (wich will be moved from!)
 
 UserDataCollection (const UserDataCollection &)=delete
 
UserDataCollectionoperator= (const UserDataCollection &)=delete
 
 UserDataCollection (UserDataCollection &&)=default
 
UserDataCollectionoperator= (UserDataCollection &&)=default
 
 ~UserDataCollection ()=default
 
void prepareForWrite () const override
 prepare buffers for serialization
 
void prepareAfterRead () override
 re-create collection from buffers after read
 
bool setReferences (const ICollectionProvider *) override
 initialize references after read
 
void setID (unsigned id) override
 set collection ID
 
unsigned getID () const override
 get collection ID
 
podio::CollectionWriteBuffers getBuffers () override
 Get the collection buffers for this collection.
 
podio::CollectionReadBuffers createBuffers () final
 Create (empty) collection buffers from which a collection can be constructed.
 
bool isValid () const override
 check for validity of the container after read
 
size_t size () const override
 number of elements in the collection
 
std::string getTypeName () const override
 fully qualified type name
 
std::string getValueTypeName () const override
 fully qualified type name of elements - with namespace
 
std::string getDataTypeName () const override
 fully qualified type name of stored POD elements - with namespace
 
void clear () override
 clear the collection and all internal states
 
bool isSubsetCollection () const override
 check if this collection is a subset collection - no subset possible
 
void setSubsetCollection (bool) override
 declare this collection to be a subset collectionv - no effect
 
void print (std::ostream &os=std::cout, bool flush=true) const override
 Print this collection to the passed stream.
 
size_t getDatamodelRegistryIndex () const override
 Get the index in the DatatypeRegistry of the EDM this collection belongs to.
 
std::vector< BasicType >::iterator begin ()
 
std::vector< BasicType >::iterator end ()
 
std::vector< BasicType >::const_iterator begin () const
 
std::vector< BasicType >::const_iterator end () const
 
std::vector< BasicType >::reference operator[] (size_t idx)
 
std::vector< BasicType >::const_reference operator[] (size_t idx) const
 
void resize (size_t count)
 
void push_back (const BasicType &value)
 
std::vector< BasicType > & vec ()
 access to the actual data vector
 
const std::vector< BasicType > & vec () const
 const access to the actual data vector
 
- Public Member Functions inherited from podio::CollectionBase
 CollectionBase (const CollectionBase &)=delete
 No copy c'tor because collections are move-only.
 
CollectionBaseoperator= (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 (unsigned id)=0
 set collection ID
 
virtual unsigned getID () const =0
 get collection ID
 
virtual podio::CollectionWriteBuffers getBuffers ()=0
 Get the collection buffers for this collection.
 
virtual podio::CollectionReadBuffers createBuffers ()=0
 Create (empty) collection buffers from which a collection can be constructed.
 
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 std::string getTypeName () const =0
 fully qualified type name
 
virtual std::string getValueTypeName () const =0
 fully qualified type name of elements - with namespace
 
virtual std::string getDataTypeName () const =0
 fully qualified type name of stored POD elements - with namespace
 
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.
 

Additional Inherited Members

- Protected Member Functions inherited from podio::CollectionBase
 CollectionBase ()=default
 default constructor
 
 CollectionBase (CollectionBase &&)=default
 Move constructor.
 
CollectionBaseoperator= (CollectionBase &&)=default
 Move assignment.
 

Detailed Description

template<typename BasicType, typename = EnableIfSupportedUserType<BasicType>>
class podio::UserDataCollection< BasicType, typename >

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

Definition at line 59 of file UserDataCollection.h.

Constructor & Destructor Documentation

◆ UserDataCollection() [1/4]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
podio::UserDataCollection< BasicType, typename >::UserDataCollection ( )
default

◆ UserDataCollection() [2/4]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
podio::UserDataCollection< BasicType, typename >::UserDataCollection ( std::vector< BasicType > &&  vec)
inline

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

Definition at line 74 of file UserDataCollection.h.

74 : _vec(std::move(vec)) {
75 }
std::vector< BasicType > & vec()
access to the actual data vector

◆ UserDataCollection() [3/4]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
podio::UserDataCollection< BasicType, typename >::UserDataCollection ( const UserDataCollection< BasicType, typename > &  )
delete

◆ UserDataCollection() [4/4]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
podio::UserDataCollection< BasicType, typename >::UserDataCollection ( UserDataCollection< BasicType, typename > &&  )
default

◆ ~UserDataCollection()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
podio::UserDataCollection< BasicType, typename >::~UserDataCollection ( )
default

Member Function Documentation

◆ begin() [1/2]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::vector< BasicType >::iterator podio::UserDataCollection< BasicType, typename >::begin ( )
inline

Definition at line 182 of file UserDataCollection.h.

182 {
183 return _vec.begin();
184 }

◆ begin() [2/2]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::vector< BasicType >::const_iterator podio::UserDataCollection< BasicType, typename >::begin ( ) const
inline

Definition at line 188 of file UserDataCollection.h.

188 {
189 return _vec.begin();
190 }

◆ clear()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
void podio::UserDataCollection< BasicType, typename >::clear ( )
inlineoverridevirtual

clear the collection and all internal states

Implements podio::CollectionBase.

Definition at line 147 of file UserDataCollection.h.

147 {
148 _vec.clear();
149 };

◆ createBuffers()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
podio::CollectionReadBuffers podio::UserDataCollection< BasicType, typename >::createBuffers ( )
inlinefinalvirtual

Create (empty) collection buffers from which a collection can be constructed.

Implements podio::CollectionBase.

Definition at line 111 of file UserDataCollection.h.

111 {
112 return {nullptr, nullptr, nullptr,
113 [](podio::CollectionReadBuffers buffers, bool) {
114 return std::make_unique<UserDataCollection<BasicType>>(std::move(*buffers.dataAsVector<BasicType>()));
115 },
116 [](podio::CollectionReadBuffers& buffers) {
117 buffers.data = podio::CollectionWriteBuffers::asVector<BasicType>(buffers.data);
118 }};
119 }
std::vector< DataT > * dataAsVector()

◆ end() [1/2]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::vector< BasicType >::iterator podio::UserDataCollection< BasicType, typename >::end ( )
inline

Definition at line 185 of file UserDataCollection.h.

185 {
186 return _vec.end();
187 }

◆ end() [2/2]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::vector< BasicType >::const_iterator podio::UserDataCollection< BasicType, typename >::end ( ) const
inline

Definition at line 191 of file UserDataCollection.h.

191 {
192 return _vec.end();
193 }

◆ getBuffers()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
podio::CollectionWriteBuffers podio::UserDataCollection< BasicType, typename >::getBuffers ( )
inlineoverridevirtual

Get the collection buffers for this collection.

Implements podio::CollectionBase.

Definition at line 106 of file UserDataCollection.h.

106 {
107 _vecPtr = &_vec; // Set the pointer to the correct internal vector
108 return {&_vecPtr, &m_refCollections, &m_vecmem_info};
109 }

◆ getDatamodelRegistryIndex()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
size_t podio::UserDataCollection< BasicType, typename >::getDatamodelRegistryIndex ( ) const
inlineoverridevirtual

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

Implements podio::CollectionBase.

Definition at line 176 of file UserDataCollection.h.

176 {
178 }
static constexpr size_t NoDefinitionNecessary

◆ getDataTypeName()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::string podio::UserDataCollection< BasicType, typename >::getDataTypeName ( ) const
inlineoverridevirtual

fully qualified type name of stored POD elements - with namespace

Implements podio::CollectionBase.

Definition at line 142 of file UserDataCollection.h.

142 {
143 return userDataTypeName<BasicType>();
144 }

◆ getID()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
unsigned podio::UserDataCollection< BasicType, typename >::getID ( ) const
inlineoverridevirtual

get collection ID

Implements podio::CollectionBase.

Definition at line 101 of file UserDataCollection.h.

101 {
102 return m_collectionID;
103 }

◆ getTypeName()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::string podio::UserDataCollection< BasicType, typename >::getTypeName ( ) const
inlineoverridevirtual

fully qualified type name

Implements podio::CollectionBase.

Definition at line 132 of file UserDataCollection.h.

132 {
133 return std::string("podio::UserDataCollection<") + userDataTypeName<BasicType>() + ">";
134 }

◆ getValueTypeName()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::string podio::UserDataCollection< BasicType, typename >::getValueTypeName ( ) const
inlineoverridevirtual

fully qualified type name of elements - with namespace

Implements podio::CollectionBase.

Definition at line 137 of file UserDataCollection.h.

137 {
138 return userDataTypeName<BasicType>();
139 }

◆ isSubsetCollection()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
bool podio::UserDataCollection< BasicType, typename >::isSubsetCollection ( ) const
inlineoverridevirtual

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

Implements podio::CollectionBase.

Definition at line 152 of file UserDataCollection.h.

152 {
153 return false;
154 }

◆ isValid()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
bool podio::UserDataCollection< BasicType, typename >::isValid ( ) const
inlineoverridevirtual

check for validity of the container after read

Implements podio::CollectionBase.

Definition at line 122 of file UserDataCollection.h.

122 {
123 return true;
124 }

◆ operator=() [1/2]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
UserDataCollection & podio::UserDataCollection< BasicType, typename >::operator= ( const UserDataCollection< BasicType, typename > &  )
delete

◆ operator=() [2/2]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
UserDataCollection & podio::UserDataCollection< BasicType, typename >::operator= ( UserDataCollection< BasicType, typename > &&  )
default

◆ operator[]() [1/2]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::vector< BasicType >::reference podio::UserDataCollection< BasicType, typename >::operator[] ( size_t  idx)
inline

Definition at line 195 of file UserDataCollection.h.

195 {
196 return _vec[idx];
197 }

◆ operator[]() [2/2]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::vector< BasicType >::const_reference podio::UserDataCollection< BasicType, typename >::operator[] ( size_t  idx) const
inline

Definition at line 198 of file UserDataCollection.h.

198 {
199 return _vec[idx];
200 }

◆ prepareAfterRead()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
void podio::UserDataCollection< BasicType, typename >::prepareAfterRead ( )
inlineoverridevirtual

re-create collection from buffers after read

Implements podio::CollectionBase.

Definition at line 87 of file UserDataCollection.h.

87 {
88 }

◆ prepareForWrite()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
void podio::UserDataCollection< BasicType, typename >::prepareForWrite ( ) const
inlineoverridevirtual

prepare buffers for serialization

Implements podio::CollectionBase.

Definition at line 83 of file UserDataCollection.h.

83 {
84 }

◆ print()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
void podio::UserDataCollection< BasicType, typename >::print ( std::ostream &  os = std::cout,
bool  flush = true 
) const
inlineoverridevirtual

Print this collection to the passed stream.

Implements podio::CollectionBase.

Definition at line 161 of file UserDataCollection.h.

161 {
162 os << "[";
163 if (!_vec.empty()) {
164 os << _vec[0];
165 for (size_t i = 0; i < _vec.size(); ++i) {
166 os << ", " << _vec[i];
167 }
168 }
169 os << "]";
170
171 if (flush) {
172 os.flush(); // Necessary for python
173 }
174 }

Referenced by podio::operator<<().

◆ push_back()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
void podio::UserDataCollection< BasicType, typename >::push_back ( const BasicType &  value)
inline

Definition at line 205 of file UserDataCollection.h.

205 {
206 _vec.push_back(value);
207 }

Referenced by TEST_CASE().

◆ resize()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
void podio::UserDataCollection< BasicType, typename >::resize ( size_t  count)
inline

Definition at line 202 of file UserDataCollection.h.

202 {
203 _vec.resize(count);
204 }

Referenced by createUserDataCollections(), and write().

◆ setID()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
void podio::UserDataCollection< BasicType, typename >::setID ( unsigned  id)
inlineoverridevirtual

set collection ID

Implements podio::CollectionBase.

Definition at line 96 of file UserDataCollection.h.

96 {
97 m_collectionID = id;
98 }

◆ setReferences()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
bool podio::UserDataCollection< BasicType, typename >::setReferences ( const ICollectionProvider )
inlineoverridevirtual

initialize references after read

Implements podio::CollectionBase.

Definition at line 91 of file UserDataCollection.h.

91 {
92 return true;
93 }

◆ setSubsetCollection()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
void podio::UserDataCollection< BasicType, typename >::setSubsetCollection ( bool  )
inlineoverridevirtual

declare this collection to be a subset collectionv - no effect

Implements podio::CollectionBase.

Definition at line 157 of file UserDataCollection.h.

157 {
158 }

◆ size()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
size_t podio::UserDataCollection< BasicType, typename >::size ( ) const
inlineoverridevirtual

number of elements in the collection

Implements podio::CollectionBase.

Definition at line 127 of file UserDataCollection.h.

127 {
128 return _vec.size();
129 }

Referenced by checkCollections().

◆ vec() [1/2]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::vector< BasicType > & podio::UserDataCollection< BasicType, typename >::vec ( )
inline

access to the actual data vector

Definition at line 210 of file UserDataCollection.h.

210 {
211 return _vec;
212 }

◆ vec() [2/2]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
const std::vector< BasicType > & podio::UserDataCollection< BasicType, typename >::vec ( ) const
inline

const access to the actual data vector

Definition at line 215 of file UserDataCollection.h.

215 {
216 return _vec;
217 }

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