PandaRoot
PndContainerI.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 
27 #ifndef PNDCONTAINERI_H
28 #define PNDCONTAINERI_H
29 
30 #include <vector>
31 
32 #include "TString.h"
33 #include "PndContainerBaseI.h"
34 
35 template <class T>
36 class PndContainerI : public PndContainerBaseI {
37 
38  public:
50  virtual ~PndContainerI(){};
51 
58  virtual T const *GetConstElementPtr(Int_t t_index) const = 0;
59 
65  std::vector<T const *> GetVectorOfPtrToConst() const
66  {
67  std::vector<T const *> result{};
68  result.reserve(this->GetSize());
69  for (Int_t i = 0; i < this->GetSize(); ++i) {
70  result.push_back(this->GetConstElementPtr(i));
71  }
72  return result;
73  }
74 
75  TString GetClassName() const { return T{}.ClassName(); }
76 };
77 
78 #endif /*PNDCONTAINERI_H*/
virtual T const * GetConstElementPtr(Int_t t_index) const =0
Get the Element object at t_index.
virtual ssize_t GetSize() const =0
Get the number of members in internal data.
unsigned int i
Definition: P4_F32vec4.h:33
Interface to a datacontainer to be used in PandaROOT.
TString GetClassName() const
Definition: PndContainerI.h:75
std::vector< T const * > GetVectorOfPtrToConst() const
return vector of const ptrs pointing at internal data, to be used to access data independent of under...
Definition: PndContainerI.h:65
virtual ~PndContainerI()
Destroy the PndContainerI object.
Definition: PndContainerI.h:50
PndContainerI()
Construct a new PndContainerI object.
Definition: PndContainerI.h:45