PandaTree
ContainerBase.h
1 #ifndef PandaTree_Framework_ContainerBase_h
2 #define PandaTree_Framework_ContainerBase_h
3 
4 #include "ReaderObject.h"
5 #include "Element.h"
6 #include "IOUtils.h"
7 
8 #include "TString.h"
9 
10 #include <vector>
11 #include <functional>
12 
13 namespace panda {
15 
18  class ContainerBase : public ReaderObject {
19  public:
20  ContainerBase() = delete;
21  ContainerBase(ContainerBase const&) = delete;
22  virtual ~ContainerBase() {}
23  ContainerBase& operator=(ContainerBase const&) = delete;
24 
25  char const* getName() const final { return name_; }
26  void setName(char const* name) final { name_ = name; }
27  void print(std::ostream& = std::cout, UInt_t level = 1) const override;
28  void dump(std::ostream& = std::cout) const override;
29 
30  virtual UInt_t size() const = 0;
31  virtual Element::datastore& getData() = 0;
32  virtual Element::datastore const& getData() const = 0;
33  virtual Element& elemAt(UInt_t) = 0;
34  virtual Element const& elemAt(UInt_t) const = 0;
35 
36  typedef std::function<bool(Element const&, Element const&)> Comparison;
38 
43  virtual std::vector<UInt_t> sort(Comparison const& fct) = 0;
44 
45  protected:
46  ContainerBase(char const* name, UInt_t unitSize) : name_(name), unitSize_(unitSize) {}
47 
48  TString name_{""};
49  UInt_t const unitSize_{0};
50  Char_t* array_{0};
51  };
52 
53 }
54 
55 #endif
void dump(std::ostream &=std::cout) const override
Dump the object content.
Definition: ContainerBase.cc:23
void print(std::ostream &=std::cout, UInt_t level=1) const override
Print the object content.
Definition: ContainerBase.cc:7
Definition: Element.h:45
void setName(char const *name) final
Set object name.
Definition: ContainerBase.h:26
char const * getName() const final
Name of this object.
Definition: ContainerBase.h:25
Base class for all containers.
Definition: ContainerBase.h:18
virtual std::vector< UInt_t > sort(Comparison const &fct)=0
Sort the contents using a comparison function and returns an array of pre-sort indices.
Base class for elements of containers.
Definition: Element.h:32
Definition: Array.h:11
Base class for objects that can be linked to an input tree directly.
Definition: ReaderObject.h:10