Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:50:08

0001 #ifndef PODIO_COLLECTIONBASE_H
0002 #define PODIO_COLLECTIONBASE_H
0003 
0004 #include "podio/CollectionBuffers.h"
0005 #include "podio/ObjectID.h"
0006 #include "podio/SchemaEvolution.h"
0007 
0008 #include <iostream>
0009 #include <string_view>
0010 #include <utility>
0011 #include <vector>
0012 
0013 namespace podio {
0014 // forward declarations
0015 class ICollectionProvider;
0016 
0017 struct RelationNames;
0018 
0019 class CollectionBase {
0020 protected:
0021   /// default constructor
0022   CollectionBase() = default;
0023   /// Move constructor
0024   CollectionBase(CollectionBase&&) = default;
0025   /// Move assignment
0026   CollectionBase& operator=(CollectionBase&&) = default;
0027 
0028 public:
0029   /// No copy c'tor because collections are move-only
0030   CollectionBase(const CollectionBase&) = delete;
0031   /// No copy assignment because collections are move-only
0032   CollectionBase& operator=(const CollectionBase&) = delete;
0033 
0034   /// prepare buffers for serialization
0035   virtual void prepareForWrite() const = 0;
0036 
0037   /// re-create collection from buffers after read
0038   virtual void prepareAfterRead() = 0;
0039 
0040   /// initialize references after read
0041   virtual bool setReferences(const ICollectionProvider* collectionProvider) = 0;
0042 
0043   /// set collection ID
0044   virtual void setID(uint32_t id) = 0;
0045 
0046   /// get collection ID
0047   virtual uint32_t getID() const = 0;
0048 
0049   /// Get the collection buffers for this collection
0050   virtual podio::CollectionWriteBuffers getBuffers() = 0;
0051 
0052   /// check for validity of the container after read
0053   virtual bool isValid() const = 0;
0054 
0055   /// number of elements in the collection
0056   virtual size_t size() const = 0;
0057 
0058   /// Is the collection empty
0059   virtual bool empty() const = 0;
0060 
0061   /// fully qualified type name
0062   virtual const std::string_view getTypeName() const = 0;
0063   /// fully qualified type name of elements - with namespace
0064   virtual const std::string_view getValueTypeName() const = 0;
0065   /// fully qualified type name of stored POD elements - with namespace
0066   virtual const std::string_view getDataTypeName() const = 0;
0067   /// schema version of the collection
0068   virtual SchemaVersionT getSchemaVersion() const = 0;
0069 
0070   /// destructor
0071   virtual ~CollectionBase() = default;
0072 
0073   /// clear the collection and all internal states
0074   virtual void clear() = 0;
0075 
0076   /// check if this collection is a subset collection
0077   virtual bool isSubsetCollection() const = 0;
0078 
0079   /// declare this collection to be a subset collection
0080   virtual void setSubsetCollection(bool setSubset = true) = 0;
0081 
0082   /// print this collection to the passed stream
0083   virtual void print(std::ostream& os = std::cout, bool flush = true) const = 0;
0084 
0085   /// Get the index in the DatatypeRegistry of the EDM this collection belongs to
0086   virtual size_t getDatamodelRegistryIndex() const = 0;
0087 };
0088 
0089 } // namespace podio
0090 
0091 #endif