Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

poolslotref.h
Go to the documentation of this file.
1 
30 #pragma once
31 
33 #include <ogdf/lib/abacus/master.h>
36 
37 #pragma GCC visibility push(default)
38 namespace abacus {
39 
40 template<class BaseType, class CoType>
41 class PoolSlotRef;
42 
43 template<class BaseType, class CoType>
44 std::ostream &operator<< (std::ostream &out, const PoolSlotRef<BaseType, CoType> &slot);
45 
46 
48 
54 template<class BaseType, class CoType>
55 class PoolSlotRef : public AbacusRoot {
56 public:
57 
59 
62  PoolSlotRef(Master *master) : master_(master), slot_(0), version_(0) { }
63 
65 
72  {
73  ConVar *cv = slot_->conVar();
74  if(cv) cv->addReference();
75  }
76 
78 
87  {
88  ConVar *cv = slot_->conVar();
89  if (version_ == slot_->version() && cv)
90  cv->addReference();
91  }
92 
94 
104  if(slot_) {
105  ConVar *cv = slot_->conVar();
106  if (cv && version_ == slot_->version())
107  cv->removeReference();
108  }
109  }
110 
112 
121  friend std::ostream &operator<< <> (std::ostream &out, const PoolSlotRef<BaseType, CoType> &slot);
122 
124 
128  BaseType *conVar() const {
129  if(version_ == slot_->version())
130  return slot_->conVar();
132 
133  return nullptr;
134  }
135 
137  unsigned long version() const { return version_; }
138 
140  PoolSlot<BaseType, CoType> *slot() const { return slot_; }
141 
142 
144 
153 
154 private:
155 
157 
159 
161  unsigned long version_;
162 
163  void printDifferentVersionError() const;
164 
165 
168 
170 };
171 
172 }
173 
175 #pragma GCC visibility pop
abacus::ConVar::addReference
void addReference()
Indicates that there is a new reference to the pool slot storing this constraint/variable.
Definition: convar.h:359
abacus::PoolSlotRef
Stores a pointer to a pool slot with version number.
Definition: active.h:41
abacus::ConVar::removeReference
void removeReference()
Is the counterpart of the function addReference() and indicates the removal of a reference to this co...
Definition: convar.h:420
constraint.h
constraint.
abacus::PoolSlotRef::PoolSlotRef
PoolSlotRef(PoolSlot< BaseType, CoType > *slot)
Creates an object referencing a pool slot slot.
Definition: poolslotref.h:71
abacus::operator<<
std::ostream & operator<<(std::ostream &out, const Active< BaseType, CoType > &rhs)
abacus::PoolSlotRef::version
unsigned long version() const
Returns the version number of the constraint/variable stored in the referenced slot at construction t...
Definition: poolslotref.h:137
abacus::PoolSlotRef::~PoolSlotRef
~PoolSlotRef()
The destructor.
Definition: poolslotref.h:103
abacus
Definition: ILPClusterPlanarity.h:50
abacus::PoolSlotRef::conVar
BaseType * conVar() const
Returns a pointer to the constraint/variable stored in the referenced slot.
Definition: poolslotref.h:128
poolslotref.inc
abacus::PoolSlotRef::slot_
PoolSlot< BaseType, CoType > * slot_
A pointer to the referenced pool slot.
Definition: poolslotref.h:158
OGDF_NEW_DELETE
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition: memory.h:85
abacus::PoolSlotRef::PoolSlotRef
PoolSlotRef(const PoolSlotRef< BaseType, CoType > &rhs)
Copy constructor.
Definition: poolslotref.h:86
abacus::PoolSlotRef::version_
unsigned long version_
The version number of the slot at construction/initialization time of this reference.
Definition: poolslotref.h:161
abacus::ConVar
Common base class for constraints (Constraint) and variables (Variable).
Definition: convar.h:66
abacus::PoolSlotRef::operator=
const PoolSlotRef< BaseType, CoType > & operator=(const PoolSlotRef< BaseType, CoType > &rhs)
variable.h
variable.
abacus::PoolSlotRef::master_
Master * master_
A pointer to the corresponding master of the optimization.
Definition: poolslotref.h:156
master.h
the master of the optimization.
poolslot.h
poolslot.
abacus::PoolSlot
Stores constraints and variables.
Definition: active.h:40
abacus::PoolSlotRef::printDifferentVersionError
void printDifferentVersionError() const
abacus::PoolSlotRef::slot
PoolSlot< BaseType, CoType > * slot() const
Returns a pointer to the referenced slot.
Definition: poolslotref.h:140
abacus::Master
The master of the optimization.
Definition: master.h:70
abacus::PoolSlotRef::PoolSlotRef
PoolSlotRef(Master *master)
Creates an object referencing no pool slot.
Definition: poolslotref.h:62