Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
abacus::PoolSlotRef< BaseType, CoType > Class Template Reference

Stores a pointer to a pool slot with version number. More...

#include <ogdf/lib/abacus/poolslotref.h>

+ Inheritance diagram for abacus::PoolSlotRef< BaseType, CoType >:

Public Member Functions

 PoolSlotRef (const PoolSlotRef< BaseType, CoType > &rhs)
 Copy constructor.
 
 PoolSlotRef (Master *master)
 Creates an object referencing no pool slot.
 
 PoolSlotRef (PoolSlot< BaseType, CoType > *slot)
 Creates an object referencing a pool slot slot.
 
 ~PoolSlotRef ()
 The destructor.
 
BaseTypeconVar () const
 Returns a pointer to the constraint/variable stored in the referenced slot.
 
PoolSlot< BaseType, CoType > * slot () const
 Returns a pointer to the referenced slot.
 
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 time.
 
- Public Member Functions inherited from abacus::AbacusRoot
virtual ~AbacusRoot ()
 The destructor.
 

Private Member Functions

const PoolSlotRef< BaseType, CoType > & operator= (const PoolSlotRef< BaseType, CoType > &rhs)
 
void printDifferentVersionError () const
 

Private Attributes

Mastermaster_
 A pointer to the corresponding master of the optimization.
 
PoolSlot< BaseType, CoType > * slot_
 A pointer to the referenced pool slot.
 
unsigned long version_
 The version number of the slot at construction/initialization time of this reference.
 

Friends

std::ostream & operator<< (std::ostream &out, const PoolSlotRef< BaseType, CoType > &slot)
 Output operator for pool slot references.
 

Additional Inherited Members

- Static Public Member Functions inherited from abacus::AbacusRoot
static bool ascii2bool (const string &str)
 Converts the string str to a boolean value.
 
static bool endsWith (const string &str, const string &end)
 Returns true if str ends with end, false otherwise.
 
static double fracPart (double x)
 Returns the absolute value of the fractional part of x.
 
static const charonOff (bool value)
 Converts a boolean variable to the strings "on" and "off".
 

Detailed Description

template<class BaseType, class CoType>
class abacus::PoolSlotRef< BaseType, CoType >

Stores a pointer to a pool slot with version number.

As already explained in the class PoolSlot we do not refer directly to constraints/variables but store a pointer to a pool slot and memorize the version number of the slot at initialization time of the class PoolSlotRef.

Definition at line 54 of file poolslotref.h.

Constructor & Destructor Documentation

◆ PoolSlotRef() [1/3]

template<class BaseType , class CoType >
abacus::PoolSlotRef< BaseType, CoType >::PoolSlotRef ( Master master)
inline

Creates an object referencing no pool slot.

Parameters
masterA pointer to the corresponding master of the optimization.

Definition at line 61 of file poolslotref.h.

◆ PoolSlotRef() [2/3]

template<class BaseType , class CoType >
abacus::PoolSlotRef< BaseType, CoType >::PoolSlotRef ( PoolSlot< BaseType, CoType > *  slot)
inline

Creates an object referencing a pool slot slot.

Also the constraint/variable contained in this slot receives a message that a new references to it is created.

Parameters
slotThe pool slot that is referenced now.

Definition at line 70 of file poolslotref.h.

◆ PoolSlotRef() [3/3]

template<class BaseType , class CoType >
abacus::PoolSlotRef< BaseType, CoType >::PoolSlotRef ( const PoolSlotRef< BaseType, CoType > &  rhs)
inline

Copy constructor.

May increment the reference counter of the constraint/variable only if version number of the slot and version number of the reference are equal, since otherwise this is not a correct reference to slot_->conVar().

Parameters
rhsThe pool slot that is copied in the initialization process.

Definition at line 85 of file poolslotref.h.

◆ ~PoolSlotRef()

The destructor.

Sends a message to the constraint that it will no longer be referred from this place in the program.

If the version number of the reference and the version number of the slot do not equal, we must not decrement the reference counter of slot_->conVar() because this is not a correct reference to this constraint/variable.

Definition at line 102 of file poolslotref.h.

Member Function Documentation

◆ conVar()

template<class BaseType , class CoType >
BaseType * abacus::PoolSlotRef< BaseType, CoType >::conVar ( ) const
inline

Returns a pointer to the constraint/variable stored in the referenced slot.

If the version number of the slot differs from the version number at construction/initialization time of this slot 0 is returned.

Definition at line 127 of file poolslotref.h.

◆ operator=()

◆ printDifferentVersionError()

template<class BaseType , class CoType >
void abacus::PoolSlotRef< BaseType, CoType >::printDifferentVersionError ( ) const
private

◆ slot() [1/2]

template<class BaseType , class CoType >
PoolSlot< BaseType, CoType > * abacus::PoolSlotRef< BaseType, CoType >::slot ( ) const
inline

Returns a pointer to the referenced slot.

Definition at line 139 of file poolslotref.h.

◆ slot() [2/2]

Initializes the referenced pool slot with s.

The function slot() may decrement the reference counter of slot_->conVar() only if the version number of the reference and the version number of the slot are equal since otherwise this is not a valid reference.

Parameters
sThe new slot that is referenced. This must not be a 0-pointer.

◆ version()

template<class BaseType , class CoType >
unsigned long abacus::PoolSlotRef< BaseType, CoType >::version ( ) const
inline

Returns the version number of the constraint/variable stored in the referenced slot at construction time.

Definition at line 136 of file poolslotref.h.

Friends And Related Symbol Documentation

◆ operator<<

template<class BaseType , class CoType >
std::ostream & operator<< ( std::ostream &  out,
const PoolSlotRef< BaseType, CoType > &  slot 
)
friend

Output operator for pool slot references.

The output operator writes the constraint/variable stored in the referenced slot to an output stream.

Parameters
outThe output stream.
slotThe reference to a pool slot being output.
Returns
A reference to the output stream.

Member Data Documentation

◆ master_

template<class BaseType , class CoType >
Master* abacus::PoolSlotRef< BaseType, CoType >::master_
private

A pointer to the corresponding master of the optimization.

Definition at line 155 of file poolslotref.h.

◆ slot_

A pointer to the referenced pool slot.

Definition at line 157 of file poolslotref.h.

◆ version_

The version number of the slot at construction/initialization time of this reference.

Definition at line 160 of file poolslotref.h.


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