PandaRoot
PndMutableContainerI.h
Go to the documentation of this file.
1 #ifndef PNDMUTABLECONTAINERI_HH
2 #define PNDMUTABLECONTAINERI_HH
3 
4 #include "PndContainerI.h"
5 
6 template <class T>
7 class PndMutableContainerI : public PndContainerI<T> {
8 
9  public:
16  PndMutableContainerI(const TString &t_foldername = "", Bool_t t_persistency = kTRUE) : PndContainerI<T>{}, fFolderName(t_foldername), fPersistency(t_persistency) {}
21  virtual ~PndMutableContainerI(){};
22 
29  virtual void Reset() = 0;
30 
37  virtual T *CreateCopy(const T &t_data) = 0;
38 
44  virtual void RemoveAt(Int_t t_index) = 0;
45 
50  virtual void Compress() {}
51 
58  virtual T *GetElement(Int_t t_index) const = 0;
59 
66  virtual T const *GetConstElementPtr(Int_t t_index) const { return this->GetElement(t_index); }
67 
73  std::vector<T *> GetVector() const
74  {
75  std::vector<T *> result{};
76  result.reserve(this->GetSize());
77  for (Int_t i = 0; i < this->GetSize(); ++i) {
78  result.push_back(this->GetElement(i));
79  }
80  return result;
81  }
82 
88  void SetFolderName(const TString &t_foldername) { fFolderName = t_foldername; }
89 
95  void SetPersistency(Bool_t t_persistency) { fPersistency = t_persistency; }
96 
102  const TString &GetFolderName() const { return fFolderName; }
103 
109  Bool_t GetPersistency() const { return fPersistency; }
110 
111  protected:
112  TString fFolderName{""};
113  Bool_t fPersistency{kFALSE};
114 };
115 
116 #endif /*PNDMUTABLECONTAINERI_HH*/
virtual void Reset()=0
Reset data.
virtual T * GetElement(Int_t t_index) const =0
Get the Element object at t_index.
PndMutableContainerI(const TString &t_foldername="", Bool_t t_persistency=kTRUE)
Construct a new PndMutableContainerI object.
std::vector< T * > GetVector() const
return vector of ptrs pointing at internal data, to be used to access data independent of underlying ...
virtual ssize_t GetSize() const =0
Get the number of members in internal data.
unsigned int i
Definition: P4_F32vec4.h:21
Bool_t GetPersistency() const
Get the Persistency of the data.
const TString & GetFolderName() const
Get the Folder Name.
virtual T * CreateCopy(const T &t_data)=0
Create a copy of t_data in internal data and return ptr to it.
virtual void Compress()
Compress.
virtual void RemoveAt(Int_t t_index)=0
Delete object at t_index in internal data.
virtual T const * GetConstElementPtr(Int_t t_index) const
Get the Element object at t_index.
void SetPersistency(Bool_t t_persistency)
Set the Persistency of the data.
void SetFolderName(const TString &t_foldername)
Set the FolderName.
Interface to a datacontainer to be used in PandaROOT.
virtual ~PndMutableContainerI()
Destroy the PndMutableContainerI object.