PandaRoot
PndConstContainerI.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 PNDCONSTCONTAINERI_HH
14 #define PNDCONSTCONTAINERI_HH
15 
16 #include "PndContainerI.h"
17 
18 template <class T>
19 class PndConstContainerI : public PndContainerI<T> {
20 
21  public:
30  virtual ~PndConstContainerI(){};
31 
38  virtual T const *GetElement(Int_t t_index) const = 0;
39 
46  virtual T const *GetConstElementPtr(Int_t t_index) const { return this->GetElement(t_index); }
47 
53  std::vector<T const *> GetVector() const
54  {
55  std::vector<T const *> result{};
56  result.reserve(this->GetSize());
57  for (Int_t i = 0; i < this->GetSize(); ++i) {
58  result.push_back(this->GetElement(i));
59  }
60  return result;
61  }
62 };
63 
64 #endif /*PNDCONSTCONTAINERI_HH*/
PndConstContainerI()
Construct a new PndConstContainerI object.
virtual T const * GetConstElementPtr(Int_t t_index) const
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
virtual T const * GetElement(Int_t t_index) const =0
Get the Element object at t_index.
Interface to a datacontainer to be used in PandaROOT.
std::vector< T const * > GetVector() const
return vector of ptrs pointing at internal data, to be used to access data independent of underlying ...