PandaRoot
PndMutableContainerI.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 #ifndef PNDMUTABLECONTAINERI_HH
14 #define PNDMUTABLECONTAINERI_HH
15 
16 #include "PndContainerI.h"
17 
18 template <class T>
19 class PndMutableContainerI : public PndContainerI<T> {
20 
21  public:
28  PndMutableContainerI(const TString &t_foldername = "", Bool_t t_persistency = kTRUE) : PndContainerI<T>{}, fFolderName(t_foldername), fPersistency(t_persistency) {}
33  virtual ~PndMutableContainerI(){};
34 
41  virtual void Reset() = 0;
42 
49  virtual T *CreateCopy(const T &t_data) = 0;
50 
56  virtual void RemoveAt(Int_t t_index) = 0;
57 
62  virtual void Compress() {}
63 
70  virtual T *GetElement(Int_t t_index) const = 0;
71 
78  virtual T const *GetConstElementPtr(Int_t t_index) const { return this->GetElement(t_index); }
79 
85  std::vector<T *> GetVector() const
86  {
87  std::vector<T *> result{};
88  result.reserve(this->GetSize());
89  for (Int_t i = 0; i < this->GetSize(); ++i) {
90  result.push_back(this->GetElement(i));
91  }
92  return result;
93  }
94 
100  void SetFolderName(const TString &t_foldername) { fFolderName = t_foldername; }
101 
107  void SetPersistency(Bool_t t_persistency) { fPersistency = t_persistency; }
108 
114  const TString &GetFolderName() const { return fFolderName; }
115 
121  Bool_t GetPersistency() const { return fPersistency; }
122 
123  protected:
124  TString fFolderName{""};
125  Bool_t fPersistency{kFALSE};
126 };
127 
128 #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:33
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.