aGrUM  0.18.1
a C++ library for (probabilistic) graphical models
PRM_tpl.h
Go to the documentation of this file.
1 
29 #include <agrum/PRM/PRM.h>
30 
31 namespace gum {
32  namespace prm {
33 
34  // Default constructor.
35  template < typename GUM_SCALAR >
37  GUM_CONSTRUCTOR(PRM);
38  addBuiltInTypes__();
39  }
40 
41  // Destructor.
42  template < typename GUM_SCALAR >
44  GUM_DESTRUCTOR(PRM);
45  classMap__.clear();
46  typeMap__.clear();
47  systemMap__.clear();
48 
49  for (const auto sys: systems__)
50  delete sys;
51 
52  for (const auto cla: classes__)
53  delete cla;
54 
55  for (const auto inter: interfaces__)
56  delete inter;
57 
58  for (const auto typ: types__)
59  delete typ;
60  }
61 
62  // Add the built-in types in the PRM
63  template < typename GUM_SCALAR >
65  LabelizedVariable var("boolean", "built-in type", 0);
66  var.addLabel("false");
67  var.addLabel("true");
68  PRMType* boolean = new PRMType(var);
69  types__.insert(boolean);
70  typeMap__.insert("boolean", boolean);
71  }
72 
73  template < typename GUM_SCALAR >
74  INLINE bool PRM< GUM_SCALAR >::isType(const std::string& name) const {
75  return typeMap__.exists(name);
76  }
77 
78  template < typename GUM_SCALAR >
79  INLINE bool PRM< GUM_SCALAR >::isClass(const std::string& name) const {
80  return classMap__.exists(name);
81  }
82 
83  template < typename GUM_SCALAR >
84  INLINE bool PRM< GUM_SCALAR >::isInterface(const std::string& name) const {
85  return interfaceMap__.exists(name);
86  }
87 
88  template < typename GUM_SCALAR >
89  INLINE bool PRM< GUM_SCALAR >::isSystem(const std::string& name) const {
90  return systemMap__.exists(name);
91  }
92 
93  template < typename GUM_SCALAR >
94  INLINE PRMType& PRM< GUM_SCALAR >::type(const std::string& name) {
95  return *(typeMap__[name]);
96  }
97 
98  template < typename GUM_SCALAR >
99  INLINE const PRMType& PRM< GUM_SCALAR >::type(const std::string& name) const {
100  return *(typeMap__[name]);
101  }
102 
103  template < typename GUM_SCALAR >
105  return types__;
106  }
107 
108  template < typename GUM_SCALAR >
109  INLINE PRMClass< GUM_SCALAR >&
110  PRM< GUM_SCALAR >::getClass(const std::string& name) {
111  return *(classMap__[name]);
112  }
113 
114  template < typename GUM_SCALAR >
115  INLINE const PRMClass< GUM_SCALAR >&
116  PRM< GUM_SCALAR >::getClass(const std::string& name) const {
117  return *(classMap__[name]);
118  }
119 
120  template < typename GUM_SCALAR >
121  INLINE const Set< PRMClass< GUM_SCALAR >* >&
123  return classes__;
124  }
125 
126  template < typename GUM_SCALAR >
128  PRM< GUM_SCALAR >::getInterface(const std::string& name) {
129  return *interfaceMap__[name];
130  }
131 
132  template < typename GUM_SCALAR >
133  INLINE const PRMInterface< GUM_SCALAR >&
134  PRM< GUM_SCALAR >::getInterface(const std::string& name) const {
135  return *interfaceMap__[name];
136  }
137 
138  template < typename GUM_SCALAR >
139  INLINE const Set< PRMInterface< GUM_SCALAR >* >&
141  return interfaces__;
142  }
143 
144  template < typename GUM_SCALAR >
146  PRM< GUM_SCALAR >::getSystem(const std::string& name) {
147  return *(systemMap__[name]);
148  }
149 
150  template < typename GUM_SCALAR >
151  INLINE const PRMSystem< GUM_SCALAR >&
152  PRM< GUM_SCALAR >::getSystem(const std::string& name) const {
153  return *(systemMap__[name]);
154  }
155 
156  template < typename GUM_SCALAR >
157  INLINE const Set< PRMSystem< GUM_SCALAR >* >&
159  return systems__;
160  }
161 
162  } /* namespace prm */
163 } /* namespace gum */
PRMInterface< GUM_SCALAR > & getInterface(const std::string &name)
Returns a constant reference on a Class<GUM_SCALAR> given it&#39;s name.
Definition: PRM_tpl.h:128
const Set< PRMType *> & types() const
Returns the Set of all PRMType in this PRM.
Definition: PRM_tpl.h:104
bool isClass(const std::string &name) const
Definition: PRM_tpl.h:79
class LabelizedVariable
PRM()
Default constructor.
Definition: PRM_tpl.h:36
const Set< PRMSystem< GUM_SCALAR > *> & systems() const
Returns the Set of all Systems in this PRM.
Definition: PRM_tpl.h:158
const Set< PRMClass< GUM_SCALAR > *> & classes() const
Returns the Set of all Class<GUM_SCALAR> in this PRM.
Definition: PRM_tpl.h:122
Copyright 2005-2020 Pierre-Henri WUILLEMIN() & Christophe GONZALES() info_at_agrum_dot_org.
const Set< PRMInterface< GUM_SCALAR > *> & interfaces() const
Returns the Set of all Class<GUM_SCALAR> in this PRM.
Definition: PRM_tpl.h:140
Copyright 2005-2020 Pierre-Henri WUILLEMIN() & Christophe GONZALES() info_at_agrum_dot_org.
Definition: agrum.h:25
void addBuiltInTypes__()
Add the built-in types in the PRM.
Definition: PRM_tpl.h:64
bool isType(const std::string &name) const
Definition: PRM_tpl.h:74
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
~PRM()
Destructor.
Definition: PRM_tpl.h:43
PRMType & type(const std::string &name)
Returns a constant reference on a PRMType given it&#39;s name.
Definition: PRM_tpl.h:94
bool isSystem(const std::string &name) const
Definition: PRM_tpl.h:89
PRMSystem< GUM_SCALAR > & getSystem(const std::string &name)
Returns a constant reference on a PRMSystem<GUM_SCALAR> given it&#39;s name.
Definition: PRM_tpl.h:146
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
Definition: PRMObject.h:229
This is a decoration of the DiscreteVariable class.
Definition: PRMType.h:63
An PRMInterface is implemented by a Class<GUM_SCALAR> and defines a set of PRMReferenceSlot<GUM_SCALA...
Definition: PRMClass.h:54
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
Definition: PRM.h:66
A PRMClass is an object of a PRM representing a fragment of a Bayesian Network which can be instantia...
Definition: PRMClass.h:66
PRMClass< GUM_SCALAR > & getClass(const std::string &name)
Returns a constant reference on a Class<GUM_SCALAR> given it&#39;s name.
Definition: PRM_tpl.h:110
LabelizedVariable & addLabel(const std::string &aLabel)
add a label with a new index (we assume that we will NEVER remove a label)
bool isInterface(const std::string &name) const
Definition: PRM_tpl.h:84