aGrUM  0.14.2
multiDimInterface.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 #ifndef GUM_MULTIDIM_INTERFACE_H
28 #define GUM_MULTIDIM_INTERFACE_H
29 
30 #include <iostream>
31 #include <vector>
32 
33 #include <agrum/agrum.h>
34 
35 #include <agrum/core/list.h>
36 #include <agrum/core/sequence.h>
37 
39 
40 namespace gum {
41 
42 #ifndef DOXYGEN_SHOULD_SKIP_THIS
43  // Forward declaration.
44  class Instantiation;
45 #endif
46 
47  // ==========================================================================
48  // === MULTIDIM INTERFACE ===
49  // ==========================================================================
63  public:
68  virtual ~MultiDimInterface(){};
69 
70  // =========================================================================
72  // =========================================================================
74 
79  virtual Idx nbrDim() const = 0;
80 
85  virtual Size domainSize() const = 0;
86 
101  virtual void add(const DiscreteVariable& v) = 0;
102 
110  virtual void erase(const DiscreteVariable& v) = 0;
111 
117  variablesSequence() const = 0;
118 
126  virtual const DiscreteVariable& variable(Idx i) const = 0;
127 
136  virtual const DiscreteVariable& variable(const std::string& name) const = 0;
137 
144  virtual Idx pos(const DiscreteVariable& v) const = 0;
145 
151  virtual bool contains(const DiscreteVariable& v) const = 0;
152 
157  virtual bool empty() const = 0;
158 
171  void replace(const DiscreteVariable& x, const DiscreteVariable& y);
172 
174 
175  protected:
185  virtual void _replace(const DiscreteVariable* x,
186  const DiscreteVariable* y) = 0;
187  };
188 
208 
217 
218 } /* namespace gum */
219 
220 #ifndef GUM_NO_INLINE
222 #endif // GUM_NO_INLINE
223 
224 #endif /* GUM_MULTIDIM_INTERFACE_H */
virtual void add(const DiscreteVariable &v)=0
Adds a new var to the variables of the multidimensional matrix.
virtual bool empty() const =0
Returns true if no var is in *this.
virtual Idx nbrDim() const =0
Returns the number of vars in the multidimensional container.
virtual bool contains(const DiscreteVariable &v) const =0
Returns true if var is in *this.
Base class for discrete random variable.
Header file of gum::Sequence, a class for storing (ordered) sequences of objects. ...
Inline implementation of gumMultiDimInterface.
virtual const DiscreteVariable & variable(Idx i) const =0
Returns a const ref to the ith var.
The generic class for storing (ordered) sequences of objects.
Definition: sequence.h:1019
Interface for all classes addressing in a multiDim fashion.
Base class for discrete random variable.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map&#39;s DAG in output using the Graphviz-dot format.
Definition: BayesNet_tpl.h:583
Generic class for manipulating lists.
virtual Size domainSize() const =0
Returns the product of the variables domain size.
virtual ~MultiDimInterface()
Class destructor.
virtual Idx pos(const DiscreteVariable &v) const =0
Returns the index of a variable.
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y)=0
This is called by MultiDimContainer::replace() to proceed with the replacing between x and y...
void replace(const DiscreteVariable &x, const DiscreteVariable &y)
Replace variables in this multidim.
virtual void erase(const DiscreteVariable &v)=0
Removes a var from the variables of the multidimensional matrix.
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const =0
Returns a const ref to the sequence of DiscreteVariable*.
Size Idx
Type for indexes.
Definition: types.h:50
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
MultiDimInterface & operator>>(MultiDimInterface &c, const DiscreteVariable &v)
Removes a var from the variables of the MutliDimAdressing.