aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
PRMType_inl.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 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 Inline implementation of type.
25  *
26  * @author Lionel TORTI and Pierre-Henri WUILLEMIN(@LIP6)
27  *
28  */
29 #include <agrum/PRM/elements/PRMType.h>
30 
31 namespace gum {
32  namespace prm {
33 
34 
35  INLINE PRMType& PRMType::superType() {
36  if (superType__) {
37  return *superType__;
38  } else {
39  GUM_ERROR(NotFound, "No super type for this type.");
40  }
41  }
42 
43 
45 
46 
47  INLINE const DiscreteVariable& PRMType::variable() const { return *var__; }
48 
49 
51 
52 
53  INLINE const DiscreteVariable& PRMType::operator*() const { return *var__; }
54 
55 
57 
58 
59  INLINE DiscreteVariable const* PRMType::operator->() const { return var__; }
60 
61 
63  return PRMObject::prm_type::TYPE;
64  }
65 
66 
67  INLINE const std::string& PRMType::name() const { return PRMObject::name(); }
68 
69 
70  INLINE const PRMType& PRMType::superType() const {
71  if (superType__) {
72  return *superType__;
73  } else {
74  GUM_ERROR(NotFound, "No super type for this type.");
75  }
76  }
77 
78 
80  try {
81  if (t != superType()) {
83  "The given type is not a valid super type for this Type");
84  }
85  } catch (NotFound&) {
86  GUM_ERROR(OperationNotAllowed, "This Type has no super Type");
87  }
88 
89  superType__ = &t;
90  }
91 
92 
93  INLINE const std::vector< Idx >& PRMType::label_map() const {
94  if (label_map__) {
95  return *label_map__;
96  } else {
97  GUM_ERROR(NotFound, "No super type for this type.");
98  }
99  }
100 
101 
102  INLINE bool PRMType::isSubType() const { return superType__ != nullptr; }
103 
104 
105  INLINE bool PRMType::isSuperTypeOf(const PRMType& t) const {
106  return t.isSubTypeOf(*this);
107  }
108 
109 
110  INLINE bool PRMType::operator==(const PRMObject& obj) const {
111  return name() == obj.name();
112  }
113 
114 
115  INLINE bool PRMType::operator!=(const PRMObject& obj) const {
116  return name() != obj.name();
117  }
118 
119  } /* namespace prm */
120 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)