aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
PRM_tpl.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 PRM.
25  *
26  * @author Lionel TORTI and Pierre-Henri WUILLEMIN(@LIP6)
27  */
28 #include <agrum/PRM/PRM.h>
29 
30 namespace gum {
31  namespace prm {
32 
33  // Default constructor.
34  template < typename GUM_SCALAR >
35  PRM< GUM_SCALAR >::PRM() {
36  GUM_CONSTRUCTOR(PRM);
37  addBuiltInTypes__();
38  }
39 
40  // Destructor.
41  template < typename GUM_SCALAR >
42  PRM< GUM_SCALAR >::~PRM() {
44  classMap__.clear();
45  typeMap__.clear();
47 
48  for (const auto sys: systems__)
49  delete sys;
50 
51  for (const auto cla: classes__)
52  delete cla;
53 
54  for (const auto inter: interfaces__)
55  delete inter;
56 
57  for (const auto typ: types__)
58  delete typ;
59  }
60 
61  // Add the built-in types in the PRM
62  template < typename GUM_SCALAR >
64  LabelizedVariable var("boolean", "built-in type", 0);
65  var.addLabel("false");
66  var.addLabel("true");
67  PRMType* boolean = new PRMType(var);
69  typeMap__.insert("boolean", boolean);
70  }
71 
72  template < typename GUM_SCALAR >
73  INLINE bool PRM< GUM_SCALAR >::isType(const std::string& name) const {
74  return typeMap__.exists(name);
75  }
76 
77  template < typename GUM_SCALAR >
78  INLINE bool PRM< GUM_SCALAR >::isClass(const std::string& name) const {
79  return classMap__.exists(name);
80  }
81 
82  template < typename GUM_SCALAR >
83  INLINE bool PRM< GUM_SCALAR >::isInterface(const std::string& name) const {
84  return interfaceMap__.exists(name);
85  }
86 
87  template < typename GUM_SCALAR >
88  INLINE bool PRM< GUM_SCALAR >::isSystem(const std::string& name) const {
89  return systemMap__.exists(name);
90  }
91 
92  template < typename GUM_SCALAR >
94  return *(typeMap__[name]);
95  }
96 
97  template < typename GUM_SCALAR >
98  INLINE const PRMType& PRM< GUM_SCALAR >::type(const std::string& name) const {
99  return *(typeMap__[name]);
100  }
101 
102  template < typename GUM_SCALAR >
103  INLINE const Set< PRMType* >& PRM< GUM_SCALAR >::types() const {
104  return types__;
105  }
106 
107  template < typename GUM_SCALAR >
110  return *(classMap__[name]);
111  }
112 
113  template < typename GUM_SCALAR >
114  INLINE const PRMClass< GUM_SCALAR >&
115  PRM< GUM_SCALAR >::getClass(const std::string& name) const {
116  return *(classMap__[name]);
117  }
118 
119  template < typename GUM_SCALAR >
120  INLINE const Set< PRMClass< GUM_SCALAR >* >&
121  PRM< GUM_SCALAR >::classes() const {
122  return classes__;
123  }
124 
125  template < typename GUM_SCALAR >
128  return *interfaceMap__[name];
129  }
130 
131  template < typename GUM_SCALAR >
132  INLINE const PRMInterface< GUM_SCALAR >&
133  PRM< GUM_SCALAR >::getInterface(const std::string& name) const {
134  return *interfaceMap__[name];
135  }
136 
137  template < typename GUM_SCALAR >
138  INLINE const Set< PRMInterface< GUM_SCALAR >* >&
139  PRM< GUM_SCALAR >::interfaces() const {
140  return interfaces__;
141  }
142 
143  template < typename GUM_SCALAR >
146  return *(systemMap__[name]);
147  }
148 
149  template < typename GUM_SCALAR >
150  INLINE const PRMSystem< GUM_SCALAR >&
151  PRM< GUM_SCALAR >::getSystem(const std::string& name) const {
152  return *(systemMap__[name]);
153  }
154 
155  template < typename GUM_SCALAR >
156  INLINE const Set< PRMSystem< GUM_SCALAR >* >&
157  PRM< GUM_SCALAR >::systems() const {
158  return systems__;
159  }
160 
161  } /* namespace prm */
162 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)