aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::prm::PRMSystem< GUM_SCALAR > Class Template Reference

A PRMSystem is a container of PRMInstance and describe a relational skeleton. More...

#include <PRMObject.h>

+ Inheritance diagram for gum::prm::PRMSystem< GUM_SCALAR >:
+ Collaboration diagram for gum::prm::PRMSystem< GUM_SCALAR >:

Public Member Functions

Constructors & destructor.
 PRMSystem (const std::string &name)
 Default constructor. More...
 
virtual ~PRMSystem ()
 Destructor. More...
 
Getters & setters over the relational skeleton.
const DiGraphskeleton () const
 Returns the relation skeleton of this PRMSystem. More...
 
PRMInstance< GUM_SCALAR > & get (NodeId id)
 Returns an PRMInstance given it's NodeId in the relational skeleton. More...
 
const PRMInstance< GUM_SCALAR > & get (NodeId id) const
 Returns an PRMInstance given it's NodeId in the relational skeleton. More...
 
NodeId get (const PRMInstance< GUM_SCALAR > &i) const
 Returns the relation skeleton of this PRMSystem. More...
 
Getters & setters over PRMInstance and array of PRMInstance.
virtual PRMObject::prm_type obj_type () const
 Returns the PRM type of this object. More...
 
Size size () const
 Returns the number of PRMInstance in this PRMSystem. More...
 
bool exists (const std::string &name) const
 Retruns true either if name is an instance or an array in this PRMSystem. More...
 
bool isInstantiated (const PRMClass< GUM_SCALAR > &c) const
 Returns true if the given Class<GUM_SCALAR> has at least one PRMInstance in this PRMSystem. More...
 
bool isInstance (const std::string &name) const
 Returns true if an PRMInstance with the given name exists. More...
 
bool isArray (const std::string &name) const
 Returns true if an array with the given name exists. More...
 
void groundedBN (BayesNetFactory< GUM_SCALAR > &factory) const
 Returns the grounded Bayesian network of this system. More...
 
void instantiate ()
 Instantiate all the PRMInstance in this PRMSystem. More...
 
PRMInstance handling.
PRMInstance< GUM_SCALAR > & get (const std::string &name)
 Returns a reference over an PRMInstance given it's name. More...
 
const PRMInstance< GUM_SCALAR > & get (const std::string &name) const
 Returns a constant reference over an PRMInstance given it's name. More...
 
const Set< PRMInstance< GUM_SCALAR > *> & get (const PRMClass< GUM_SCALAR > &type) const
 Returns the sequence of all instances of the given type. More...
 
NodeId add (PRMInstance< GUM_SCALAR > *i)
 Add an PRMInstance to this system. More...
 
Array handling.
const Sequence< PRMInstance< GUM_SCALAR > *> & getArray (const std::string &name) const
 Returns the sequence of instances of a given array. More...
 
PRMClassElementContainer< GUM_SCALAR > & getArrayType (const std::string &name)
 Returns the type of the given array. More...
 
const PRMClassElementContainer< GUM_SCALAR > & getArrayType (const std::string &name) const
 Returns the type of the given array. More...
 
NodeId add (const std::string &array, PRMInstance< GUM_SCALAR > *i)
 Add an PRMInstance to an array in this system. If the array doesn't exists it is created. More...
 
NodeId add (const std::string &array, PRMInstance< GUM_SCALAR > &i)
 Add an PRMInstance to an array in this system. If the array doesn't exists it is created. More...
 
void addArray (const std::string &array, PRMClassElementContainer< GUM_SCALAR > &type)
 Add an array of instances in this system. If the array doesn't exists it is created. More...
 
Getters & setters.
const std::string & name () const
 Returns the name of this object. More...
 
void name (const std::string &name)
 Change the name of the PRM Object. More...
 
Operators
bool operator== (const PRMObject &obj) const
 To PRMObject are equal if they have the same name (which is unique). More...
 
bool operator!= (const PRMObject &obj) const
 To PRMObject are equal if they have the same name (which is unique). More...
 

Protected Member Functions

 PRMSystem (const PRMSystem< GUM_SCALAR > &from)
 Copy constructor. Don't use it. More...
 
PRMSystem< GUM_SCALAR > & operator= (const PRMSystem< GUM_SCALAR > &from)=delete
 Copy operator. Don't use it. More...
 
Ground BN private methods.
void _groundRef_ (const PRMInstance< GUM_SCALAR > &instance, BayesNetFactory< GUM_SCALAR > &factory) const
 Method which ground PRMReferenceSlot of an PRMInstance and add arcs in the IBayesNet. More...
 
void _groundAttr_ (const PRMInstance< GUM_SCALAR > &instance, BayesNetFactory< GUM_SCALAR > &factory) const
 Method which ground Atttributes and Aggregators of an PRMInstance. More...
 
void _groundPotential_ (const PRMInstance< GUM_SCALAR > &instance, const PRMAttribute< GUM_SCALAR > &attr, BayesNetFactory< GUM_SCALAR > &factory) const
 Method which copy node's Potential of an PRMInstance to the grounded Bayesian network. More...
 
void _groundAgg_ (const PRMClassElement< GUM_SCALAR > &elt, const std::string &name, BayesNetFactory< GUM_SCALAR > &factory) const
 Ground an aggregator with the given name in the grounded IBayesNet. More...
 

Built-in types.

enum  prm_type : char {
  prm_type::ALL, prm_type::CLASS, prm_type::PRM_INTERFACE, prm_type::CLASS_ELT,
  prm_type::TYPE, prm_type::SYSTEM, prm_type::INSTANCE
}
 Enumeration of the different types of objects handled by a PRM. More...
 
static std::string LEFT_CAST ()
 Enumeration of the different types of objects handled by a PRM. More...
 
static std::string RIGHT_CAST ()
 Enumeration of the different types of objects handled by a PRM. More...
 
static std::string enum2str (prm_type type)
 Returns the string representation of a PRMObject. More...
 
static INLINE bool isClass (const PRMObject &obj)
 Returns true if obj_ptr is of type Class. More...
 
static INLINE bool isInterface (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInterface. More...
 
static INLINE bool isInstance (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInstance. More...
 

Iterators.

typedef NodeProperty< PRMInstance< GUM_SCALAR > *>::iterator iterator
 Iterator over the PRMInstance of this PRMSystem. More...
 
typedef NodeProperty< PRMInstance< GUM_SCALAR > *>::const_iterator const_iterator
 Constant Iterator over the PRMInstance of this PRMSystem. More...
 
typedef Sequence< PRMInstance< GUM_SCALAR > *>::iterator array_iterator
 Iterator over the PRMInstance in an array in this PRMSystem. More...
 
typedef Sequence< PRMInstance< GUM_SCALAR > *>::const_iterator const_array_iterator
 Iterator over the PRMInstance in an array in this PRMSystem. More...
 
iterator begin ()
 Returns an iterator over the instances in this system. More...
 
const iteratorend ()
 Returns a iterator at the end of the set of PRMInstance in this PRMSystem. More...
 
const_iterator begin () const
 Returns a constant iterator over the instances in this system. More...
 
const const_iteratorend () const
 Returns a constant iterator at the end of the set of PRMInstance in this PRMSystem. More...
 
array_iterator begin (const std::string &a)
 Returns an iterator at the beginning of the Sequence of PRMInstance in the array named a;. More...
 
const array_iteratorend (const std::string &a)
 Returns an iterator at the end of the Sequence of PRMInstance in the array named a. More...
 
const_array_iterator begin (const std::string &a) const
 Returns an iterator at the beginning of the Sequence of PRMInstance in the array named a;. More...
 
const const_array_iteratorend (const std::string &a) const
 Returns an iterator at the end of the Sequence of PRMInstance in the array named a. More...
 

Private PRMInstance handling methods and members.

typedef std::pair< PRMClassElementContainer< GUM_SCALAR > *, Sequence< PRMInstance< GUM_SCALAR > *> *> model_pair
 Typedef of the pair of a Class<GUM_SCALAR> and the sequence of it's instantiation. More...
 
DiGraph skeleton_
 The relational skeleton of this PRMSystem. More...
 
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
 The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem. More...
 
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
 The mapping between PRMInstance and their names. More...
 
HashTable< PRMClass< GUM_SCALAR > *, Set< PRMInstance< GUM_SCALAR > *> *> instanceMap_
 Mapping between a class and all it's PRMInstance in this system. More...
 
HashTable< std::string, model_pairarrayMap_
 Mapping between arrays and their name. The first element of the pair is the type of the array. More...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::prm::PRMSystem< GUM_SCALAR >

A PRMSystem is a container of PRMInstance and describe a relational skeleton.

Definition at line 234 of file PRMObject.h.

Member Typedef Documentation

◆ array_iterator

template<typename GUM_SCALAR>
typedef Sequence< PRMInstance< GUM_SCALAR >* >::iterator gum::prm::PRMSystem< GUM_SCALAR >::array_iterator

Iterator over the PRMInstance in an array in this PRMSystem.

Definition at line 222 of file PRMSystem.h.

◆ const_array_iterator

template<typename GUM_SCALAR>
typedef Sequence< PRMInstance< GUM_SCALAR >* >::const_iterator gum::prm::PRMSystem< GUM_SCALAR >::const_array_iterator

Iterator over the PRMInstance in an array in this PRMSystem.

Definition at line 235 of file PRMSystem.h.

◆ const_iterator

template<typename GUM_SCALAR>
typedef NodeProperty< PRMInstance< GUM_SCALAR >* >::const_iterator gum::prm::PRMSystem< GUM_SCALAR >::const_iterator

Constant Iterator over the PRMInstance of this PRMSystem.

Definition at line 212 of file PRMSystem.h.

◆ iterator

template<typename GUM_SCALAR>
typedef NodeProperty< PRMInstance< GUM_SCALAR >* >::iterator gum::prm::PRMSystem< GUM_SCALAR >::iterator

Iterator over the PRMInstance of this PRMSystem.

Definition at line 202 of file PRMSystem.h.

◆ model_pair

template<typename GUM_SCALAR>
typedef std::pair< PRMClassElementContainer< GUM_SCALAR >*, Sequence< PRMInstance< GUM_SCALAR >* >* > gum::prm::PRMSystem< GUM_SCALAR >::model_pair
protected

Typedef of the pair of a Class<GUM_SCALAR> and the sequence of it's instantiation.

Definition at line 277 of file PRMSystem.h.

Member Enumeration Documentation

◆ prm_type

enum gum::prm::PRMObject::prm_type : char
stronginherited

Enumeration of the different types of objects handled by a PRM.

The "all" type is used to tell that we want any kind of PRMType (useful with iterators for example). No PRMObject will ever have "all" as type.

Enumerator
ALL 
CLASS 
PRM_INTERFACE 
CLASS_ELT 
TYPE 
SYSTEM 
INSTANCE 

Definition at line 68 of file PRMObject.h.

68  : char
69  {
70  ALL,
71  CLASS,
72  PRM_INTERFACE,
73  CLASS_ELT,
74  TYPE,
75  SYSTEM,
76  INSTANCE
77  };

Constructor & Destructor Documentation

◆ PRMSystem() [1/2]

template<typename GUM_SCALAR >
gum::prm::PRMSystem< GUM_SCALAR >::PRMSystem ( const std::string &  name)
explicit

Default constructor.

Definition at line 41 of file PRMSystem_tpl.h.

41  : PRMObject(name) {
42  GUM_CONSTRUCTOR(PRMSystem);
43  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
PRMSystem(const std::string &name)
Default constructor.
Definition: PRMSystem_tpl.h:41
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:42

◆ ~PRMSystem()

template<typename GUM_SCALAR >
gum::prm::PRMSystem< GUM_SCALAR >::~PRMSystem ( )
virtual

Destructor.

Definition at line 46 of file PRMSystem_tpl.h.

46  {
47  GUM_DESTRUCTOR(PRMSystem);
48 
49  for (const auto& elt: *this)
50  delete elt.second;
51 
52  for (const auto& elt: instanceMap_)
53  delete elt.second;
54 
55  for (const auto& elt: arrayMap_)
56  delete elt.second.second;
57  }
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
PRMSystem(const std::string &name)
Default constructor.
Definition: PRMSystem_tpl.h:41
HashTable< PRMClass< GUM_SCALAR > *, Set< PRMInstance< GUM_SCALAR > *> *> instanceMap_
Mapping between a class and all it&#39;s PRMInstance in this system.
Definition: PRMSystem.h:271

◆ PRMSystem() [2/2]

template<typename GUM_SCALAR>
INLINE gum::prm::PRMSystem< GUM_SCALAR >::PRMSystem ( const PRMSystem< GUM_SCALAR > &  from)
protected

Copy constructor. Don't use it.

Definition at line 60 of file PRMSystem_tpl.h.

60  :
61  PRMObject(from), skeleton_(from.skeleton_), nodeIdMap_(from.nodeIdMap_),
62  nameMap_(from.nameMap_), instanceMap_(from.instanceMap_), arrayMap_(from.arrayMap_) {
63  GUM_CONS_CPY(PRMSystem);
64  }
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
PRMSystem(const std::string &name)
Default constructor.
Definition: PRMSystem_tpl.h:41
DiGraph skeleton_
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:261
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:265
HashTable< PRMClass< GUM_SCALAR > *, Set< PRMInstance< GUM_SCALAR > *> *> instanceMap_
Mapping between a class and all it&#39;s PRMInstance in this system.
Definition: PRMSystem.h:271
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:268
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:42

Member Function Documentation

◆ _groundAgg_()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::_groundAgg_ ( const PRMClassElement< GUM_SCALAR > &  elt,
const std::string &  name,
BayesNetFactory< GUM_SCALAR > &  factory 
) const
protected

Ground an aggregator with the given name in the grounded IBayesNet.

Parameters
eltThe aggregator grounded.
nameThe aggregator's name in the grounded IBayesNet.
factoryThe factory used to build the grounded IBayesNet.

Definition at line 139 of file PRMSystem_tpl.h.

141  {
142  factory.startVariableDeclaration();
143  factory.variableName(name);
144 
145  const DiscreteVariable& agg_var = elt.type().variable();
146 
147  VarType var_type = agg_var.varType();
148 
149  factory.variableType(var_type);
150 
151  switch (var_type) {
152  case VarType::Labelized: {
153  const auto l = static_cast< const LabelizedVariable& >(agg_var);
154  for (Idx i = 0; i < l.domainSize(); ++i) {
155  factory.addModality(l.label(i));
156  }
157  break;
158  }
159  case VarType::Discretized: {
160  const auto d = static_cast< const DiscretizedVariable< GUM_SCALAR >& >(agg_var);
161  for (Idx i = 0; i < d.domainSize(); ++i) {
162  factory.addTick(d.tick(i));
163  }
164  break;
165  }
166  case VarType::Range: {
167  const auto r = static_cast< const RangeVariable& >(agg_var);
168  factory.addMin(r.minVal());
169  factory.addMax(r.maxVal());
170  break;
171  }
172  case VarType::Continuous:
173  // Todo Error
174  break;
175  }
176 
177  const PRMAggregate< GUM_SCALAR >& agg = static_cast< const PRMAggregate< GUM_SCALAR >& >(elt);
178 
179  switch (agg.agg_type()) {
181  factory.setVariableCPTImplementation(new aggregator::Min< GUM_SCALAR >());
182  break;
183  }
184 
186  factory.setVariableCPTImplementation(new aggregator::Max< GUM_SCALAR >());
187  break;
188  }
189 
191  factory.setVariableCPTImplementation(new aggregator::Exists< GUM_SCALAR >(agg.label()));
192  break;
193  }
194 
196  factory.setVariableCPTImplementation(new aggregator::Forall< GUM_SCALAR >(agg.label()));
197  break;
198  }
199 
201  factory.setVariableCPTImplementation(new aggregator::Count< GUM_SCALAR >(agg.label()));
202  break;
203  }
204 
206  factory.setVariableCPTImplementation(new aggregator::Median< GUM_SCALAR >());
207  break;
208  }
209 
211  factory.setVariableCPTImplementation(new aggregator::Amplitude< GUM_SCALAR >());
212  break;
213  }
214 
216  factory.setVariableCPTImplementation(new aggregator::Or< GUM_SCALAR >());
217  break;
218  }
219 
221  factory.setVariableCPTImplementation(new aggregator::And< GUM_SCALAR >());
222  break;
223  }
224 
226  factory.setVariableCPTImplementation(new aggregator::Sum< GUM_SCALAR >());
227  break;
228  }
229 
230  default:
231  GUM_ERROR(OperationNotAllowed, "Aggregator not handled yet for " << agg.name())
232  }
233 
234  factory.endVariableDeclaration();
235  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
VarType
Definition: variable.h:40
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ _groundAttr_()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::_groundAttr_ ( const PRMInstance< GUM_SCALAR > &  instance,
BayesNetFactory< GUM_SCALAR > &  factory 
) const
protected

Method which ground Atttributes and Aggregators of an PRMInstance.

Parameters
instanceThe PRMInstance grounded by this method.
factoryThe factory used to build the grounded IBayesNet.

Definition at line 105 of file PRMSystem_tpl.h.

106  {
107  for (const auto node: instance.type().containerDag()) {
108  // Working a Class<GUM_SCALAR> level because PRMAggregate<GUM_SCALAR>
109  // are
110  // instantiated as PRMAttribute<GUM_SCALAR> in an
111  // PRMInstance<GUM_SCALAR>
112  switch (instance.type().get(node).elt_type()) {
114  // TODO: make a special case for noisy-or
115  std::stringstream elt_name;
116  elt_name << instance.name() << "." << instance.type().get(node).safeName();
117  DiscreteVariable* var = instance.get(node).type().variable().clone();
118  var->setName(elt_name.str());
119  factory.setVariable(*var); // var is copied by the factory
120  delete var;
121  break;
122  }
123 
125  std::stringstream elt_name;
126  elt_name << instance.name() << "." << instance.type().get(node).safeName();
127  _groundAgg_(instance.type().get(node), elt_name.str(), factory);
128  break;
129  }
130 
131  default:
132  break;
133  /* Do nothing */;
134  }
135  }
136  }
void _groundAgg_(const PRMClassElement< GUM_SCALAR > &elt, const std::string &name, BayesNetFactory< GUM_SCALAR > &factory) const
Ground an aggregator with the given name in the grounded IBayesNet.

◆ _groundPotential_()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::_groundPotential_ ( const PRMInstance< GUM_SCALAR > &  instance,
const PRMAttribute< GUM_SCALAR > &  attr,
BayesNetFactory< GUM_SCALAR > &  factory 
) const
protected

Method which copy node's Potential of an PRMInstance to the grounded Bayesian network.

Parameters
instanceThe PRMInstance currently grounded.
attrThe PRMAttribute<GUM_SCALAR> for which the Potential is grounded.
factoryThe factory used to build the grounded IBayesNet.

Definition at line 291 of file PRMSystem_tpl.h.

293  {
294  Bijection< const DiscreteVariable*, const DiscreteVariable* > bijection;
295  std::stringstream var_name;
296  var_name << instance.name() << "." << attr.safeName();
297  bijection.insert(&(attr.type().variable()), &(factory.variable(var_name.str())));
298 
299  for (const auto parent: instance.type().containerDag().parents(attr.id())) {
300  switch (instance.type().get(parent).elt_type()) {
303  std::stringstream parent_name;
304  parent_name << instance.name() << "." << instance.get(parent).safeName();
305  bijection.insert(&(instance.get(parent).type().variable()),
306  &(factory.variable(parent_name.str())));
307  break;
308  }
309 
311  std::stringstream parent_name;
312  const PRMSlotChain< GUM_SCALAR >& sc
313  = static_cast< const PRMSlotChain< GUM_SCALAR >& >(instance.type().get(parent));
314  parent_name << instance.getInstance(sc.id()).name() << "." << sc.lastElt().safeName();
315  bijection.insert(
316  &(instance.getInstance(sc.id()).get(sc.lastElt().safeName()).type().variable()),
317  &(factory.variable(parent_name.str())));
318  break;
319  }
320 
321  default: {
322  GUM_ERROR(FatalError, "invalid ClassElement<GUM_SCALAR> type as parent.")
323  break;
324  }
325  }
326  }
327 
328  // Copy Potential
329  // DO NOT USE MultiDimBijArray as they will wreck havok if you delete
330  // the prm befor its grounded BN (happens a lot in pyAgrum)
331  Potential< GUM_SCALAR >* p = new Potential< GUM_SCALAR >();
332  for (auto var: attr.cpf().variablesSequence()) {
333  p->add(*(bijection.second(var)));
334  }
335  Instantiation inst(attr.cpf()), jnst(*p);
336  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end()); inst.inc(), jnst.inc()) {
337  p->set(jnst, attr.cpf().get(inst));
338  }
339  GUM_ASSERT(inst.end() && jnst.end());
340  factory.setVariableCPT(var_name.str(), p, false);
341  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ _groundRef_()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_ ( const PRMInstance< GUM_SCALAR > &  instance,
BayesNetFactory< GUM_SCALAR > &  factory 
) const
protected

Method which ground PRMReferenceSlot of an PRMInstance and add arcs in the IBayesNet.

Parameters
instanceThe PRMInstance grounded by this method.
factoryThe factory used to build the grounded IBayesNet.

Definition at line 238 of file PRMSystem_tpl.h.

239  {
240  for (const auto& elt: instance) {
241  std::stringstream elt_name;
242  elt_name << instance.name() << "." << elt.second->safeName();
243  factory.startParentsDeclaration(elt_name.str());
244 
245  for (const auto par: instance.type().containerDag().parents(elt.second->id())) {
246  switch (instance.type().get(par).elt_type()) {
249  std::stringstream parent_name;
250  parent_name << instance.name() << "." << instance.get(par).safeName();
251  factory.addParent(parent_name.str());
252  break;
253  }
254 
256  std::string parent_name
257  = static_cast< const PRMSlotChain< GUM_SCALAR >& >(instance.type().get(par))
258  .lastElt()
259  .safeName();
260 
261  try {
262  for (const auto ref: instance.getInstances(par)) {
263  std::stringstream sBuff;
264  sBuff << ref->name() << "." << parent_name;
265  factory.addParent(sBuff.str());
266  }
267  } catch (NotFound&) {
268  // No instances for this slotchain
269  }
270 
271  break;
272  }
273 
274  default:
275  break;
276  /* nothing to do by default */
277  }
278  }
279 
280  factory.endParentsDeclaration();
281 
282  // Checking if we need to ground the Potential (only for class level
283  // attributes since
284  // aggregates Potentials are generated)
285  if (PRMClassElement< GUM_SCALAR >::isAttribute(instance.type().get(elt.second->safeName())))
286  _groundPotential_(instance, *elt.second, factory);
287  }
288  }
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
void _groundPotential_(const PRMInstance< GUM_SCALAR > &instance, const PRMAttribute< GUM_SCALAR > &attr, BayesNetFactory< GUM_SCALAR > &factory) const
Method which copy node&#39;s Potential of an PRMInstance to the grounded Bayesian network.

◆ add() [1/3]

template<typename GUM_SCALAR>
NodeId gum::prm::PRMSystem< GUM_SCALAR >::add ( PRMInstance< GUM_SCALAR > *  i)

Add an PRMInstance to this system.

Exceptions
DuplicateElementRaised if an PRMInstance with the same name already exists.

Definition at line 67 of file PRMSystem_tpl.h.

67  {
68  if (nameMap_.exists(i->name())) {
69  GUM_ERROR(DuplicateElement,
70  "an Instance<GUM_SCALAR> with the same is already in this System");
71  }
72 
73  NodeId id = skeleton_.addNode();
74  nodeIdMap_.insert(id, i);
75  nameMap_.insert(i->name(), i);
76 
77  try {
78  instanceMap_[&(i->type())]->insert(i);
79  } catch (NotFound&) {
80  instanceMap_.insert(&(i->type()), new Set< PRMInstance< GUM_SCALAR >* >());
81  instanceMap_[&(i->type())]->insert(i);
82  }
83 
84  return id;
85  }
virtual NodeId addNode()
insert a new node and return its id
DiGraph skeleton_
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:261
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:265
HashTable< PRMClass< GUM_SCALAR > *, Set< PRMInstance< GUM_SCALAR > *> *> instanceMap_
Mapping between a class and all it&#39;s PRMInstance in this system.
Definition: PRMSystem.h:271
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:268
Size NodeId
Type for node ids.
Definition: graphElements.h:97
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ add() [2/3]

template<typename GUM_SCALAR>
INLINE NodeId gum::prm::PRMSystem< GUM_SCALAR >::add ( const std::string &  array,
PRMInstance< GUM_SCALAR > *  i 
)

Add an PRMInstance to an array in this system. If the array doesn't exists it is created.

Exceptions
PRMTypeErrorRaised if i is not of the good type.
DuplicateElementRaised if an PRMInstance with same name already exists.

Definition at line 469 of file PRMSystem_tpl.h.

470  {
471  try {
472  if (i->type().isSubTypeOf(*(arrayMap_[array].first))) {
473  NodeId id = add(i);
474  arrayMap_[array].second->insert(i);
475  return id;
476  } else {
477  GUM_ERROR(PRMTypeError,
478  "the given Instance<GUM_SCALAR> is of an incorrect "
479  "Class<GUM_SCALAR> type");
480  }
481  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
482  }
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:67
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Size NodeId
Type for node ids.
Definition: graphElements.h:97
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ add() [3/3]

template<typename GUM_SCALAR>
INLINE NodeId gum::prm::PRMSystem< GUM_SCALAR >::add ( const std::string &  array,
PRMInstance< GUM_SCALAR > &  i 
)

Add an PRMInstance to an array in this system. If the array doesn't exists it is created.

Exceptions
PRMTypeErrorRaised if i is not of the good type.
DuplicateElementRaised if an PRMInstance with same name already exists.

Definition at line 344 of file PRMSystem_tpl.h.

345  {
346  return add(array, &i);
347  }
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:67

◆ addArray()

template<typename GUM_SCALAR>
INLINE void gum::prm::PRMSystem< GUM_SCALAR >::addArray ( const std::string &  array,
PRMClassElementContainer< GUM_SCALAR > &  type 
)

Add an array of instances in this system. If the array doesn't exists it is created.

Exceptions
DuplicateElementRaised if an existing array with the same name already exists.

Definition at line 485 of file PRMSystem_tpl.h.

486  {
487  if (arrayMap_.exists(array)) {
488  GUM_ERROR(DuplicateElement, "an array '" << array << "' is already in this System")
489  }
490 
492  array,
493  PRMSystem< GUM_SCALAR >::model_pair(&type, new Sequence< PRMInstance< GUM_SCALAR >* >()));
494  }
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
std::pair< PRMClassElementContainer< GUM_SCALAR > *, Sequence< PRMInstance< GUM_SCALAR > *> *> model_pair
Typedef of the pair of a Class<GUM_SCALAR> and the sequence of it&#39;s instantiation.
Definition: PRMSystem.h:277
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ begin() [1/4]

template<typename GUM_SCALAR >
INLINE PRMSystem< GUM_SCALAR >::iterator gum::prm::PRMSystem< GUM_SCALAR >::begin ( )

Returns an iterator over the instances in this system.

Definition at line 497 of file PRMSystem_tpl.h.

497  {
498  return nodeIdMap_.begin();
499  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:265

◆ begin() [2/4]

template<typename GUM_SCALAR >
INLINE PRMSystem< GUM_SCALAR >::const_iterator gum::prm::PRMSystem< GUM_SCALAR >::begin ( ) const

Returns a constant iterator over the instances in this system.

Definition at line 507 of file PRMSystem_tpl.h.

507  {
508  return nodeIdMap_.begin();
509  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:265

◆ begin() [3/4]

template<typename GUM_SCALAR >
INLINE PRMSystem< GUM_SCALAR >::array_iterator gum::prm::PRMSystem< GUM_SCALAR >::begin ( const std::string &  a)

Returns an iterator at the beginning of the Sequence of PRMInstance in the array named a;.

Exceptions
NotFoundRaised if no array matches a.

Definition at line 519 of file PRMSystem_tpl.h.

519  {
520  try {
521  return arrayMap_[a].second->begin();
522  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
523  }
iterator begin()
Returns an unsafe iterator pointing to the beginning of the hashtable.
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ begin() [4/4]

template<typename GUM_SCALAR >
INLINE PRMSystem< GUM_SCALAR >::const_array_iterator gum::prm::PRMSystem< GUM_SCALAR >::begin ( const std::string &  a) const

Returns an iterator at the beginning of the Sequence of PRMInstance in the array named a;.

Exceptions
NotFoundRaised if no array matches a.

Definition at line 535 of file PRMSystem_tpl.h.

535  {
536  try {
537  return arrayMap_[a].second->begin();
538  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
539  }
iterator begin()
Returns an unsafe iterator pointing to the beginning of the hashtable.
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ end() [1/4]

template<typename GUM_SCALAR >
INLINE const PRMSystem< GUM_SCALAR >::iterator & gum::prm::PRMSystem< GUM_SCALAR >::end ( )

Returns a iterator at the end of the set of PRMInstance in this PRMSystem.

Definition at line 502 of file PRMSystem_tpl.h.

502  {
503  return nodeIdMap_.end();
504  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:265

◆ end() [2/4]

template<typename GUM_SCALAR >
INLINE const PRMSystem< GUM_SCALAR >::const_iterator & gum::prm::PRMSystem< GUM_SCALAR >::end ( ) const

Returns a constant iterator at the end of the set of PRMInstance in this PRMSystem.

Definition at line 513 of file PRMSystem_tpl.h.

513  {
514  return nodeIdMap_.end();
515  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:265

◆ end() [3/4]

template<typename GUM_SCALAR >
INLINE const PRMSystem< GUM_SCALAR >::array_iterator & gum::prm::PRMSystem< GUM_SCALAR >::end ( const std::string &  a)

Returns an iterator at the end of the Sequence of PRMInstance in the array named a.

Exceptions
NotFoundRaised if no array matches a.

Definition at line 527 of file PRMSystem_tpl.h.

527  {
528  try {
529  return arrayMap_[a].second->end();
530  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
531  }
const iterator & end() noexcept
Returns the unsafe iterator pointing to the end of the hashtable.
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ end() [4/4]

template<typename GUM_SCALAR >
INLINE const PRMSystem< GUM_SCALAR >::const_array_iterator & gum::prm::PRMSystem< GUM_SCALAR >::end ( const std::string &  a) const

Returns an iterator at the end of the Sequence of PRMInstance in the array named a.

Exceptions
NotFoundRaised if no array matches a.

Definition at line 543 of file PRMSystem_tpl.h.

543  {
544  try {
545  return arrayMap_[a].second->end();
546  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
547  }
const iterator & end() noexcept
Returns the unsafe iterator pointing to the end of the hashtable.
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ enum2str()

static std::string gum::prm::PRMObject::enum2str ( prm_type  type)
inlinestaticinherited

Returns the string representation of a PRMObject.

Definition at line 83 of file PRMObject.h.

83  {
84  switch (type) {
85  case prm_type::CLASS:
86  return "PRMType::CLASS";
87 
89  return "PRMType::CLASS_ELT";
90 
91  case prm_type::TYPE:
92  return "PRMType::TYPE";
93 
94  case prm_type::SYSTEM:
95  return "PRMType::SYSTEM";
96 
97  case prm_type::INSTANCE:
98  return "PRMType::INSTANCE";
99 
101  return "PRMType::PRM_INTERFACE";
102 
103  default:
104  return "unknown";
105  }
106  }

◆ exists()

template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMSystem< GUM_SCALAR >::exists ( const std::string &  name) const

Retruns true either if name is an instance or an array in this PRMSystem.

Definition at line 550 of file PRMSystem_tpl.h.

550  {
551  return nameMap_.exists(name) || arrayMap_.exists(name);
552  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:268

◆ get() [1/6]

template<typename GUM_SCALAR >
INLINE PRMInstance< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::get ( NodeId  id)

Returns an PRMInstance given it's NodeId in the relational skeleton.

Exceptions
NotFoundRaised if no PRMInstance matches the given NodeId.

Definition at line 355 of file PRMSystem_tpl.h.

355  {
356  try {
357  return *(nodeIdMap_[id]);
358  } catch (NotFound&) {
359  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id")
360  }
361  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:265
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ get() [2/6]

template<typename GUM_SCALAR >
INLINE const PRMInstance< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::get ( NodeId  id) const

Returns an PRMInstance given it's NodeId in the relational skeleton.

Exceptions
NotFoundRaised if no PRMInstance matches the given NodeId.

Definition at line 364 of file PRMSystem_tpl.h.

364  {
365  try {
366  return *(nodeIdMap_[id]);
367  } catch (NotFound&) {
368  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id")
369  }
370  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:265
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ get() [3/6]

template<typename GUM_SCALAR>
INLINE NodeId gum::prm::PRMSystem< GUM_SCALAR >::get ( const PRMInstance< GUM_SCALAR > &  i) const

Returns the relation skeleton of this PRMSystem.

Definition at line 373 of file PRMSystem_tpl.h.

373  {
374  try {
375  return nodeIdMap_.keyByVal(const_cast< PRMInstance< GUM_SCALAR >* >(&i));
376  } catch (NotFound&) {
377  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id")
378  }
379  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:265
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ get() [4/6]

template<typename GUM_SCALAR>
INLINE PRMInstance< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::get ( const std::string &  name)

Returns a reference over an PRMInstance given it's name.

Exceptions
NotFoundRaised if the no PRMInstance matches name.

Definition at line 414 of file PRMSystem_tpl.h.

414  {
415  try {
416  return *(nameMap_[name]);
417  } catch (NotFound&) {
418  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given name")
419  }
420  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:268
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ get() [5/6]

template<typename GUM_SCALAR>
INLINE const PRMInstance< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::get ( const std::string &  name) const

Returns a constant reference over an PRMInstance given it's name.

Exceptions
NotFoundRaised if the no PRMInstance matches name.

Definition at line 424 of file PRMSystem_tpl.h.

424  {
425  try {
426  return *(nameMap_[name]);
427  } catch (NotFound&) {
428  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given name")
429  }
430  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:268
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ get() [6/6]

template<typename GUM_SCALAR>
INLINE const Set< PRMInstance< GUM_SCALAR > *> & gum::prm::PRMSystem< GUM_SCALAR >::get ( const PRMClass< GUM_SCALAR > &  type) const

Returns the sequence of all instances of the given type.

Exceptions
NotFoundRaised if there is instantiation of type.

Definition at line 435 of file PRMSystem_tpl.h.

435  {
436  try {
437  return *(instanceMap_[const_cast< PRMClass< GUM_SCALAR >* >(&type)]);
438  } catch (NotFound&) {
439  GUM_ERROR(NotFound, "the given Class<GUM_SCALAR> has no instantiation in this System");
440  }
441  }
HashTable< PRMClass< GUM_SCALAR > *, Set< PRMInstance< GUM_SCALAR > *> *> instanceMap_
Mapping between a class and all it&#39;s PRMInstance in this system.
Definition: PRMSystem.h:271
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ getArray()

template<typename GUM_SCALAR >
INLINE const Sequence< PRMInstance< GUM_SCALAR > *> & gum::prm::PRMSystem< GUM_SCALAR >::getArray ( const std::string &  name) const

Returns the sequence of instances of a given array.

Exceptions
NotFoundRaised if no array matches name.

Definition at line 446 of file PRMSystem_tpl.h.

446  {
447  try {
448  return *(arrayMap_[name].second);
449  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
450  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ getArrayType() [1/2]

template<typename GUM_SCALAR >
INLINE PRMClassElementContainer< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::getArrayType ( const std::string &  name)

Returns the type of the given array.

Exceptions
NotFoundRaised if no array matches name.

Definition at line 454 of file PRMSystem_tpl.h.

454  {
455  try {
456  return *(arrayMap_[name].first);
457  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
458  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ getArrayType() [2/2]

template<typename GUM_SCALAR >
INLINE const PRMClassElementContainer< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::getArrayType ( const std::string &  name) const

Returns the type of the given array.

Exceptions
NotFoundRaised if no array matches name.

Definition at line 462 of file PRMSystem_tpl.h.

462  {
463  try {
464  return *(arrayMap_[name].first);
465  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
466  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ groundedBN()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::groundedBN ( BayesNetFactory< GUM_SCALAR > &  factory) const

Returns the grounded Bayesian network of this system.

Parameters
factoryThe factory used to build the grounded Bayesian network.

Definition at line 88 of file PRMSystem_tpl.h.

88  {
89  factory.startNetworkDeclaration();
90  factory.addNetworkProperty("name", name());
91  factory.endNetworkDeclaration();
92 
93  // Adding nodes
94  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end(); ++iter) {
95  _groundAttr_(*(iter.val()), factory);
96  }
97 
98  // Adding arcs and filling CPTs
99  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end(); ++iter) {
100  _groundRef_(*(iter.val()), factory);
101  }
102  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
iterator begin()
Returns an iterator over the instances in this system.
NodeProperty< PRMInstance< GUM_SCALAR > *>::const_iterator const_iterator
Constant Iterator over the PRMInstance of this PRMSystem.
Definition: PRMSystem.h:212
void _groundAttr_(const PRMInstance< GUM_SCALAR > &instance, BayesNetFactory< GUM_SCALAR > &factory) const
Method which ground Atttributes and Aggregators of an PRMInstance.
void _groundRef_(const PRMInstance< GUM_SCALAR > &instance, BayesNetFactory< GUM_SCALAR > &factory) const
Method which ground PRMReferenceSlot of an PRMInstance and add arcs in the IBayesNet.
const iterator & end()
Returns a iterator at the end of the set of PRMInstance in this PRMSystem.

◆ instantiate()

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMSystem< GUM_SCALAR >::instantiate ( )

Instantiate all the PRMInstance in this PRMSystem.

Definition at line 407 of file PRMSystem_tpl.h.

407  {
408  for (auto iter = begin(); iter != end(); ++iter) {
409  (*(iter.val())).instantiate();
410  }
411  }
iterator begin()
Returns an iterator over the instances in this system.
const iterator & end()
Returns a iterator at the end of the set of PRMInstance in this PRMSystem.

◆ isArray()

template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMSystem< GUM_SCALAR >::isArray ( const std::string &  name) const

Returns true if an array with the given name exists.

Definition at line 402 of file PRMSystem_tpl.h.

402  {
403  return arrayMap_.exists(name);
404  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:281

◆ isClass()

static INLINE bool gum::prm::PRMObject::isClass ( const PRMObject obj)
inlinestaticinherited

Returns true if obj_ptr is of type Class.

Definition at line 109 of file PRMObject.h.

References gum::prm::PRMObject::PRMObject().

109 { return obj.obj_type() == prm_type::CLASS; }
+ Here is the call graph for this function:

◆ isInstance() [1/2]

static INLINE bool gum::prm::PRMObject::isInstance ( const PRMObject obj)
inlinestaticinherited

Returns true if obj_ptr is of type PRMInstance.

Definition at line 117 of file PRMObject.h.

References gum::prm::PRMObject::PRMObject().

117  {
118  return obj.obj_type() == prm_type::INSTANCE;
119  }
+ Here is the call graph for this function:

◆ isInstance() [2/2]

template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMSystem< GUM_SCALAR >::isInstance ( const std::string &  name) const

Returns true if an PRMInstance with the given name exists.

Definition at line 397 of file PRMSystem_tpl.h.

397  {
398  return nameMap_.exists(name);
399  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:268

◆ isInstantiated()

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMSystem< GUM_SCALAR >::isInstantiated ( const PRMClass< GUM_SCALAR > &  c) const

Returns true if the given Class<GUM_SCALAR> has at least one PRMInstance in this PRMSystem.

Definition at line 392 of file PRMSystem_tpl.h.

392  {
393  return instanceMap_.exists(const_cast< PRMClass< GUM_SCALAR >* >(&c));
394  }
HashTable< PRMClass< GUM_SCALAR > *, Set< PRMInstance< GUM_SCALAR > *> *> instanceMap_
Mapping between a class and all it&#39;s PRMInstance in this system.
Definition: PRMSystem.h:271

◆ isInterface()

static INLINE bool gum::prm::PRMObject::isInterface ( const PRMObject obj)
inlinestaticinherited

Returns true if obj_ptr is of type PRMInterface.

Definition at line 112 of file PRMObject.h.

References gum::prm::PRMObject::PRMObject().

112  {
113  return obj.obj_type() == prm_type::PRM_INTERFACE;
114  }
+ Here is the call graph for this function:

◆ LEFT_CAST()

static std::string gum::prm::PRMObject::LEFT_CAST ( )
inlinestaticinherited

Enumeration of the different types of objects handled by a PRM.

The "all" type is used to tell that we want any kind of PRMType (useful with iterators for example). No PRMObject will ever have "all" as type.

Definition at line 79 of file PRMObject.h.

79 { return "("; }

◆ name() [1/2]

INLINE const std::string & gum::prm::PRMObject::name ( ) const
inherited

Returns the name of this object.

Definition at line 34 of file PRMObject_inl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

34 { return _name_; }
std::string _name_
Definition: PRMObject.h:205
+ Here is the call graph for this function:

◆ name() [2/2]

INLINE void gum::prm::PRMObject::name ( const std::string &  name)
inherited

Change the name of the PRM Object.

Warning
Don't do this unless you know what you are doing !

Definition at line 38 of file PRMObject_inl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

38 { _name_ = name; }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
std::string _name_
Definition: PRMObject.h:205
+ Here is the call graph for this function:

◆ obj_type()

template<typename GUM_SCALAR >
INLINE PRMObject::prm_type gum::prm::PRMSystem< GUM_SCALAR >::obj_type ( ) const
virtual

Returns the PRM type of this object.

Implements gum::prm::PRMObject.

Definition at line 382 of file PRMSystem_tpl.h.

◆ operator!=()

INLINE bool gum::prm::PRMObject::operator!= ( const PRMObject obj) const
inherited

To PRMObject are equal if they have the same name (which is unique).

Definition at line 46 of file PRMObject_inl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

46 { return _name_ != obj.name(); }
std::string _name_
Definition: PRMObject.h:205
+ Here is the call graph for this function:

◆ operator=()

template<typename GUM_SCALAR>
PRMSystem< GUM_SCALAR >& gum::prm::PRMSystem< GUM_SCALAR >::operator= ( const PRMSystem< GUM_SCALAR > &  from)
protecteddelete

Copy operator. Don't use it.

◆ operator==()

INLINE bool gum::prm::PRMObject::operator== ( const PRMObject obj) const
inherited

To PRMObject are equal if they have the same name (which is unique).

Definition at line 42 of file PRMObject_inl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

42 { return _name_ == obj.name(); }
std::string _name_
Definition: PRMObject.h:205
+ Here is the call graph for this function:

◆ RIGHT_CAST()

static std::string gum::prm::PRMObject::RIGHT_CAST ( )
inlinestaticinherited

Enumeration of the different types of objects handled by a PRM.

The "all" type is used to tell that we want any kind of PRMType (useful with iterators for example). No PRMObject will ever have "all" as type.

Definition at line 80 of file PRMObject.h.

80 { return ")"; }

◆ size()

template<typename GUM_SCALAR >
INLINE Size gum::prm::PRMSystem< GUM_SCALAR >::size ( ) const

Returns the number of PRMInstance in this PRMSystem.

Definition at line 387 of file PRMSystem_tpl.h.

387  {
388  return nodeIdMap_.size();
389  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:265

◆ skeleton()

template<typename GUM_SCALAR >
INLINE const DiGraph & gum::prm::PRMSystem< GUM_SCALAR >::skeleton ( ) const

Returns the relation skeleton of this PRMSystem.

Definition at line 350 of file PRMSystem_tpl.h.

350  {
351  return skeleton_;
352  }
DiGraph skeleton_
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:261

Member Data Documentation

◆ arrayMap_

template<typename GUM_SCALAR>
HashTable< std::string, model_pair > gum::prm::PRMSystem< GUM_SCALAR >::arrayMap_
protected

Mapping between arrays and their name. The first element of the pair is the type of the array.

Definition at line 281 of file PRMSystem.h.

◆ instanceMap_

template<typename GUM_SCALAR>
HashTable< PRMClass< GUM_SCALAR >*, Set< PRMInstance< GUM_SCALAR >* >* > gum::prm::PRMSystem< GUM_SCALAR >::instanceMap_
protected

Mapping between a class and all it's PRMInstance in this system.

Definition at line 271 of file PRMSystem.h.

◆ nameMap_

template<typename GUM_SCALAR>
HashTable< std::string, PRMInstance< GUM_SCALAR >* > gum::prm::PRMSystem< GUM_SCALAR >::nameMap_
protected

The mapping between PRMInstance and their names.

Definition at line 268 of file PRMSystem.h.

◆ nodeIdMap_

template<typename GUM_SCALAR>
NodeProperty< PRMInstance< GUM_SCALAR >* > gum::prm::PRMSystem< GUM_SCALAR >::nodeIdMap_
protected

The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem.

Definition at line 265 of file PRMSystem.h.

◆ skeleton_

template<typename GUM_SCALAR>
DiGraph gum::prm::PRMSystem< GUM_SCALAR >::skeleton_
protected

The relational skeleton of this PRMSystem.

Definition at line 261 of file PRMSystem.h.


The documentation for this class was generated from the following files: