aGrUM  0.16.0
variableNodeMap.h
Go to the documentation of this file.
1 
29 #ifndef GUM_VARIABLE_NODE_MAP_H
30 #define GUM_VARIABLE_NODE_MAP_H
31 
32 #include <iostream>
33 #include <string>
34 
35 #include <agrum/agrum.h>
36 
37 #include <agrum/core/bijection.h>
40 
41 namespace gum {
42 
51  public:
53 
55 
58 
61  VariableNodeMap(const VariableNodeMap& source);
62 
65 
68 
70 
71  // ===========================================================================
73  // ===========================================================================
75 
77 
78  const DiscreteVariable& get(NodeId id) const;
79 
81 
82  NodeId get(const DiscreteVariable& var) const;
83 
85  bool exists(NodeId id) const;
86 
88  bool exists(const DiscreteVariable& var) const;
89 
91 
96  NodeId insert(NodeId id, const DiscreteVariable& var);
97 
99 
100  void erase(NodeId id);
101 
103 
104  void erase(const DiscreteVariable& var);
105 
107 
109  void changeName(NodeId id, const std::string& new_name);
110 
112  void clear();
113 
115  const std::string toString() const;
116 
123  const std::string& name(NodeId id) const;
124 
131  const std::string& name(const DiscreteVariable& var) const;
132 
134 
135  // ===========================================================================
137  // ===========================================================================
139 
141 
142  const DiscreteVariable& operator[](NodeId id) const;
143 
145 
146  NodeId operator[](const DiscreteVariable& var) const;
147 
149 
150  // ===========================================================================
152  // ===========================================================================
154 
156  NodeId idFromName(const std::string& name) const;
157  const DiscreteVariable& variableFromName(const std::string& name) const;
158 
160 
161  private:
163  void __copy(const VariableNodeMap& source);
164 
167 
170  };
171 
173 
174  std::ostream& operator<<(std::ostream&, const VariableNodeMap&);
175 
176 } /* namespace gum */
177 
178 #ifndef GUM_NO_INLINE
180 #endif /* GUM_NO_INLINE */
181 
182 #endif /* GUM_VARIABLE_NODE_MAP_H*/
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __copy(const VariableNodeMap &source)
effectively do the copy (for copy constructor or operator=)
const std::string & name(NodeId id) const
Returns the name of a variable given its id.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Bijection< NodeId, const DiscreteVariable *> __nodes2vars
Bijection between the node&#39;s NodeIds and the variables.
NodeId insert(NodeId id, const DiscreteVariable &var)
Maps id with var.
VariableNodeMap()
Default constructor.
Container used to map discrete variables with nodes.
bool exists(NodeId id) const
Return true if id matches a node.
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
void erase(NodeId id)
Removes a var and it&#39;s id of this mapping. The pointer is deleted.
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:605
void clear()
removes all the associations
const DiscreteVariable & operator[](NodeId id) const
Returns a discrete variable given it&#39;s node id.
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1805
NodeId idFromName(const std::string &name) const
void changeName(NodeId id, const std::string &new_name)
we allow the user to change the name of a variable
VariableNodeMap & operator=(const VariableNodeMap &source)
Copy operator.
const std::string toString() const
friendly displays the content of the VariableNodeMap
Bijection< std::string, NodeId > __names2nodes
HashTable for easely find an id from a name.
~VariableNodeMap()
Destructor.
const DiscreteVariable & variableFromName(const std::string &name) const
Size NodeId
Type for node ids.
Definition: graphElements.h:98
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.