Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/podio/CollectionBase.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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