aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
PRM_tpl.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 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 >
109  return *(_classMap_[name]);
110  }
111 
112  template < typename GUM_SCALAR >
113  INLINE const PRMClass< GUM_SCALAR >&
114  PRM< GUM_SCALAR >::getClass(const std::string& name) const {
115  return *(_classMap_[name]);
116  }
117 
118  template < typename GUM_SCALAR >
119  INLINE const Set< PRMClass< GUM_SCALAR >* >& PRM< GUM_SCALAR >::classes() const {
120  return _classes_;
121  }
122 
123  template < typename GUM_SCALAR >
125  return *_interfaceMap_[name];
126  }
127 
128  template < typename GUM_SCALAR >
129  INLINE const PRMInterface< GUM_SCALAR >&
130  PRM< GUM_SCALAR >::getInterface(const std::string& name) const {
131  return *_interfaceMap_[name];
132  }
133 
134  template < typename GUM_SCALAR >
136  return _interfaces_;
137  }
138 
139  template < typename GUM_SCALAR >
141  return *(_systemMap_[name]);
142  }
143 
144  template < typename GUM_SCALAR >
145  INLINE const PRMSystem< GUM_SCALAR >&
146  PRM< GUM_SCALAR >::getSystem(const std::string& name) const {
147  return *(_systemMap_[name]);
148  }
149 
150  template < typename GUM_SCALAR >
151  INLINE const Set< PRMSystem< GUM_SCALAR >* >& PRM< GUM_SCALAR >::systems() const {
152  return _systems_;
153  }
154 
155  } /* namespace prm */
156 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)