LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
SortedObjects.h
Go to the documentation of this file.
1 
12 #ifndef SortedObjects_h
13 #define SortedObjects_h
14 
15 #include <vector>
16 
17 namespace pma
18 {
19  class SortedObjectBase;
20  class SortedBranchBase;
21 }
22 
24 {
25  friend class pma::SortedBranchBase;
26 
27 public:
28  SortedObjectBase(void) : next(0), prev(0) {}
30 
33 
34  virtual ~SortedObjectBase(void) { Disconnect(); }
35 
36  virtual void Disconnect(void);
37 
38  virtual bool AddNext(pma::SortedObjectBase* nextElement);
39  virtual int RemoveNext(pma::SortedObjectBase* nextElement);
40 
41  virtual bool IsFirst(void) const { return !prev; }
42  virtual bool IsLast(void) const { return !next; }
43 
44  virtual pma::SortedObjectBase* Prev(void) const { return prev; }
45  virtual pma::SortedObjectBase* Next(unsigned int index = 0) const { return next; }
46  virtual unsigned int NextCount(void) const
47  {
48  if (next) return 1;
49  else return 0;
50  }
51 
52 protected:
55 };
56 
57 
61 {
62 public:
65  pma::SortedObjectBase(prevElement, nextElement)
66  {
67  if (nextElement) next_vector.push_back(next);
68  }
71 
72  virtual ~SortedBranchBase(void) { Disconnect(); }
73 
74  virtual void Disconnect(void);
75 
76  virtual bool AddNext(pma::SortedObjectBase* nextElement);
77  virtual int RemoveNext(pma::SortedObjectBase* nextElement);
78 
79  virtual pma::SortedObjectBase* Next(unsigned int index = 0) const
80  {
81  if (next_vector.size()) return next_vector[index];
82  else return 0;
83  }
84  virtual unsigned int NextCount(void) const { return next_vector.size(); }
85  virtual bool IsLast(void) const { return !(next_vector.size()); }
86 
87 protected:
88  std::vector< pma::SortedObjectBase* > next_vector;
89 };
90 
91 #endif
92 
pma::SortedObjectBase * prev
Definition: SortedObjects.h:54
virtual unsigned int NextCount(void) const
Definition: SortedObjects.h:84
virtual bool IsFirst(void) const
Definition: SortedObjects.h:41
virtual bool IsLast(void) const
Definition: SortedObjects.h:42
virtual unsigned int NextCount(void) const
Definition: SortedObjects.h:46
std::vector< pma::SortedObjectBase * > next_vector
Definition: SortedObjects.h:88
virtual int RemoveNext(pma::SortedObjectBase *nextElement)
SortedBranchBase(const pma::SortedBranchBase &src)
Note: copy constructor does not preserve connections.
Definition: SortedObjects.h:70
SortedBranchBase(pma::SortedObjectBase *prevElement, pma::SortedObjectBase *nextElement=0)
Definition: SortedObjects.h:64
virtual pma::SortedObjectBase * Next(unsigned int index=0) const
Definition: SortedObjects.h:79
virtual bool IsLast(void) const
Definition: SortedObjects.h:85
virtual ~SortedObjectBase(void)
Definition: SortedObjects.h:34
pma::SortedObjectBase * next
Definition: SortedObjects.h:53
virtual void Disconnect(void)
virtual bool AddNext(pma::SortedObjectBase *nextElement)
virtual ~SortedBranchBase(void)
Definition: SortedObjects.h:72
virtual pma::SortedObjectBase * Prev(void) const
Definition: SortedObjects.h:44
virtual pma::SortedObjectBase * Next(unsigned int index=0) const
Definition: SortedObjects.h:45
SortedObjectBase(const pma::SortedObjectBase &src)
Note: copy constructor does not preserve connections.
Definition: SortedObjects.h:32