aGrUM  0.16.0
PRMType_inl.h
Go to the documentation of this file.
1 
31 
32 namespace gum {
33  namespace prm {
34 
35 
37  if (__superType) {
38  return *__superType;
39  } else {
40  GUM_ERROR(NotFound, "No super type for this type.");
41  }
42  }
43 
44 
45  INLINE DiscreteVariable& PRMType::variable() { return *__var; }
46 
47 
48  INLINE const DiscreteVariable& PRMType::variable() const { return *__var; }
49 
50 
51  INLINE DiscreteVariable& PRMType::operator*() { return *__var; }
52 
53 
54  INLINE const DiscreteVariable& PRMType::operator*() const { return *__var; }
55 
56 
58 
59 
60  INLINE DiscreteVariable const* PRMType::operator->() const { return __var; }
61 
62 
65  }
66 
67 
68  INLINE const std::string& PRMType::name() const { return PRMObject::name(); }
69 
70 
71  INLINE const PRMType& PRMType::superType() const {
72  if (__superType) {
73  return *__superType;
74  } else {
75  GUM_ERROR(NotFound, "No super type for this type.");
76  }
77  }
78 
79 
80  INLINE void PRMType::setSuper(PRMType& t) {
81  try {
82  if (t != superType()) {
84  "The given type is not a valid super type for this Type");
85  }
86  } catch (NotFound&) {
87  GUM_ERROR(OperationNotAllowed, "This Type has no super Type");
88  }
89 
90  __superType = &t;
91  }
92 
93 
94  INLINE const std::vector< Idx >& PRMType::label_map() const {
95  if (__label_map) {
96  return *__label_map;
97  } else {
98  GUM_ERROR(NotFound, "No super type for this type.");
99  }
100  }
101 
102 
103  INLINE bool PRMType::isSubType() const { return __superType != nullptr; }
104 
105 
106  INLINE bool PRMType::isSuperTypeOf(const PRMType& t) const {
107  return t.isSubTypeOf(*this);
108  }
109 
110 
111  INLINE bool PRMType::operator==(const PRMObject& obj) const {
112  return name() == obj.name();
113  }
114 
115 
116  INLINE bool PRMType::operator!=(const PRMObject& obj) const {
117  return name() != obj.name();
118  }
119 
120  } /* namespace prm */
121 } /* namespace gum */
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
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
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
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
DiscreteVariable * __var
The discrete variable.
Definition: PRMType.h:276
bool operator==(const PRMObject &from) const
Equality operator.
Definition: PRMType_inl.h:111
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
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Abstract base class for any element defined in a PRM.
Definition: PRMObject.h:56
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
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 isSubTypeOf(const PRMType &super) const
Returns true if this is a subtype of super.
Definition: PRMType.cpp:107
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55