1#ifndef PODIO_USERDATACOLLECTION_H
2#define PODIO_USERDATACOLLECTION_H
15#define PODIO_ADD_USER_TYPE(type) \
17 constexpr const char* userDataTypeName<type>() { \
26 std::tuple<float, double, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t>;
37template <
typename BasicType,
typename = EnableIfSupportedUserType<BasicType>>
58template <
typename BasicType,
typename = EnableIfSupportedUserType<BasicType>>
62 std::vector<BasicType> _vec{};
66 std::vector<BasicType>* _vecPtr{
nullptr};
67 int m_collectionID{0};
96 void setID(
unsigned id)
override {
102 return m_collectionID;
108 return {&_vecPtr, &m_refCollections, &m_vecmem_info};
112 return {
nullptr,
nullptr,
nullptr,
114 return std::make_unique<UserDataCollection<BasicType>>(std::move(*buffers.
dataAsVector<BasicType>()));
117 buffers.
data = podio::CollectionWriteBuffers::asVector<BasicType>(buffers.
data);
133 return std::string(
"podio::UserDataCollection<") + userDataTypeName<BasicType>() +
">";
138 return userDataTypeName<BasicType>();
143 return userDataTypeName<BasicType>();
161 void print(std::ostream& os = std::cout,
bool flush =
true)
const override {
165 for (
size_t i = 0; i < _vec.size(); ++i) {
166 os <<
", " << _vec[i];
182 typename std::vector<BasicType>::iterator
begin() {
185 typename std::vector<BasicType>::iterator
end() {
188 typename std::vector<BasicType>::const_iterator
begin()
const {
191 typename std::vector<BasicType>::const_iterator
end()
const {
195 typename std::vector<BasicType>::reference
operator[](
size_t idx) {
198 typename std::vector<BasicType>::const_reference
operator[](
size_t idx)
const {
206 _vec.push_back(value);
210 typename std::vector<BasicType>&
vec() {
215 const typename std::vector<BasicType>&
vec()
const {
221#undef PODIO_ADD_USER_TYPE
223template <
typename BasicType,
typename = EnableIfSupportedUserType<BasicType>>
#define PODIO_ADD_USER_TYPE(type)
static constexpr size_t NoDefinitionNecessary
void setSubsetCollection(bool) override
declare this collection to be a subset collectionv - no effect
std::string getTypeName() const override
fully qualified type name
void push_back(const BasicType &value)
std::vector< BasicType > & vec()
access to the actual data vector
void prepareAfterRead() override
re-create collection from buffers after read
UserDataCollection & operator=(const UserDataCollection &)=delete
UserDataCollection(std::vector< BasicType > &&vec)
Constructor from an existing vector (wich will be moved from!)
std::string getDataTypeName() const override
fully qualified type name of stored POD elements - with namespace
std::vector< BasicType >::const_iterator begin() const
bool setReferences(const ICollectionProvider *) override
initialize references after read
bool isValid() const override
check for validity of the container after read
podio::CollectionWriteBuffers getBuffers() override
Get the collection buffers for this collection.
const std::vector< BasicType > & vec() const
const access to the actual data vector
std::vector< BasicType >::const_iterator end() const
bool isSubsetCollection() const override
check if this collection is a subset collection - no subset possible
~UserDataCollection()=default
void setID(unsigned id) override
set collection ID
UserDataCollection(UserDataCollection &&)=default
std::string getValueTypeName() const override
fully qualified type name of elements - with namespace
unsigned getID() const override
get collection ID
std::vector< BasicType >::iterator end()
podio::CollectionReadBuffers createBuffers() final
Create (empty) collection buffers from which a collection can be constructed.
std::vector< BasicType >::reference operator[](size_t idx)
size_t size() const override
number of elements in the collection
void prepareForWrite() const override
prepare buffers for serialization
UserDataCollection & operator=(UserDataCollection &&)=default
void resize(size_t count)
UserDataCollection()=default
void print(std::ostream &os=std::cout, bool flush=true) const override
Print this collection to the passed stream.
std::vector< BasicType >::iterator begin()
void clear() override
clear the collection and all internal states
std::vector< BasicType >::const_reference operator[](size_t idx) const
size_t getDatamodelRegistryIndex() const override
Get the index in the DatatypeRegistry of the EDM this collection belongs to.
UserDataCollection(const UserDataCollection &)=delete
std::tuple< float, double, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t > SupportedUserDataTypes
std::vector< std::pair< std::string, void * > > VectorMembersInfo
std::ostream & operator<<(std::ostream &o, const podio::UserDataCollection< BasicType > &coll)
std::enable_if_t< detail::isInTuple< T, SupportedUserDataTypes > > EnableIfSupportedUserType
constexpr const char * userDataTypeName()
std::vector< UVecPtr< podio::ObjectID > > CollRefCollection
std::vector< DataT > * dataAsVector()