Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
poolslotref.h
Go to the documentation of this file.
1
30#pragma once
31
36
37#pragma GCC visibility push(default)
38namespace abacus {
39
40template<class BaseType, class CoType>
41class PoolSlotRef;
42
43template<class BaseType, class CoType>
44std::ostream &operator<< (std::ostream &out, const PoolSlotRef<BaseType, CoType> &slot);
45
46
48
54template<class BaseType, class CoType>
55class PoolSlotRef : public AbacusRoot {
56public:
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
141
142
144
153
154private:
155
157
159
161 unsigned long version_;
162
164
165
168
170};
171
172}
173
175#pragma GCC visibility pop
Base class of all other classes of ABACUS.
Definition abacusroot.h:69
Common base class for constraints (Constraint) and variables (Variable).
Definition convar.h:66
void addReference()
Indicates that there is a new reference to the pool slot storing this constraint/variable.
Definition convar.h:359
void removeReference()
Is the counterpart of the function addReference() and indicates the removal of a reference to this co...
Definition convar.h:420
The master of the optimization.
Definition master.h:70
Stores constraints and variables.
Definition poolslot.h:78
Stores a pointer to a pool slot with version number.
Definition poolslotref.h:55
BaseType * conVar() const
Returns a pointer to the constraint/variable stored in the referenced slot.
PoolSlotRef(Master *master)
Creates an object referencing no pool slot.
Definition poolslotref.h:62
Master * master_
A pointer to the corresponding master of the optimization.
~PoolSlotRef()
The destructor.
const PoolSlotRef< BaseType, CoType > & operator=(const PoolSlotRef< BaseType, CoType > &rhs)
unsigned long version_
The version number of the slot at construction/initialization time of this reference.
PoolSlotRef(const PoolSlotRef< BaseType, CoType > &rhs)
Copy constructor.
Definition poolslotref.h:86
void printDifferentVersionError() const
PoolSlot< BaseType, CoType > * slot_
A pointer to the referenced pool slot.
PoolSlot< BaseType, CoType > * slot() const
Returns a pointer to the referenced slot.
PoolSlotRef(PoolSlot< BaseType, CoType > *slot)
Creates an object referencing a pool slot slot.
Definition poolslotref.h:71
void slot(PoolSlot< BaseType, CoType > *s)
Initializes the referenced pool slot with s.
unsigned long version() const
Returns the version number of the constraint/variable stored in the referenced slot at construction t...
constraint.
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition memory.h:85
the master of the optimization.
std::ostream & operator<<(std::ostream &out, const Active< BaseType, CoType > &rhs)
poolslot.
variable.