aGrUM  0.20.2
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 236 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 230 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 244 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 219 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 208 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 288 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:292
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:282

◆ 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_),
63  arrayMap_(from.arrayMap_) {
64  GUM_CONS_CPY(PRMSystem);
65  }
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:292
PRMSystem(const std::string &name)
Default constructor.
Definition: PRMSystem_tpl.h:41
DiGraph skeleton_
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:271
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:275
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:282
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:278
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:42

Member Function Documentation

◆ 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 68 of file PRMSystem_tpl.h.

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

◆ 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 520 of file PRMSystem_tpl.h.

521  {
522  try {
523  if (i->type().isSubTypeOf(*(arrayMap_[array].first))) {
524  NodeId id = add(i);
525  arrayMap_[array].second->insert(i);
526  return id;
527  } else {
528  GUM_ERROR(PRMTypeError,
529  "the given Instance<GUM_SCALAR> is of an incorrect "
530  "Class<GUM_SCALAR> type");
531  }
532  } catch (NotFound&) {
533  GUM_ERROR(NotFound, "found no array matching the given name");
534  }
535  }
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:292
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:68
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:54

◆ 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 380 of file PRMSystem_tpl.h.

381  {
382  return add(array, &i);
383  }
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:68

◆ 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 538 of file PRMSystem_tpl.h.

540  {
541  if (arrayMap_.exists(array)) {
542  GUM_ERROR(DuplicateElement,
543  "an array '" << array << "' is already in this System");
544  }
545 
546  arrayMap_.insert(array,
548  &type,
549  new Sequence< PRMInstance< GUM_SCALAR >* >()));
550  }
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:292
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:288
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:54

◆ 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 554 of file PRMSystem_tpl.h.

554  {
555  return nodeIdMap_.begin();
556  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:275

◆ 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 566 of file PRMSystem_tpl.h.

566  {
567  return nodeIdMap_.begin();
568  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:275

◆ 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 578 of file PRMSystem_tpl.h.

578  {
579  try {
580  return arrayMap_[a].second->begin();
581  } catch (NotFound&) {
582  GUM_ERROR(NotFound, "found no array matching the given name");
583  }
584  }
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:292
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 598 of file PRMSystem_tpl.h.

598  {
599  try {
600  return arrayMap_[a].second->begin();
601  } catch (NotFound&) {
602  GUM_ERROR(NotFound, "found no array matching the given name");
603  }
604  }
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:292
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 560 of file PRMSystem_tpl.h.

560  {
561  return nodeIdMap_.end();
562  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:275

◆ 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 572 of file PRMSystem_tpl.h.

572  {
573  return nodeIdMap_.end();
574  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:275

◆ 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 588 of file PRMSystem_tpl.h.

588  {
589  try {
590  return arrayMap_[a].second->end();
591  } catch (NotFound&) {
592  GUM_ERROR(NotFound, "found no array matching the given name");
593  }
594  }
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:292
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 608 of file PRMSystem_tpl.h.

608  {
609  try {
610  return arrayMap_[a].second->end();
611  } catch (NotFound&) {
612  GUM_ERROR(NotFound, "found no array matching the given name");
613  }
614  }
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:292
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 617 of file PRMSystem_tpl.h.

617  {
618  return nameMap_.exists(name) || arrayMap_.exists(name);
619  }
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:292
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:278

◆ 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 391 of file PRMSystem_tpl.h.

391  {
392  try {
393  return *(nodeIdMap_[id]);
394  } catch (NotFound&) {
395  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
396  }
397  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:275
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 401 of file PRMSystem_tpl.h.

401  {
402  try {
403  return *(nodeIdMap_[id]);
404  } catch (NotFound&) {
405  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
406  }
407  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:275
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 411 of file PRMSystem_tpl.h.

411  {
412  try {
413  return nodeIdMap_.keyByVal(const_cast< PRMInstance< GUM_SCALAR >* >(&i));
414  } catch (NotFound&) {
415  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
416  }
417  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:275
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 455 of file PRMSystem_tpl.h.

455  {
456  try {
457  return *(nameMap_[name]);
458  } catch (NotFound&) {
459  GUM_ERROR(NotFound,
460  "found no Instance<GUM_SCALAR> matching the given name");
461  }
462  }
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:278
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 466 of file PRMSystem_tpl.h.

466  {
467  try {
468  return *(nameMap_[name]);
469  } catch (NotFound&) {
470  GUM_ERROR(NotFound,
471  "found no Instance<GUM_SCALAR> matching the given name");
472  }
473  }
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:278
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 478 of file PRMSystem_tpl.h.

478  {
479  try {
480  return *(instanceMap_[const_cast< PRMClass< GUM_SCALAR >* >(&type)]);
481  } catch (NotFound&) {
482  GUM_ERROR(
483  NotFound,
484  "the given Class<GUM_SCALAR> has no instantiation in this System");
485  }
486  }
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:282
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 491 of file PRMSystem_tpl.h.

491  {
492  try {
493  return *(arrayMap_[name].second);
494  } catch (NotFound&) {
495  GUM_ERROR(NotFound, "found no array matching the given name");
496  }
497  }
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:292
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 501 of file PRMSystem_tpl.h.

501  {
502  try {
503  return *(arrayMap_[name].first);
504  } catch (NotFound&) {
505  GUM_ERROR(NotFound, "found no array matching the given name");
506  }
507  }
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:292
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 511 of file PRMSystem_tpl.h.

511  {
512  try {
513  return *(arrayMap_[name].first);
514  } catch (NotFound&) {
515  GUM_ERROR(NotFound, "found no array matching the given name");
516  }
517  }
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:292
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 147 of file PRMSystem_tpl.h.

150  {
151  factory.startVariableDeclaration();
152  factory.variableName(name);
153 
154  const DiscreteVariable& agg_var = elt.type().variable();
155 
156  VarType var_type = agg_var.varType();
157 
158  factory.variableType(var_type);
159 
160  switch (var_type) {
161  case VarType::Labelized: {
162  const auto l = static_cast< const LabelizedVariable& >(agg_var);
163  for (Idx i = 0; i < l.domainSize(); ++i) {
164  factory.addModality(l.label(i));
165  }
166  break;
167  }
168  case VarType::Discretized: {
169  const auto d
170  = static_cast< const DiscretizedVariable< GUM_SCALAR >& >(agg_var);
171  for (Idx i = 0; i < d.domainSize(); ++i) {
172  factory.addTick(d.tick(i));
173  }
174  break;
175  }
176  case VarType::Range: {
177  const auto r = static_cast< const RangeVariable& >(agg_var);
178  factory.addMin(r.minVal());
179  factory.addMax(r.maxVal());
180  break;
181  }
182  case VarType::Continuous:
183  // Todo Error
184  break;
185  }
186 
187  const PRMAggregate< GUM_SCALAR >& agg
188  = static_cast< const PRMAggregate< GUM_SCALAR >& >(elt);
189 
190  switch (agg.agg_type()) {
192  factory.setVariableCPTImplementation(
193  new aggregator::Min< GUM_SCALAR >());
194  break;
195  }
196 
198  factory.setVariableCPTImplementation(
199  new aggregator::Max< GUM_SCALAR >());
200  break;
201  }
202 
204  factory.setVariableCPTImplementation(
205  new aggregator::Exists< GUM_SCALAR >(agg.label()));
206  break;
207  }
208 
210  factory.setVariableCPTImplementation(
211  new aggregator::Forall< GUM_SCALAR >(agg.label()));
212  break;
213  }
214 
216  factory.setVariableCPTImplementation(
217  new aggregator::Count< GUM_SCALAR >(agg.label()));
218  break;
219  }
220 
222  factory.setVariableCPTImplementation(
223  new aggregator::Median< GUM_SCALAR >());
224  break;
225  }
226 
228  factory.setVariableCPTImplementation(
229  new aggregator::Amplitude< GUM_SCALAR >());
230  break;
231  }
232 
234  factory.setVariableCPTImplementation(new aggregator::Or< GUM_SCALAR >());
235  break;
236  }
237 
239  factory.setVariableCPTImplementation(
240  new aggregator::And< GUM_SCALAR >());
241  break;
242  }
243 
245  factory.setVariableCPTImplementation(
246  new aggregator::Sum< GUM_SCALAR >());
247  break;
248  }
249 
250  default: {
251  GUM_ERROR(OperationNotAllowed, "Aggregator not handled yet");
252  break;
253  }
254  }
255 
256  factory.endVariableDeclaration();
257  }
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:54

◆ 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 110 of file PRMSystem_tpl.h.

112  {
113  for (const auto node: instance.type().containerDag()) {
114  // Working a Class<GUM_SCALAR> level because PRMAggregate<GUM_SCALAR>
115  // are
116  // instantiated as PRMAttribute<GUM_SCALAR> in an
117  // PRMInstance<GUM_SCALAR>
118  switch (instance.type().get(node).elt_type()) {
120  // TODO: make a special case for noisy-or
121  std::stringstream elt_name;
122  elt_name << instance.name() << "."
123  << instance.type().get(node).safeName();
124  DiscreteVariable* var = instance.get(node).type().variable().clone();
125  var->setName(elt_name.str());
126  factory.setVariable(*var); // var is copied by the factory
127  delete var;
128  break;
129  }
130 
132  std::stringstream elt_name;
133  elt_name << instance.name() << "."
134  << instance.type().get(node).safeName();
135  groundAgg__(instance.type().get(node), elt_name.str(), factory);
136  break;
137  }
138 
139  default:
140  break;
141  /* Do nothing */;
142  }
143  }
144  }
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.

◆ 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 90 of file PRMSystem_tpl.h.

91  {
92  factory.startNetworkDeclaration();
93  factory.addNetworkProperty("name", name());
94  factory.endNetworkDeclaration();
95 
96  // Adding nodes
97  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end();
98  ++iter) {
99  groundAttr__(*(iter.val()), factory);
100  }
101 
102  // Adding arcs and filling CPTs
103  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end();
104  ++iter) {
105  groundRef__(*(iter.val()), factory);
106  }
107  }
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 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:219
void groundAttr__(const PRMInstance< GUM_SCALAR > &instance, BayesNetFactory< GUM_SCALAR > &factory) const
Method which ground Atttributes and Aggregators of an PRMInstance.
const iterator & end()
Returns a iterator at the end of the set of PRMInstance in this PRMSystem.

◆ 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 318 of file PRMSystem_tpl.h.

321  {
322  Bijection< const DiscreteVariable*, const DiscreteVariable* > bijection;
323  std::stringstream var_name;
324  var_name << instance.name() << "." << attr.safeName();
325  bijection.insert(&(attr.type().variable()),
326  &(factory.variable(var_name.str())));
327 
328  for (const auto parent: instance.type().containerDag().parents(attr.id())) {
329  switch (instance.type().get(parent).elt_type()) {
332  std::stringstream parent_name;
333  parent_name << instance.name() << "."
334  << instance.get(parent).safeName();
335  bijection.insert(&(instance.get(parent).type().variable()),
336  &(factory.variable(parent_name.str())));
337  break;
338  }
339 
341  std::stringstream parent_name;
342  const PRMSlotChain< GUM_SCALAR >& sc
343  = static_cast< const PRMSlotChain< GUM_SCALAR >& >(
344  instance.type().get(parent));
345  parent_name << instance.getInstance(sc.id()).name() << "."
346  << sc.lastElt().safeName();
347  bijection.insert(&(instance.getInstance(sc.id())
348  .get(sc.lastElt().safeName())
349  .type()
350  .variable()),
351  &(factory.variable(parent_name.str())));
352  break;
353  }
354 
355  default: {
356  GUM_ERROR(FatalError,
357  "invalid ClassElement<GUM_SCALAR> type as parent.");
358  break;
359  }
360  }
361  }
362 
363  // Copy Potential
364  // DO NOT USE MultiDimBijArray as they will wreck havok if you delete
365  // the prm befor its grounded BN (happens a lot in pyAgrum)
366  Potential< GUM_SCALAR >* p = new Potential< GUM_SCALAR >();
367  for (auto var: attr.cpf().variablesSequence()) {
368  p->add(*(bijection.second(var)));
369  }
370  Instantiation inst(attr.cpf()), jnst(*p);
371  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
372  inst.inc(), jnst.inc()) {
373  p->set(jnst, attr.cpf().get(inst));
374  }
375  GUM_ASSERT(inst.end() && jnst.end());
376  factory.setVariableCPT(var_name.str(), p, false);
377  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 260 of file PRMSystem_tpl.h.

262  {
263  for (const auto& elt: instance) {
264  std::stringstream elt_name;
265  elt_name << instance.name() << "." << elt.second->safeName();
266  factory.startParentsDeclaration(elt_name.str());
267 
268  for (const auto par:
269  instance.type().containerDag().parents(elt.second->id())) {
270  switch (instance.type().get(par).elt_type()) {
273  std::stringstream parent_name;
274  parent_name << instance.name() << "."
275  << instance.get(par).safeName();
276  factory.addParent(parent_name.str());
277  break;
278  }
279 
281  std::string parent_name
282  = static_cast< const PRMSlotChain< GUM_SCALAR >& >(
283  instance.type().get(par))
284  .lastElt()
285  .safeName();
286 
287  try {
288  for (const auto ref: instance.getInstances(par)) {
289  std::stringstream sBuff;
290  sBuff << ref->name() << "." << parent_name;
291  factory.addParent(sBuff.str());
292  }
293  } catch (NotFound&) {
294  // No instances for this slotchain
295  }
296 
297  break;
298  }
299 
300  default:
301  break;
302  /* nothing to do by default */
303  }
304  }
305 
306  factory.endParentsDeclaration();
307 
308  // Checking if we need to ground the Potential (only for class level
309  // attributes since
310  // aggregates Potentials are generated)
312  instance.type().get(elt.second->safeName())))
313  groundPotential__(instance, *elt.second, factory);
314  }
315  }
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.
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.

◆ instantiate()

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

Instantiate all the PRMInstance in this PRMSystem.

Definition at line 447 of file PRMSystem_tpl.h.

447  {
448  for (auto iter = begin(); iter != end(); ++iter) {
449  (*(iter.val())).instantiate();
450  }
451  }
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 442 of file PRMSystem_tpl.h.

442  {
443  return arrayMap_.exists(name);
444  }
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:292

◆ 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  {
110  return obj.obj_type() == prm_type::CLASS;
111  }
+ Here is the call graph for this function:

◆ isInstance() [1/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 437 of file PRMSystem_tpl.h.

437  {
438  return nameMap_.exists(name);
439  }
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:278

◆ isInstance() [2/2]

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 119 of file PRMObject.h.

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

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

◆ 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 430 of file PRMSystem_tpl.h.

431  {
432  return instanceMap_.exists(const_cast< PRMClass< GUM_SCALAR >* >(&c));
433  }
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:282

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 114 of file PRMObject.h.

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

114  {
115  return obj.obj_type() == prm_type::PRM_INTERFACE;
116  }
+ 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:207
+ 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; }
std::string name__
Definition: PRMObject.h:207
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
+ 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 420 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 48 of file PRMObject_inl.h.

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

48  {
49  return name__ != obj.name();
50  }
std::string name__
Definition: PRMObject.h:207
+ 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  {
43  return name__ == obj.name();
44  }
std::string name__
Definition: PRMObject.h:207
+ 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 425 of file PRMSystem_tpl.h.

425  {
426  return nodeIdMap_.size();
427  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:275

◆ 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 386 of file PRMSystem_tpl.h.

386  {
387  return skeleton_;
388  }
DiGraph skeleton_
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:271

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 292 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 282 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 278 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 275 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 271 of file PRMSystem.h.


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