26 #ifndef DOXYGEN_SHOULD_SKIP_THIS 38 template <
typename GUM_SCALAR >
40 static Idx __abstract_id = 0;
41 return ++__abstract_id;
45 template <
typename GUM_SCALAR >
46 HashTable< Idx, const MultiDimImplementation< GUM_SCALAR >* >&
48 static HashTable< Idx, const MultiDimImplementation< GUM_SCALAR >* >
50 # ifdef GUM_DEBUG_MODE 54 static bool first_time =
true;
58 __debug__::__inc_deletion(
59 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)&__multidims);
67 template <
typename GUM_SCALAR >
68 HashTable< const MultiDimImplementation< GUM_SCALAR >*,
Idx >&
70 static HashTable< const MultiDimImplementation< GUM_SCALAR >*,
Idx >
72 # ifdef GUM_DEBUG_MODE 76 static bool first_time =
true;
80 __debug__::__inc_deletion(
81 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)&__multidim_ids);
85 return __multidim_ids;
89 template <
typename GUM_SCALAR >
92 # ifdef GUM_DEBUG_MODE 96 static bool first_time =
true;
100 __debug__::__inc_deletion(
101 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)&__ids);
109 template <
typename GUM_SCALAR >
110 HashTable< Idx, const Sequence< const DiscreteVariable* >* >&
112 static HashTable< Idx, const Sequence< const DiscreteVariable* >* > __vars;
113 # ifdef GUM_DEBUG_MODE 117 static bool first_time =
true;
121 __debug__::__inc_deletion(
122 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)&__vars);
130 template <
typename GUM_SCALAR >
132 static HashTable< Idx, Size > __size;
133 # ifdef GUM_DEBUG_MODE 137 static bool first_time =
true;
141 __debug__::__inc_deletion(
142 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)&__size);
150 template <
typename GUM_SCALAR >
152 const MultiDimImplementation< GUM_SCALAR >& multidim) {
154 GUM_CONSTRUCTOR(ScheduleMultiDim);
158 if (__multidim2id().exists(&multidim)) {
160 __id = __multidim2id().operator[](&multidim);
170 __id2multidim().insert(__id, &multidim);
171 __multidim2id().insert(&multidim, __id);
174 __id2refs().insert(__id, 1);
177 const Sequence< const DiscreteVariable* >* vars =
178 new Sequence< const DiscreteVariable* >(multidim.variablesSequence());
179 __id2vars().insert(__id, vars);
182 __id2size().insert(__id, multidim.domainSize());
187 template <
typename GUM_SCALAR >
189 const MultiDimDecorator< GUM_SCALAR >& multidim) {
191 GUM_CONSTRUCTOR(ScheduleMultiDim);
193 const MultiDimImplementation< GUM_SCALAR >* impl = multidim.content();
197 if (__multidim2id().exists(impl)) {
199 __id = __multidim2id().operator[](impl);
209 __id2multidim().insert(__id, impl);
210 __multidim2id().insert(impl, __id);
213 __id2refs().insert(__id, 1);
216 const Sequence< const DiscreteVariable* >* vars =
217 new Sequence< const DiscreteVariable* >(multidim.variablesSequence());
218 __id2vars().insert(__id, vars);
221 __id2size().insert(__id, multidim.domainSize());
226 template <
typename GUM_SCALAR >
228 const Sequence< const DiscreteVariable* >& vars) :
237 const Sequence< const DiscreteVariable* >* new_vars =
238 new Sequence< const DiscreteVariable* >(vars);
244 for (
const auto var : *new_vars)
245 size *= var->domainSize();
251 template <
typename GUM_SCALAR >
253 const ScheduleMultiDim< GUM_SCALAR >& from) :
264 template <
typename GUM_SCALAR >
290 template <
typename GUM_SCALAR >
292 operator=(
const ScheduleMultiDim< GUM_SCALAR >& from) {
294 if (
__id != from.__id) {
323 template <
typename GUM_SCALAR >
325 operator==(
const ScheduleMultiDim< GUM_SCALAR >& m)
const {
326 return (
__id == m.__id);
330 template <
typename GUM_SCALAR >
332 operator!=(
const ScheduleMultiDim< GUM_SCALAR >& m)
const {
333 return (
__id != m.__id);
338 template <
typename GUM_SCALAR >
339 INLINE
const MultiDimImplementation< GUM_SCALAR >&
346 template <
typename GUM_SCALAR >
352 template <
typename GUM_SCALAR >
358 template <
typename GUM_SCALAR >
359 INLINE
const Sequence< const DiscreteVariable* >&
365 template <
typename GUM_SCALAR >
371 template <
typename GUM_SCALAR >
373 const MultiDimImplementation< GUM_SCALAR >& m) {
380 "the multidim table has already been " 381 "wrapped into a ScheduleMultidim with another id");
390 const MultiDimImplementation< GUM_SCALAR >* impl =
393 if (impl == &m)
return;
406 const Sequence< const DiscreteVariable* >& m_vars = m.variablesSequence();
407 Sequence< const DiscreteVariable* >* vars =
408 const_cast< Sequence< const DiscreteVariable* >*
>(
418 template <
typename GUM_SCALAR >
420 const MultiDimDecorator< GUM_SCALAR >& m) {
425 template <
typename GUM_SCALAR >
427 std::stringstream str;
434 }
catch (NotFound&) { str <<
__id; }
const Sequence< const DiscreteVariable *> & variablesSequence() const
returns the set of variables involved in the multidim
static HashTable< const MultiDimImplementation< GUM_SCALAR > *, Idx > & __multidim2id()
returns the id corresponding to a given multidim
a MultiDimImplementation Wrapper used for scheduling inferences
ScheduleMultiDim(const MultiDimImplementation< GUM_SCALAR > &)
constructs a ScheduleMultiDim containing an already built implementation
std::string toString() const
displays the content of the multidim
bool isAbstract() const
returns whether the ScheduleMultiDim contains a real multiDimImplementation
Idx id() const
returns the id of the ScheduleMultiDim
void erase(const Key &key)
Removes a given element from the hash table.
Size domainSize() const
returns the domain size of the multidim
gum is the global namespace for all aGrUM entities
bool operator!=(const ScheduleMultiDim< GUM_SCALAR > &) const
checks whether two ScheduleMultiDim are related to different tables
ScheduleMultiDim< GUM_SCALAR > & operator=(const ScheduleMultiDim< GUM_SCALAR > &)
copy operator
~ScheduleMultiDim()
destructor
const MultiDimImplementation< GUM_SCALAR > & multiDim() const
returns the multiDimImplementation actually contained in the ScheduleMultiDim
static HashTable< Idx, const Sequence< const DiscreteVariable *> *> & __id2vars()
returns a table with the variables of the table corresponding to id
static HashTable< Idx, Idx > & __id2refs()
returns a table indicating how many ScheduleMultiDim have the same id
static Idx __newId()
returns a new distinct ID for each abtract scheduleMultiDim
static HashTable< Idx, Size > & __id2size()
returns a table with the domain size of the table corresponding to id
Idx __id
the unique Id of the ScheduleMultiDim
static HashTable< Idx, const MultiDimImplementation< GUM_SCALAR > *> & __id2multidim()
returns a mapping from id to multidimImplementations
std::size_t Size
In aGrUM, hashed values are unsigned long int.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
void setMultiDim(const MultiDimImplementation< GUM_SCALAR > &)
sets a new multiDimImplementation inside the wrapper
bool operator==(const ScheduleMultiDim< GUM_SCALAR > &) const
checks whether two ScheduleMultiDim are related to the same table
#define GUM_ERROR(type, msg)