PandaRoot
PndMutableContainer.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 
26 #ifndef PNDMUTABLECONTAINER_HH
27 #define PNDMUTABLECONTAINER_HH
28 
29 #include <vector>
30 
31 #include "PndContainerI.h"
32 #include "PndSTDMutableContainer.h"
33 #include "PndTCAMutableContainer.h"
34 
35 template <class T>
37 
38  public:
45  PndMutableContainer(const TString &t_foldername = "", Bool_t t_persistency = kTRUE) : PndMutableContainerI<T>(t_foldername, t_persistency) {}
46 
51  virtual ~PndMutableContainer(){};
52 
58  void SetContainer(PndMutableContainerI<T> *t_container) { this->fImp.reset(t_container); }
59 
66  virtual void Reset() final
67  {
68  if (this->fImp != nullptr) {
69  this->fImp->Reset();
70  }
71  }
72 
79  virtual T *CreateCopy(const T &t_data) final
80  {
81  if (this->fImp != nullptr) {
82  return this->fImp->CreateCopy(t_data);
83  }
84  return nullptr;
85  }
86 
92  virtual void RemoveAt(Int_t t_index) final
93  {
94  if (this->fImp != nullptr) {
95  this->fImp->RemoveAt(t_index);
96  }
97  }
98 
104  virtual ssize_t GetSize() const final
105  {
106  if (this->fImp != nullptr) {
107  return this->fImp->GetSize();
108  }
109  return 0;
110  }
111 
118  virtual T *GetElement(Int_t t_index) const final
119  {
120  if (this->fImp != nullptr) {
121  return this->fImp->GetElement(t_index);
122  }
123  return nullptr;
124  }
125 
130  virtual void Compress()
131  {
132  if (this->fImp != nullptr) {
133  this->fImp->Compress();
134  }
135  }
136 
137  protected:
138  std::unique_ptr<PndMutableContainerI<T>> fImp{nullptr};
139 };
140 
141 #endif /*PNDMUTABLECONTAINER_HH*/
PndMutableContainer(const TString &t_foldername="", Bool_t t_persistency=kTRUE)
Construct a new PndMutableContainer object.
virtual void Compress()
Compress.
Input and Output Container implementation of PndMutableContainerI using an underlying TClonesArray...
virtual ~PndMutableContainer()
Destroy the PndMutableContainer object.
virtual void RemoveAt(Int_t t_index) final
Delete object at t_index in internal data.
virtual T * CreateCopy(const T &t_data) final
Create a copy of t_data in internal data and return ptr to it.
Input and Output Container implementation of PndMutableContainerI using an underlying std::vector<T> ...
virtual ssize_t GetSize() const final
Get the number of members in internal data.
virtual void Reset() final
Reset data.
Interface to a datacontainer to be used in PandaROOT.
std::unique_ptr< PndMutableContainerI< T > > fImp
virtual T * GetElement(Int_t t_index) const final
Get the Element object at t_index.
void SetContainer(PndMutableContainerI< T > *t_container)
Set the Output Container object.