Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

poolslot.inc
Go to the documentation of this file.
1 
29 #pragma once
30 
32 #include <ogdf/lib/abacus/pool.h>
33 #include <ogdf/lib/abacus/convar.h>
34 
35 namespace abacus {
36 
37 template<class BaseType, class CoType>
39  Master *master,
40  Pool<BaseType, CoType> *pool,
41  BaseType *convar) : master_(master), conVar_(convar), pool_(pool)
42 {
43  version_ = (convar) ? 1 : 0;
44 }
45 
46 
47 template<class BaseType, class CoType>
48 PoolSlot<BaseType, CoType>::~PoolSlot()
49 {
50 #ifdef OGDF_DEBUG
51  if (conVar_ && conVar_->nReferences()) {
52  Logger::ifout() << "~PoolSlot(): it is not allowed to destruct objects of class PoolSlot with a constraint/variable with positive reference counter = " << conVar_->nReferences() << ".\n";
53  }
54 
55 #ifndef OGDF_USE_ASSERT_EXCEPTIONS // do not throw exceptions in destructor
56  OGDF_ASSERT((conVar_ && conVar_->nReferences()) == false);
57 #endif
58 #endif
59 
60  delete conVar_;
61 }
62 
63 
64 template<class BaseType, class CoType>
65 void PoolSlot<BaseType, CoType>::insert(BaseType *convar)
66 {
67  if (conVar_ != nullptr) {
68  Logger::ifout() << "PoolSlot::insert(): insertion failed, the slot is not void\n";
69  OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::AlgorithmFailureCode::Poolslot);
70  }
71 
72  if (version_ == std::numeric_limits<unsigned long>::max()) {
73  Logger::ifout() << "PoolSlot::insert(): insertion failed, maximum version number ULONG_MAX reached\n";
74  OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::AlgorithmFailureCode::Poolslot);
75  }
76 
77  conVar_ = convar;
78  ++version_;
79 }
80 
81 }
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
convar.h
constraints and variables.
abacus
Definition: ILPClusterPlanarity.h:50
abacus::PoolSlot::PoolSlot
PoolSlot(Master *master, Pool< BaseType, CoType > *pool, BaseType *convar=0)
Creates a pool slot and inserts convar.
pool.h
OGDF_THROW_PARAM
#define OGDF_THROW_PARAM(CLASS, PARAM)
Replacement for throw.
Definition: exceptions.h:71
poolslot.h
poolslot.
ogdf::AlgorithmFailureCode::Poolslot
@ Poolslot