aGrUM  0.16.0
internalNode.cpp
Go to the documentation of this file.
1 
32 
33 #define ALLOCATE(x) SmallObjectAllocator::instance().allocate(x)
34 #define DEALLOCATE(x, y) SmallObjectAllocator::instance().deallocate(x, y)
35 
36 namespace gum {
37 
38  // ============================================================================
39  // Constructors
40  // ============================================================================
42  GUM_CONSTRUCTOR(InternalNode);
43  __nodeVar = nullptr;
44  }
45 
47  GUM_CONSTRUCTOR(InternalNode);
48  __setNodeVar(v);
49  }
50 
52  GUM_CONSTRUCTOR(InternalNode);
53  __nodeVar = v;
54  __nodeSons = sons;
55  }
56 
57  // ============================================================================
58  // Destructors
59  // ============================================================================
61  GUM_DESTRUCTOR(InternalNode);
63  }
64 
65  // ============================================================================
66  // Allocates a table of nodeid of the size given in parameter
67  // ============================================================================
69  NodeId* sons =
70  static_cast< NodeId* >(ALLOCATE(sizeof(NodeId) * v->domainSize()));
71  for (gum::Idx i = 0; i < v->domainSize(); ++i)
72  sons[i] = 0;
73  return sons;
74  }
75 
76  // ============================================================================
77  // Deallocates a NodeSons table
78  // ============================================================================
80  DEALLOCATE(s, sizeof(NodeId) * v->domainSize());
81  }
82 
83  // ============================================================================
84  // Node handlers
85  // ============================================================================
88  __nodeVar = v;
89  __nodeSons = sons;
90  }
91 
92  // ============================================================================
93  // Var handlers
94  // ============================================================================
97  __setNodeVar(v);
98  }
99 
101  __nodeVar = v;
103  }
104 
105  // ============================================================================
106  // Parent handlers
107  // ============================================================================
108  void InternalNode::addParent(NodeId parent, Idx modality) {
109  __nodeParents.addLink(Parent(parent, modality));
110  }
111 
112  void InternalNode::removeParent(NodeId parent, Idx modality) {
113  __nodeParents.searchAndRemoveLink(Parent(parent, modality));
114  }
115 
116 } // namespace gum
117 
118 #ifdef GUM_NO_INLINE
120 #endif /* GUM_NO_INLINE */
void addParent(NodeId parent, Idx modality)
Adds a parent.
void setNode(const DiscreteVariable *v, NodeId *sons)
Allows you to respecify the node, changing its attached variable as well as its son map...
void __setNodeVar(const DiscreteVariable *v)
Set the node variable.
void removeParent(NodeId parent, Idx modality)
Removes a parent.
LinkedList< Parent > __nodeParents
The list of the node&#39;s parent.
Definition: internalNode.h:125
static NodeId * allocateNodeSons(const DiscreteVariable *v)
Allocates a table of nodeid of the size given in parameter.
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.
~InternalNode()
Class destructors.
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
#define DEALLOCATE(x, y)
static void deallocateNodeSons(const DiscreteVariable *v, NodeId *s)
Deallocates a NodeSons table.
void setNodeVar(const DiscreteVariable *v)
Set the node variable.
#define ALLOCATE(x)
virtual Size domainSize() const =0
NodeId * __nodeSons
Table of sons of the node.
Definition: internalNode.h:122
Structure used to represent a node internal structure.
Definition: internalNode.h:102
const DiscreteVariable * __nodeVar
Variable associated to such node.
Definition: internalNode.h:105
Represent a node&#39;s parent.
Definition: internalNode.h:50
Size Idx
Type for indexes.
Definition: types.h:53
Size NodeId
Type for node ids.
Definition: graphElements.h:98
InternalNode()
Default Constructor Creates an empty node with no variable attached.