aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
ITerminalNodePolicy.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Headers of the ITerminalNodePolicy
25  *
26  * @author Pierre-Henri WUILLEMIN(@LIP6) and Jean-Christophe MAGNAN and Christophe
27  * GONZALES(@AMU)
28  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
29  */
30 #ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_INTERFACE_TERMINAL_NODE_POLICY_H
31 #define GUM_MULTI_DIM_FUNCTION_GRAPH_INTERFACE_TERMINAL_NODE_POLICY_H
32 
33 #include <agrum/tools/graphs/parts/nodeGraphPart.h>
34 
35 namespace gum {
36 
37  // clang-format off
38  /**
39  * @class ITerminalNodePolicy
40  * @headerfile ITerminalNodePolicy.h <agrum/tools/multidim/FunctionGraphUtilities/terminalNodePolicies/ITerminalNodePolicy.h>
41  * @ingroup multidim_group
42  *
43  * @brief Interface specifying the methods to be implemented by any
44  * TerminalNodePolicy
45  */
46  template <typename GUM_SCALAR>
48 
49  public:
50  // ============================================================================
51  /// @name Terminal Node Creation and Destruction
52  // ============================================================================
53  /// @{
54 
55  /// Insert a new terminal node with given value
56  virtual void addTerminalNode( const NodeId& n, const GUM_SCALAR& v ) = 0;
57 
58  /// Remove node matching given id
59  virtual void eraseTerminalNode( const NodeId& n ) = 0;
60 
61  /// Erase all terminal nodes
62  virtual void clearAllTerminalNodes() = 0;
63 
64  /// @}
65  // ============================================================================
66  /// @name Terminal Nodes Existence
67  // ============================================================================
68  /// @{
69 
70  /// Returns true if a terminal node matching this id exists
71  virtual bool existsTerminalNodeWithId( const NodeId& n ) const = 0;
72 
73  /// Returns true if a terminal node matching this value exists
74  virtual bool existsTerminalNodeWithValue( const GUM_SCALAR& v ) const = 0;
75 
76  /// @}
77  // ============================================================================
78  /// @name Terminal Nodes value and id access
79  // ============================================================================
80  /// @{
81 
82  /// Returns the value of the terminal node that has the given id
83  virtual const GUM_SCALAR& terminalNodeValue( const NodeId& n ) const = 0;
84 
85  /// Returns the id of the terminal node that has the given value
86  virtual const NodeId& terminalNodeId( const GUM_SCALAR& v ) const = 0;
87 
88  /// @}
89  // ============================================================================
90  /// @name Iterator on Terminal Nodes
91  // ============================================================================
92  /// @{
93 
94  /// Initializes the constant safe iterator on terminal nodes
95  virtual void beginValues() const = 0;
96 
97  /// Indicates if constant safe iterator has reach end of terminal nodes list
98  virtual bool hasValue() const = 0;
99 
100  /// Increments the constant safe iterator
101  virtual void nextValue() const = 0;
102 
103  /// Returns the value of the current terminal nodes pointed by the constant
104  /// safe iterator
105  virtual const GUM_SCALAR& value() const = 0;
106 
107  /// Returns the id of the current terminal nodes pointed by the constant
108  /// safe iterator
109  virtual const NodeId& id() const = 0;
110 
111  /// @}
112  };
113 
114 } // End of namespace gum
115 
116 #endif /* GUM_MULTI_DIM_FUNCTION_GRAPH_INTERFACE_TERMINAL_NODE_POLICY_H */
Interface specifying the methods to be implemented by any TerminalNodePolicy.
virtual const GUM_SCALAR & value() const =0
Returns the value of the current terminal nodes pointed by the constant safe iterator.
virtual void clearAllTerminalNodes()=0
Erase all terminal nodes.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
virtual bool existsTerminalNodeWithValue(const GUM_SCALAR &v) const =0
Returns true if a terminal node matching this value exists.
virtual void addTerminalNode(const NodeId &n, const GUM_SCALAR &v)=0
Insert a new terminal node with given value.
virtual void beginValues() const =0
Initializes the constant safe iterator on terminal nodes.
virtual const NodeId & terminalNodeId(const GUM_SCALAR &v) const =0
Returns the id of the terminal node that has the given value.
virtual bool hasValue() const =0
Indicates if constant safe iterator has reach end of terminal nodes list.
virtual bool existsTerminalNodeWithId(const NodeId &n) const =0
Returns true if a terminal node matching this id exists.
virtual const GUM_SCALAR & terminalNodeValue(const NodeId &n) const =0
Returns the value of the terminal node that has the given id.
virtual void nextValue() const =0
Increments the constant safe iterator.
virtual const NodeId & id() const =0
Returns the id of the current terminal nodes pointed by the constant safe iterator.
virtual void eraseTerminalNode(const NodeId &n)=0
Remove node matching given id.