aGrUM  0.16.0
PRMType.h
Go to the documentation of this file.
1 
30 #ifndef GUM_RANDOM_VARIABLE_TYPE_H
31 #define GUM_RANDOM_VARIABLE_TYPE_H
32 
33 #include <sstream>
34 #include <vector>
35 
36 #include <agrum/agrum.h>
37 
42 
44 #include <agrum/PRM/utils_prm.h>
45 
46 namespace gum {
47  namespace prm {
48 
49  template < typename GUM_SCALAR >
50  class PRMFactory;
51 
63  class PRMType : public PRMObject {
64  public:
65  // ==========================================================================
67  // ==========================================================================
69 
70  template < typename GUM_SCALAR >
71  friend class PRMFactory;
72 
74  // ==========================================================================
76  // ==========================================================================
78 
80  static PRMType* boolean() {
81  LabelizedVariable var("boolean", "Boolean variable", 0);
82  var.addLabel("false");
83  var.addLabel("true");
84  return new PRMType(var);
85  }
86 
88  // ==========================================================================
90  // ==========================================================================
92 
97  explicit PRMType(const DiscreteVariable& var);
98 
104  PRMType(PRMType& super_type,
105  const std::vector< Idx >& label_map,
106  const DiscreteVariable& var);
107 
112  PRMType(const PRMType& from);
113 
117  virtual ~PRMType();
118 
120  // ==========================================================================
122  // ==========================================================================
124 
127 
129  const DiscreteVariable& variable() const;
130 
132  // ==========================================================================
134  // ==========================================================================
136 
141 
145  const DiscreteVariable& operator*() const;
146 
151 
155  DiscreteVariable const* operator->() const;
156 
160  bool operator==(const PRMObject& from) const;
161 
165  bool operator!=(const PRMObject& from) const;
166 
168  // ==========================================================================
170  // ==========================================================================
172 
176  virtual prm_type obj_type() const;
177 
181  const std::string& name() const;
182 
186  bool isSubType() const;
187 
193  bool isSubTypeOf(const PRMType& super) const;
194 
198  bool isSuperTypeOf(const PRMType& t) const;
199 
204  PRMType& superType();
205 
210  const PRMType& superType() const;
211 
229  void setSuper(PRMType& t);
230 
236  const std::vector< Idx >& label_map() const;
237 
239  // ==========================================================================
240  private:
241  // ==========================================================================
243  // ==========================================================================
245 
250  PRMType(PRMType&& from);
251 
255  PRMType& operator=(const PRMType& from);
256 
260  PRMType& operator=(PRMType&& from);
261 
263  // ==========================================================================
265  // ==========================================================================
267 
269  bool __isValid() const;
270 
273  void __updateName();
274 
277 
280 
283  std::vector< Idx >* __label_map;
284 
286  };
287 
288  } /* namespace prm */
289 
290 } /* namespace gum */
291 
292 #ifndef GUM_NO_INLINE
294 #endif // GUM_NO_INLINE
295 
296 #endif /* GUM_CLASS_H */
const std::string & name() const
Returns the name of this object.
Definition: PRMType_inl.h:68
PRMType & superType()
Returns the super type of this type.
Definition: PRMType_inl.h:36
void setSuper(PRMType &t)
Changes the PRMType of this PRMType super.
Definition: PRMType_inl.h:80
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
PRMType * __superType
The super type of this, if any.
Definition: PRMType.h:279
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
Definition: PRMType_inl.h:45
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
class LabelizedVariable
PRMType(const DiscreteVariable &var)
Default Constructor.
Definition: PRMType.cpp:50
virtual ~PRMType()
Destructor.
Definition: PRMType.cpp:90
bool isSuperTypeOf(const PRMType &t) const
Returns true if this is a super type of t.
Definition: PRMType_inl.h:106
Base class for discrete random variable.
bool operator!=(const PRMObject &from) const
Difference operator.
Definition: PRMType_inl.h:116
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
DiscreteVariable * __var
The discrete variable.
Definition: PRMType.h:276
bool operator==(const PRMObject &from) const
Equality operator.
Definition: PRMType_inl.h:111
void __updateName()
Used at construction to set a unique name to this class underlying DiscreteVariable.
Definition: PRMType.cpp:42
DiscreteVariable * operator->()
Dereference the DiscreteVariable contained in this.
Definition: PRMType_inl.h:57
prm_type
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:69
virtual prm_type obj_type() const
Implementation of the pure virtual method of PRMObject.
Definition: PRMType_inl.h:63
Factory which builds a PRM<GUM_SCALAR>.
Definition: PRMType.h:50
std::vector< Idx > * __label_map
A vector in which the i-th element is the Idx of the super type&#39;s label for the i-th label of this...
Definition: PRMType.h:283
This is a decoration of the DiscreteVariable class.
Definition: PRMType.h:63
Abstract base class for any element defined in a PRM.
Definition: PRMObject.h:56
static PRMType * boolean()
Returns a pointer on type boolean.
Definition: PRMType.h:80
const std::vector< Idx > & label_map() const
Returns the vector in which the i-th element is the Idx of the super type&#39;s label for the i-th label ...
Definition: PRMType_inl.h:94
PRMType & operator=(const PRMType &from)
Copy operator.
Definition: PRMType.cpp:97
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
DiscreteVariable & operator*()
Indirection on the DiscreteVariable contained in this.
Definition: PRMType_inl.h:51
bool isSubType() const
Returns true if this type is a sub-type.
Definition: PRMType_inl.h:103
bool __isValid() const
Returns true if this is a valid type or subtype.
Definition: PRMType.cpp:118
LabelizedVariable & addLabel(const std::string &aLabel)
add a label with a new index (we assume that we will NEVER remove a label)
bool isSubTypeOf(const PRMType &super) const
Returns true if this is a subtype of super.
Definition: PRMType.cpp:107
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.