73 GUM_ASSERT(master !=
nullptr);
80 for (
const auto var: v)
158 std::stringstream sstr;
167 for (
const auto var:
_vars_) {
168 if (!first) sstr <<
"|";
171 sstr << var->name() <<
":" << var->label(
val(*var));
183 for (
const auto var:
_vars_)
192 for (
const auto& elt: map) {
Base class for discrete random variable.
The class for generic Hash Tables.
Class for assigning/browsing values to tuples of discrete variables.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
void synchronizeWithMaster(const MultiDimAdressable *m)
Force the variables sequence to be the same as the master one.
void _masterIncNotification_() const
Sequence< const DiscreteVariable * > _vars_
The tuple of variables to be instantiated.
bool actAsSlave(MultiDimAdressable &aMD)
Tries to register the Instantiation to a MultiDimAdressable.
bool isMaster(const MultiDimAdressable *m) const
Indicates whether m is the master of this instantiation.
void _masterFirstNotification_() const
Instantiation & setVals(const Instantiation &i)
Assign the values from i in the Instantiation.
std::vector< Idx > _vals_
The current instantiation: the value of the tuple.
bool _overflow_
Indicates whether the current value of the tuple is valid when we loop sufficiently over values of th...
void _reorder_(const Sequence< const DiscreteVariable * > &v)
Reorder vars of this instantiation giving the order in v.
bool contains(const DiscreteVariable &v) const final
Indicates whether a given variable belongs to the Instantiation.
Instantiation()
Default constructor: creates an empty tuple.
MultiDimAdressable * _master_
The master, if any, contains precisely the set of variables to be instantiated.
void _init_(MultiDimAdressable *master)
Initialize this Instantiation.
~Instantiation()
Destructor.
Idx hamming() const
Returns the hamming distance of this instantiation.
void _erase_(const DiscreteVariable &v)
Removes a variable from the sequence of vars.
void _masterLastNotification_() const
void _add_(const DiscreteVariable &v)
Adds a new var to the sequence of vars.
void _masterDecNotification_() const
Idx val(Idx i) const
Returns the current value of the variable at position i.
void setValsFrom(const HashTable< const DiscreteVariable *, const DiscreteVariable * > &map, const Instantiation &external)
Assign the values of external in *this, using map as a bijection between external and this variables.
void _masterChangeNotification_(Idx varPos, Idx newVal, Idx oldVal) const
std::string toString() const
Give a string version of instantiation.
const DiscreteVariable & variable(Idx i) const final
Returns the variable at position i in the tuple.
Idx nbrDim() const final
Returns the number of variables in the Instantiation.
bool forgetMaster()
Deassociate the master MultiDimAdressable, if any.
void eraseWithMaster(const MultiDimAdressable *m, const DiscreteVariable &v)
Call Instantiation:: erase(const DiscreteVariable&) by master.
Instantiation & operator=(const Instantiation &aI)
Copy operator.
Abstract base class for all multi dimensionnal addressable.
virtual bool registerSlave(Instantiation &i)=0
Register i as a slave of this MultiDimAdressable.
virtual MultiDimAdressable & getMasterRef()=0
In order to insure the dereference for decorators, we need to virtualize the access to master pointer...
Interface for all classes addressing in a multiDim fashion.
virtual const Sequence< const DiscreteVariable * > & variablesSequence() const =0
Returns a const ref to the sequence of DiscreteVariable*.
Exception : the element we looked for cannot be found.
Exception : operation not allowed.
Size size() const noexcept
Returns the size of the sequence.
The generic class for storing (ordered) sequences of objects.
const std::string & name() const
returns the name of the variable
#define GUM_ERROR(type, msg)
Size Idx
Type for indexes.
Header files of gum::Instantiation.
Inline implemenation of gum::Instantiation.
Headers for the abstract base class for all multi dimensionnal containers.
gum is the global namespace for all aGrUM entities
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree