Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

abacus::PoolSlotRef< BaseType, CoType > Class Template Reference

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

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

Public Member Functions

 PoolSlotRef (const PoolSlotRef< BaseType, CoType > &rhs)
 Copy constructor. More...
 
 PoolSlotRef (Master *master)
 Creates an object referencing no pool slot. More...
 
 PoolSlotRef (PoolSlot< BaseType, CoType > *slot)
 Creates an object referencing a pool slot slot. More...
 
 ~PoolSlotRef ()
 The destructor. More...
 
BaseType * conVar () const
 Returns a pointer to the constraint/variable stored in the referenced slot. More...
 
PoolSlot< BaseType, CoType > * slot () const
 Returns a pointer to the referenced slot. More...
 
void slot (PoolSlot< BaseType, CoType > *s)
 Initializes the referenced pool slot with s. More...
 
unsigned long version () const
 Returns the version number of the constraint/variable stored in the referenced slot at construction time. More...
 

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. More...
 
PoolSlot< BaseType, CoType > * slot_
 A pointer to the referenced pool slot. More...
 
unsigned long version_
 The version number of the slot at construction/initialization time of this reference. More...
 

Friends

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

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 40 of file active.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()

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

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=()

template<class BaseType , class CoType >
const PoolSlotRef<BaseType, CoType>& abacus::PoolSlotRef< BaseType, CoType >::operator= ( const PoolSlotRef< BaseType, CoType > &  rhs)
private

◆ 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]

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

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 Function 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_

template<class BaseType , class CoType >
PoolSlot<BaseType, CoType>* abacus::PoolSlotRef< BaseType, CoType >::slot_
private

A pointer to the referenced pool slot.

Definition at line 157 of file poolslotref.h.

◆ version_

template<class BaseType , class CoType >
unsigned long abacus::PoolSlotRef< BaseType, CoType >::version_
private

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: