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 #pragma GCC visibility push(default)
36 namespace abacus {
37 
38 template<class BaseType, class CoType>
40  Master *master,
41  Pool<BaseType, CoType> *pool,
42  BaseType *convar) : master_(master), conVar_(convar), pool_(pool)
43 {
44  version_ = (convar) ? 1 : 0;
45 }
46 
47 
48 template<class BaseType, class CoType>
49 PoolSlot<BaseType, CoType>::~PoolSlot()
50 {
51 #ifdef OGDF_DEBUG
52  if (conVar_ && conVar_->nReferences()) {
53  Logger::ifout() << "~PoolSlot(): it is not allowed to destruct objects of class PoolSlot with a constraint/variable with positive reference counter = " << conVar_->nReferences() << ".\n";
54  }
55 
56 #ifndef OGDF_USE_ASSERT_EXCEPTIONS // do not throw exceptions in destructor
57  OGDF_ASSERT((conVar_ && conVar_->nReferences()) == false);
58 #endif
59 #endif
60 
61  delete conVar_;
62 }
63 
64 
65 template<class BaseType, class CoType>
66 void PoolSlot<BaseType, CoType>::insert(BaseType *convar)
67 {
68  if (conVar_ != nullptr) {
69  Logger::ifout() << "PoolSlot::insert(): insertion failed, the slot is not void\n";
70  OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::AlgorithmFailureCode::Poolslot);
71  }
72 
73  if (version_ == std::numeric_limits<unsigned long>::max()) {
74  Logger::ifout() << "PoolSlot::insert(): insertion failed, maximum version number ULONG_MAX reached\n";
75  OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::AlgorithmFailureCode::Poolslot);
76  }
77 
78  conVar_ = convar;
79  ++version_;
80 }
81 
82 }
83 #pragma GCC visibility pop
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