aGrUM  0.14.2
internalNode.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
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  ***************************************************************************/
20 
28 #ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_INTERNAL_NODE_H
29 #define GUM_MULTI_DIM_FUNCTION_GRAPH_INTERNAL_NODE_H
30 
31 #include <agrum/agrum.h>
36 
37 namespace gum {
38 
39  // clang-format off
47  // clang-format on
48  struct Parent {
51 
55  Parent(NodeId pi, Idx m);
56 
60  Parent(const Parent& src);
61 
62  // ============================================================================
64  // ============================================================================
66 
70  void* operator new(size_t s);
71 
75  void operator delete(void* p);
76 
78  // ============================================================================
80  // ============================================================================
82 
83  bool operator==(const Parent& comp) const;
84 
85  bool operator!=(const Parent& comp) const;
86 
87  Parent& operator=(const Parent& src);
89  };
90 
91  // clang-format off
99  // clang-format on
100  class InternalNode {
101  private:
104 
121 
124 
126  void __setNodeVar(const DiscreteVariable* v);
127 
128  public:
129  // ============================================================================
131  // ============================================================================
133 
138  InternalNode();
139 
146  explicit InternalNode(const DiscreteVariable* v);
147 
158  InternalNode(const DiscreteVariable* v, NodeId* sons);
159 
163  ~InternalNode();
165  // ============================================================================
167  // ============================================================================
169 
173  void* operator new(size_t s);
174 
178  void operator delete(void* p);
179 
181  // ============================================================================
183  // ============================================================================
185 
193  void setNode(const DiscreteVariable* v, NodeId* sons);
194 
196  // ============================================================================
198  // ============================================================================
200 
204  void setNodeVar(const DiscreteVariable* v);
205 
209  const DiscreteVariable* nodeVar() const;
210 
212  // ============================================================================
214  // ============================================================================
216 
220  void setSon(Idx modality, NodeId son);
221 
225  NodeId son(Idx modality) const;
226 
230  Idx nbSons() const;
231 
233  // ============================================================================
235  // ============================================================================
237 
241  void addParent(NodeId parent, Idx modality);
242 
246  void removeParent(NodeId parent, Idx modality);
247 
251  Link< Parent >* parents();
252 
256  const Link< Parent >* parents() const;
257 
259  // ============================================================================
261  // ============================================================================
263 
267  static NodeId* allocateNodeSons(const DiscreteVariable* v);
268 
272  static void deallocateNodeSons(const DiscreteVariable* v, NodeId* s);
273 
275  };
276 
277 } // End of namespace gum
278 
279 #ifndef GUM_NO_INLINE
281 #endif /* GUM_NO_INLINE */
282 
283 #endif /* GUM_MULTI_DIM_FUNCTION_GRAPH_INTERNAL_NODE_H */
bool operator==(const Parent &comp) const
NodeId parentId
Definition: internalNode.h:49
Headers of gum::SmallObjectAllocator.
Base class for discrete random variable.
LinkedList< Parent > __nodeParents
The list of the node&#39;s parent.
Definition: internalNode.h:123
Inline implementation of the InternalNode class.
Base class for discrete random variable.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
bool operator!=(const Parent &comp) const
Parent & operator=(const Parent &src)
NodeId * __nodeSons
Table of sons of the node.
Definition: internalNode.h:120
Structure used to represent a node internal structure.
Definition: internalNode.h:100
const DiscreteVariable * __nodeVar
Variable associated to such node.
Definition: internalNode.h:103
Parent(NodeId pi, Idx m)
Class constructor.
Chain list allocated using the SmallObjectAllocator.
Definition: link.h:131
Represent a node&#39;s parent.
Definition: internalNode.h:48
Size Idx
Type for indexes.
Definition: types.h:50
Size NodeId
Type for node ids.
Definition: graphElements.h:97
some utils for topology : NodeId, Edge, Arc and consorts ...