Public Member Functions | Protected Attributes | List of all members
pma::SortedBranchBase Class Reference

#include <SortedObjects.h>

Inheritance diagram for pma::SortedBranchBase:
pma::SortedObjectBase pma::Node3D

Public Member Functions

 SortedBranchBase (void)
 
 SortedBranchBase (pma::SortedObjectBase *prevElement, pma::SortedObjectBase *nextElement=0)
 
 SortedBranchBase (const pma::SortedBranchBase &src)
 Note: copy constructor does not preserve connections. More...
 
virtual ~SortedBranchBase (void)
 
virtual void Disconnect (void)
 
virtual bool AddNext (pma::SortedObjectBase *nextElement)
 
virtual int RemoveNext (pma::SortedObjectBase *nextElement)
 
virtual pma::SortedObjectBaseNext (unsigned int index=0) const
 
virtual unsigned int NextCount (void) const
 
virtual bool IsLast (void) const
 
- Public Member Functions inherited from pma::SortedObjectBase
 SortedObjectBase (void)
 
 SortedObjectBase (pma::SortedObjectBase *prevElement, pma::SortedObjectBase *nextElement)
 
 SortedObjectBase (const pma::SortedObjectBase &src)
 Note: copy constructor does not preserve connections. More...
 
virtual ~SortedObjectBase (void)
 
virtual bool IsFirst (void) const
 
virtual pma::SortedObjectBasePrev (void) const
 

Protected Attributes

std::vector< pma::SortedObjectBase * > next_vector
 
- Protected Attributes inherited from pma::SortedObjectBase
pma::SortedObjectBasenext
 
pma::SortedObjectBaseprev
 

Detailed Description

Base for classes, where a single object is assigned to Prev() and many objects may be assigned to Next().

Definition at line 60 of file SortedObjects.h.

Constructor & Destructor Documentation

pma::SortedBranchBase::SortedBranchBase ( void  )
inline

Definition at line 63 of file SortedObjects.h.

pma::SortedBranchBase::SortedBranchBase ( pma::SortedObjectBase prevElement,
pma::SortedObjectBase nextElement = 0 
)
inline

Definition at line 64 of file SortedObjects.h.

64  :
65  pma::SortedObjectBase(prevElement, nextElement)
66  {
67  if (nextElement) next_vector.push_back(next);
68  }
std::vector< pma::SortedObjectBase * > next_vector
Definition: SortedObjects.h:88
pma::SortedObjectBase * next
Definition: SortedObjects.h:53
pma::SortedBranchBase::SortedBranchBase ( const pma::SortedBranchBase src)
inline

Note: copy constructor does not preserve connections.

Definition at line 70 of file SortedObjects.h.

virtual pma::SortedBranchBase::~SortedBranchBase ( void  )
inlinevirtual

Definition at line 72 of file SortedObjects.h.

72 { Disconnect(); }
virtual void Disconnect(void)

Member Function Documentation

bool pma::SortedBranchBase::AddNext ( pma::SortedObjectBase nextElement)
virtual

Reimplemented from pma::SortedObjectBase.

Definition at line 70 of file SortedObjects.cxx.

71 {
72  if (!nextElement)
73  {
74  mf::LogError("pma::SortedBranchBase") << "Next == 0.";
75  return false;
76  }
77 
78  if (nextElement == this)
79  {
80  mf::LogWarning("pma::SortedBranchBase") << "Next == This.";
81  return false;
82  }
83 
84  bool present = false;
85  for (size_t i = 0; i < next_vector.size(); i++)
86  {
87  if (next_vector[i] == nextElement)
88  {
89  mf::LogWarning("pma::SortedBranchBase") << "Contained.";
90  present = true; break;
91  }
92  }
93  if (!present)
94  {
95  if (nextElement->prev) // && (nextElement->prev != this)
96  nextElement->prev->RemoveNext(nextElement);
97 
98  next = nextElement;
99  next->prev = this;
100  next_vector.push_back(next);
101  return true;
102  }
103  else return false;
104 }
pma::SortedObjectBase * prev
Definition: SortedObjects.h:54
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::vector< pma::SortedObjectBase * > next_vector
Definition: SortedObjects.h:88
virtual int RemoveNext(pma::SortedObjectBase *nextElement)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
pma::SortedObjectBase * next
Definition: SortedObjects.h:53
constexpr ProductStatus present() noexcept
Definition: ProductStatus.h:10
void pma::SortedBranchBase::Disconnect ( void  )
virtual

Reimplemented from pma::SortedObjectBase.

Definition at line 64 of file SortedObjects.cxx.

65 {
66  while (next_vector.size()) RemoveNext(next_vector.front());
67  if (prev) prev->RemoveNext(this);
68 }
virtual int RemoveNext(pma::SortedObjectBase *nextElement)
pma::SortedObjectBase * prev
Definition: SortedObjects.h:54
std::vector< pma::SortedObjectBase * > next_vector
Definition: SortedObjects.h:88
virtual int RemoveNext(pma::SortedObjectBase *nextElement)
virtual bool pma::SortedBranchBase::IsLast ( void  ) const
inlinevirtual

Reimplemented from pma::SortedObjectBase.

Definition at line 85 of file SortedObjects.h.

85 { return !(next_vector.size()); }
std::vector< pma::SortedObjectBase * > next_vector
Definition: SortedObjects.h:88
virtual pma::SortedObjectBase* pma::SortedBranchBase::Next ( unsigned int  index = 0) const
inlinevirtual

Reimplemented from pma::SortedObjectBase.

Definition at line 79 of file SortedObjects.h.

80  {
81  if (next_vector.size()) return next_vector[index];
82  else return 0;
83  }
std::vector< pma::SortedObjectBase * > next_vector
Definition: SortedObjects.h:88
virtual unsigned int pma::SortedBranchBase::NextCount ( void  ) const
inlinevirtual

Reimplemented from pma::SortedObjectBase.

Definition at line 84 of file SortedObjects.h.

84 { return next_vector.size(); }
std::vector< pma::SortedObjectBase * > next_vector
Definition: SortedObjects.h:88
int pma::SortedBranchBase::RemoveNext ( pma::SortedObjectBase nextElement)
virtual

Reimplemented from pma::SortedObjectBase.

Definition at line 106 of file SortedObjects.cxx.

107 {
108  if (!nextElement || (nextElement == this)) return -1;
109 
110  int index = -1;
111  for (unsigned int i = 0; i < next_vector.size(); i++)
112  {
113  if (next_vector[i] == nextElement) { index = i; break; }
114  }
115  if (index >= 0)
116  {
117  if (next_vector[index]->prev != this)
118  {
119  mf::LogError("pma::SortedBranchBase") << "Object structure is broken.";
120  return -1;
121  }
122  next_vector[index]->prev = 0;
123  next_vector.erase(next_vector.begin() + index);
124 
125  if (next_vector.size() > 0) next = next_vector.back();
126  else next = 0;
127  }
128  return index;
129 }
pma::SortedObjectBase * prev
Definition: SortedObjects.h:54
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::vector< pma::SortedObjectBase * > next_vector
Definition: SortedObjects.h:88
pma::SortedObjectBase * next
Definition: SortedObjects.h:53

Member Data Documentation

std::vector< pma::SortedObjectBase* > pma::SortedBranchBase::next_vector
protected

Definition at line 88 of file SortedObjects.h.


The documentation for this class was generated from the following files: