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

A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantiated in PRMInstance. More...

#include <agrum/PRM/elements/PRMClass.h>

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

Public Member Functions

Constructors & destructor.
 PRMClass (const std::string &name)
 Default constructor. More...
 
 PRMClass (const std::string &name, PRMClass< GUM_SCALAR > &super, bool delayInheritance=false)
 Constructor for building a subclass of super. More...
 
 PRMClass (const std::string &name, const Set< PRMInterface< GUM_SCALAR > * > &set, bool delayInheritance=false)
 Constructor for building a Class<GUM_SCALAR> implementing several each interface in set. More...
 
 PRMClass (const std::string &name, PRMClass< GUM_SCALAR > &super, const Set< PRMInterface< GUM_SCALAR > * > &set, bool delayInheritance=false)
 Constructor for building a subclass of super and implementing each interface in set. More...
 
 PRMClass (const PRMClass< GUM_SCALAR > &source)=delete
 Copy constructor. More...
 
 PRMClass (const PRMClass< GUM_SCALAR > &&source)=delete
 Move constructor. More...
 
PRMClass< GUM_SCALAR > & operator= (const PRMClass< GUM_SCALAR > &source)=delete
 Copy operator. Don't use it. More...
 
PRMClass< GUM_SCALAR > & operator= (const PRMClass< GUM_SCALAR > &&source)=delete
 Move operator. Don't use it. More...
 
virtual ~PRMClass ()
 Destructor. More...
 
virtual PRMObject::prm_type obj_type () const
 Implementation of pure virtual method of PRMObject. More...
 
Graphical operator
PRMClassElement< GUM_SCALAR > & get (NodeId id)
 See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(NodeId). More...
 
const PRMClassElement< GUM_SCALAR > & get (NodeId id) const
 See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(NodeId). More...
 
PRMClassElement<GUM_SCALAR> getters and setters
virtual bool isOutputNode (const PRMClassElement< GUM_SCALAR > &elt) const
 Returns true if elt is an output node. More...
 
bool isCastDescendant (const std::string &safe_name) const
 Return true if the attribute named safe_name is a cast descendant. More...
 
PRMClassElement< GUM_SCALAR > & get (const std::string &name)
 See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(const std::string&). More...
 
const PRMClassElement< GUM_SCALAR > & get (const std::string &name) const
 See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(const std::string&). More...
 
virtual NodeId add (PRMClassElement< GUM_SCALAR > *elt)
 See gum::prm::add(PRMClassElement<GUM_SCALAR>*). More...
 
virtual NodeId overload (PRMClassElement< GUM_SCALAR > *elt)
 See gum::prm::overload(PRMClassElement<GUM_SCALAR>*). More...
 
virtual void addArc (const std::string &tail, const std::string &head)
 See gum::prm::PRMClassElementContainer<GUM_SCALAR>::addArc(). More...
 
const Set< PRMAttribute< GUM_SCALAR > *> & attributes () const
 Returns the set of PRMAttribute<GUM_SCALAR> of this Class<GUM_SCALAR>. More...
 
const Set< PRMParameter< GUM_SCALAR > *> & parameters () const
 Returns the set of parameters of this Class<GUM_SCALAR>. More...
 
HashTable< std::string, const PRMParameter< GUM_SCALAR > *> scope () const
 Returns all the parameters in the scope of this class. More...
 
const Set< PRMAggregate< GUM_SCALAR > *> & aggregates () const
 Returns the set of PRMAggregate<GUM_SCALAR> of this Class<GUM_SCALAR>. More...
 
const Set< PRMReferenceSlot< GUM_SCALAR > *> & referenceSlots () const
 Returns the set of PRMReferenceSlot<GUM_SCALAR> of this Class<GUM_SCALAR>. More...
 
const Set< PRMSlotChain< GUM_SCALAR > *> & slotChains () const
 Returns the set of PRMSlotChain<GUM_SCALAR> of this Class<GUM_SCALAR>. More...
 
Inheritance methods
virtual bool isSubTypeOf (const PRMClassElementContainer< GUM_SCALAR > &cec) const
 Test if this Class<GUM_SCALAR> is a subclass of cec. More...
 
const PRMClass< GUM_SCALAR > & super () const
 Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>. More...
 
const Set< PRMInterface< GUM_SCALAR > *> & implements () const
 Returns the Set of PRMInterface<GUM_SCALAR> implemented by this Class<GUM_SCALAR>. More...
 
const Set< PRMClass< GUM_SCALAR > *> & extensions () const
 Returns the set of Class<GUM_SCALAR> which are direct sub-Class<GUM_SCALAR> of this Class<GUM_SCALAR>. More...
 
Getters & setters operators
PRMClassElement< GUM_SCALAR > & operator[] (NodeId id)
 See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](NodeId). More...
 
const PRMClassElement< GUM_SCALAR > & operator[] (NodeId id) const
 See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](NodeId). More...
 
PRMClassElement< GUM_SCALAR > & operator[] (const std::string &name)
 See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](const std::string&). More...
 
const PRMClassElement< GUM_SCALAR > & operator[] (const std::string &name) const
 See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](const std::string&). More...
 
For custom inheritance
void inheritReferenceSlots ()
 
void inheritParameters ()
 
void inheritAttributes ()
 
void inheritAggregates ()
 
void inheritSlotChains ()
 
void initializeInheritance ()
 
void completeInheritance (const std::string &attr)
 
Getters on the gum::PRMClassElement<GUM_SCALAR>.
virtual bool belongsTo (const PRMClassElement< GUM_SCALAR > &elt) const
 Returns true if elt belongs to this PRMClassElementContainer. More...
 
virtual bool exists (const std::string &name) const
 Returns true if a member with the given name exists in this PRMClassElementContainer or in the PRMClassElementContainer hierarchy. More...
 
virtual bool isInputNode (const PRMClassElement< GUM_SCALAR > &elt) const
 Returns true if the node is an input node. More...
 
virtual void setInputNode (const PRMClassElement< GUM_SCALAR > &elt, bool b)
 Set the input flag value of id at b. More...
 
virtual void setOutputNode (const PRMClassElement< GUM_SCALAR > &elt, bool b)
 Set the output flag value of id at b. More...
 
virtual bool isInnerNode (const PRMClassElement< GUM_SCALAR > &elt) const
 Returns true if the node is an inner node. More...
 
Graphical operator
virtual bool exists (NodeId id) const
 Returns true if a member with the given id exists in this PRMClassElementContainer or in the PRMClassElementContainer hierarchy. More...
 
virtual const DAGcontainerDag () const
 Returns the gum::DAG of this PRMClassElementContainer. More...
 
Inheritance getters and setters
virtual bool isSuperTypeOf (const PRMClassElementContainer< GUM_SCALAR > &cec) const
 Test if this PRMClassElementContainer is a super type of cec. 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

virtual const DAGdag_ () const
 returns a constant reference over this interface's dag. More...
 
virtual DAGdag_ ()
 Returns a non constant reference over this PRMInterface<GUM_SCALAR>'s DAG. More...
 
void findAllSubtypes_ (Set< PRMClassElementContainer< GUM_SCALAR > * > &set)
 Fills set with all the subtypes of this Class<GUM_SCALAR>. More...
 
void updateDescendants_ (const PRMClassElement< GUM_SCALAR > &elt)
 See gum::prm::PRMClassElementContainer<GUM_SCALAR>(const PRMClassElement<GUM_SCALAR>&). More...
 
virtual std::pair< bool, bool > & getIOFlag_ (const PRMClassElement< GUM_SCALAR > &elt)
 Returns the IO flags of a PRMClassElement<GUM_SCALAR>. More...
 
virtual const std::pair< bool, bool > & getIOFlag_ (const PRMClassElement< GUM_SCALAR > &elt) const
 Returns the IO flags of a PRMClassElement<GUM_SCALAR>. More...
 
virtual void setIOFlag_ (const PRMClassElement< GUM_SCALAR > &elt, const std::pair< bool, bool > &flags)
 Defines the IO flags of a PRMClassElement<GUM_SCALAR>. More...
 
virtual void copyIOFlags_ (const PRMClassElementContainer< GUM_SCALAR > &c)
 Copy the IO Flags of c in this PRMClassElementContainer. More...
 

Friends

class PRMInterface< GUM_SCALAR >
 

PRMClassElement<GUM_SCALAR> members

HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
 Mapping between a member's name and itself. Used for fast access to a member given it's name. More...
 
Set< PRMAttribute< GUM_SCALAR > *> _attributes_
 The sequence of PRMAttribute<GUM_SCALAR>s. More...
 
Set< PRMReferenceSlot< GUM_SCALAR > *> _referenceSlots_
 The sequence of PRMReferenceSlot<GUM_SCALAR>. More...
 
Set< PRMAggregate< GUM_SCALAR > *> _aggregates_
 The sequence of aggregate. More...
 
Set< PRMSlotChain< GUM_SCALAR > *> _slotChains_
 The set of gum::PRMSlotChain<GUM_SCALAR>s. More...
 
Set< PRMParameter< GUM_SCALAR > *> _parameters_
 The Set of parameters in this Class<GUM_SCALAR>. More...
 
void _addCastDescendants_ (PRMClassElement< GUM_SCALAR > *attr)
 Recursively adds cast descendant of attr in this Class<GUM_SCALAR>. More...
 
void _addCastDescendants_ (PRMAttribute< GUM_SCALAR > *start, PRMAttribute< GUM_SCALAR > *end)
 Recursively adds cast descendant from start to end in this Class<GUM_SCALAR>. More...
 

Inheritance members

PRMClass< GUM_SCALAR > * _superClass_
 The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this. Note that this is first searched for gum::PRMClassElement<GUM_SCALAR>. More...
 
Set< PRMInterface< GUM_SCALAR > *> * _implements_
 The Set of implemented interface of this. More...
 
Set< PRMClass< GUM_SCALAR > *> _extensions_
 The set of Class<GUM_SCALAR> which are extension of this Class<GUM_SCALAR> (i.e. direct subtypes). More...
 
Bijection< const DiscreteVariable *, const DiscreteVariable *> * _bijection_
 The bijection between variables in super and variables in this The bijection's firsts are attributes in this and its seconds are attributes in c. More...
 
HashFunc< PRMClassElementContainer< GUM_SCALAR > *> _dummy_hashfunc_
 a dummy member used to fix a compilation issue in clang4 More...
 
void _inheritClass_ (const PRMClass< GUM_SCALAR > &c)
 Proceed with the copy when this inherits c. More...
 
void _implementInterfaces_ (bool delayInheritance)
 Proceed with the implementation of interfaces. More...
 
void _checkInterfaces_ (PRMClassElement< GUM_SCALAR > *elt)
 Check that a given element respects all the class interfaces. More...
 
void _checkInterface_ (PRMClassElement< GUM_SCALAR > *elt, PRMInterface< GUM_SCALAR > *i)
 Check that a given element respects a specific interface. More...
 
void _checkRefInterfaces_ (PRMReferenceSlot< GUM_SCALAR > *elt)
 Check that a given element respects all the class interfaces. More...
 
void _checkRefInterface_ (PRMReferenceSlot< GUM_SCALAR > *elt, PRMInterface< GUM_SCALAR > *i)
 Check that a given element respects a specific interface. More...
 
void _addIOInterfaceFlags_ (PRMClassElement< GUM_SCALAR > *elt)
 Check if elt is present in an implementation. If it is, its IO flags are updated. More...
 
void _addExtension_ (PRMClass< GUM_SCALAR > *c)
 This method is called when a sub-Class<GUM_SCALAR> of this Class<GUM_SCALAR> is created. More...
 
bool _checkOverloadLegality_ (const PRMClassElement< GUM_SCALAR > *overloaded, const PRMClassElement< GUM_SCALAR > *overloader)
 Return true of overloaded can be overload by overloader. More...
 
void _overloadAttribute_ (PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
 Overloads an attribute. More...
 
void _overloadAggregate_ (PRMAggregate< GUM_SCALAR > *overloader, PRMClassElement< GUM_SCALAR > *overloaded)
 Overloads an aggregate. More...
 
void _overloadReference_ (PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
 Overloads a reference slot. More...
 
void _overloadParameter_ (PRMParameter< GUM_SCALAR > *overloader, PRMParameter< GUM_SCALAR > *overloaded)
 Overloads a parameter. 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...
 

Detailed Description

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

A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantiated in PRMInstance.

See also
PRMClassElement

Definition at line 65 of file PRMClass.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

◆ PRMClass() [1/6]

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

Default constructor.

Parameters
nameThe class name.

Definition at line 39 of file PRMClass_tpl.h.

39  :
40  PRMClassElementContainer< GUM_SCALAR >(name), _superClass_(nullptr), _implements_(nullptr),
41  _bijection_(nullptr) {
42  GUM_CONSTRUCTOR(PRMClass);
43  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:39
Bijection< const DiscreteVariable *, const DiscreteVariable *> * _bijection_
The bijection between variables in super and variables in this The bijection&#39;s firsts are attributes ...
Definition: PRMClass.h:397
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ PRMClass() [2/6]

template<typename GUM_SCALAR>
gum::prm::PRMClass< GUM_SCALAR >::PRMClass ( const std::string &  name,
PRMClass< GUM_SCALAR > &  super,
bool  delayInheritance = false 
)

Constructor for building a subclass of super.

Parameters
nameThe subclass name.
superThe super Class<GUM_SCALAR> of this.
delayInheritanceIf true, inheritance will be delayed.

Definition at line 46 of file PRMClass_tpl.h.

48  :
49  PRMClassElementContainer< GUM_SCALAR >(name),
50  _superClass_(&super), _implements_(nullptr),
51  _bijection_(new Bijection< const DiscreteVariable*, const DiscreteVariable* >()) {
52  GUM_CONSTRUCTOR(PRMClass);
53  if (!delayInheritance) {
54  _dag_ = super.containerDag();
56  }
57  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
void _inheritClass_(const PRMClass< GUM_SCALAR > &c)
Proceed with the copy when this inherits c.
Definition: PRMClass_tpl.h:299
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:39
Bijection< const DiscreteVariable *, const DiscreteVariable *> * _bijection_
The bijection between variables in super and variables in this The bijection&#39;s firsts are attributes ...
Definition: PRMClass.h:397
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ PRMClass() [3/6]

template<typename GUM_SCALAR>
gum::prm::PRMClass< GUM_SCALAR >::PRMClass ( const std::string &  name,
const Set< PRMInterface< GUM_SCALAR > * > &  set,
bool  delayInheritance = false 
)

Constructor for building a Class<GUM_SCALAR> implementing several each interface in set.

Parameters
nameThe sub class name.
setThe Set of implemented interfaces.
delayInheritanceIf true, inheritance will be delayed.

Definition at line 60 of file PRMClass_tpl.h.

62  :
63  PRMClassElementContainer< GUM_SCALAR >(name),
64  _superClass_(nullptr), _implements_(new Set< PRMInterface< GUM_SCALAR >* >(set)),
65  _bijection_(nullptr) {
66  GUM_CONSTRUCTOR(PRMClass);
67 
68  if (!delayInheritance) { _implementInterfaces_(false); }
69  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
friend class PRMInterface< GUM_SCALAR >
Definition: PRMClass.h:66
void _implementInterfaces_(bool delayInheritance)
Proceed with the implementation of interfaces.
Definition: PRMClass_tpl.h:98
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:39
Bijection< const DiscreteVariable *, const DiscreteVariable *> * _bijection_
The bijection between variables in super and variables in this The bijection&#39;s firsts are attributes ...
Definition: PRMClass.h:397
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ PRMClass() [4/6]

template<typename GUM_SCALAR>
gum::prm::PRMClass< GUM_SCALAR >::PRMClass ( const std::string &  name,
PRMClass< GUM_SCALAR > &  super,
const Set< PRMInterface< GUM_SCALAR > * > &  set,
bool  delayInheritance = false 
)

Constructor for building a subclass of super and implementing each interface in set.

Parameters
nameThe sub class name.
superThe super Class<GUM_SCALAR> of this.
setThe Set of implemented interfaces.
delayInheritanceIf true, inheritance will be delayed.

Definition at line 72 of file PRMClass_tpl.h.

75  :
76  PRMClassElementContainer< GUM_SCALAR >(name),
77  _superClass_(&super), _implements_(nullptr),
78  _bijection_(new Bijection< const DiscreteVariable*, const DiscreteVariable* >()) {
79  GUM_CONSTRUCTOR(PRMClass);
80  if (!delayInheritance) {
81  _dag_ = super.containerDag();
83  }
84 
85  // Adding other implementation
86  if (_implements_ == nullptr) { // super has not created _implements_
87  _implements_ = new Set< PRMInterface< GUM_SCALAR >* >(set);
88  } else { // we just add the new implementations
89  for (const auto elt: set) {
90  _implements_->insert(elt);
91  }
92  }
93 
94  if (!delayInheritance) { _implementInterfaces_(false); }
95  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
void _inheritClass_(const PRMClass< GUM_SCALAR > &c)
Proceed with the copy when this inherits c.
Definition: PRMClass_tpl.h:299
void _implementInterfaces_(bool delayInheritance)
Proceed with the implementation of interfaces.
Definition: PRMClass_tpl.h:98
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:39
Bijection< const DiscreteVariable *, const DiscreteVariable *> * _bijection_
The bijection between variables in super and variables in this The bijection&#39;s firsts are attributes ...
Definition: PRMClass.h:397
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ PRMClass() [5/6]

template<typename GUM_SCALAR>
gum::prm::PRMClass< GUM_SCALAR >::PRMClass ( const PRMClass< GUM_SCALAR > &  source)
delete

Copy constructor.

◆ PRMClass() [6/6]

template<typename GUM_SCALAR>
gum::prm::PRMClass< GUM_SCALAR >::PRMClass ( const PRMClass< GUM_SCALAR > &&  source)
delete

Move constructor.

◆ ~PRMClass()

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

Destructor.

Definition at line 115 of file PRMClass_tpl.h.

115  {
116  GUM_DESTRUCTOR(PRMClass);
117 
118  for (const auto& elt: _nodeIdMap_) {
119  delete elt.second;
120  }
121 
122  if (_implements_) { delete _implements_; }
123 
124  if (_bijection_) { delete _bijection_; }
125  }
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:39
Bijection< const DiscreteVariable *, const DiscreteVariable *> * _bijection_
The bijection between variables in super and variables in this The bijection&#39;s firsts are attributes ...
Definition: PRMClass.h:397
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341

Member Function Documentation

◆ _addCastDescendants_() [1/2]

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::_addCastDescendants_ ( PRMClassElement< GUM_SCALAR > *  attr)
private

Recursively adds cast descendant of attr in this Class<GUM_SCALAR>.

Definition at line 666 of file PRMClass_tpl.h.

666  {
667  auto parent = attr;
668  PRMAttribute< GUM_SCALAR >* child = 0;
669 
670  while (parent->type().isSubType()) {
671  child = parent->getCastDescendant();
672 
673  // Check if id was reserved by one of the class interfaces
674  bool found = false;
675  try {
676  for (auto i: implements()) {
677  if (i->exists(child->safeName())) {
678  child->setId(i->get(child->safeName()).id());
679  found = true;
680  break;
681  }
682  }
683  } catch (NotFound&) {
684  // No interface
685  }
686  if (!found) {
687  child->setId(nextNodeId());
688  _dag_.addNodeWithId(child->id());
689  }
690  _nodeIdMap_.insert(child->id(), child);
691  // Only use child's safe name when adding to the name map!
692  _nameMap_.insert(child->safeName(), child);
693  _attributes_.insert(child);
694  // Do not use Class<GUM_SCALAR>::insertArc(), child's CPF is already
695  // initialized properly
696  _dag_.addArc(parent->id(), child->id());
697 
698  parent = child;
699  }
700  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
const Set< PRMInterface< GUM_SCALAR > *> & implements() const
Returns the Set of PRMInterface<GUM_SCALAR> implemented by this Class<GUM_SCALAR>.
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
Set< PRMAttribute< GUM_SCALAR > *> _attributes_
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:354
void addArc(NodeId tail, NodeId head) final
insert a new arc into the directed graph
Definition: DAG_inl.h:42
NodeId nextNodeId()
Returns the next value of an unique counter for PRM&#39;s node id.
Definition: utils_prm.cpp:64
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337

◆ _addCastDescendants_() [2/2]

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::_addCastDescendants_ ( PRMAttribute< GUM_SCALAR > *  start,
PRMAttribute< GUM_SCALAR > *  end 
)
private

Recursively adds cast descendant from start to end in this Class<GUM_SCALAR>.

Definition at line 898 of file PRMClass_tpl.h.

899  {
900  PRMAttribute< GUM_SCALAR >* parent = start;
901  PRMAttribute< GUM_SCALAR >* child = 0;
902 
903  while (parent->type().superType() != end->type()) {
904  child = parent->getCastDescendant();
905  child->setId(nextNodeId());
906  _nodeIdMap_.insert(child->id(), child);
907  _dag_.addNodeWithId(child->id());
908  // Only use child's safe name when adding to the name map!
909  _nameMap_.insert(child->safeName(), child);
910  _attributes_.insert(child);
911  _addIOInterfaceFlags_(child);
912  // Do not use Class<GUM_SCALAR>::insertArc(), child's CPF is already
913  // initialized properly
914  _dag_.addArc(parent->id(), child->id());
915  parent = child;
916  }
917 
918  parent->setAsCastDescendant(end);
919  _dag_.addArc(parent->id(), end->id());
920  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
Set< PRMAttribute< GUM_SCALAR > *> _attributes_
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:354
void addArc(NodeId tail, NodeId head) final
insert a new arc into the directed graph
Definition: DAG_inl.h:42
void _addIOInterfaceFlags_(PRMClassElement< GUM_SCALAR > *elt)
Check if elt is present in an implementation. If it is, its IO flags are updated. ...
Definition: PRMClass_tpl.h:932
NodeId nextNodeId()
Returns the next value of an unique counter for PRM&#39;s node id.
Definition: utils_prm.cpp:64
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337

◆ _addExtension_()

template<typename GUM_SCALAR>
INLINE void gum::prm::PRMClass< GUM_SCALAR >::_addExtension_ ( PRMClass< GUM_SCALAR > *  c)
private

This method is called when a sub-Class<GUM_SCALAR> of this Class<GUM_SCALAR> is created.

Parameters
cThe Class<GUM_SCALAR> added as a direct sub-Class<GUM_SCALAR> of this.
Exceptions
DuplicateElementRaised if c is already a sub-Class<GUM_SCALAR> of this.

Definition at line 1186 of file PRMClass_tpl.h.

1186  {
1187  _extensions_.insert(c);
1188  }
Set< PRMClass< GUM_SCALAR > *> _extensions_
The set of Class<GUM_SCALAR> which are extension of this Class<GUM_SCALAR> (i.e. direct subtypes)...
Definition: PRMClass.h:392

◆ _addIOInterfaceFlags_()

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::_addIOInterfaceFlags_ ( PRMClassElement< GUM_SCALAR > *  elt)
private

Check if elt is present in an implementation. If it is, its IO flags are updated.

Definition at line 932 of file PRMClass_tpl.h.

932  {
933  // We only add IO Flags if elt matches is required by and interface
934  if (_implements_ != nullptr) {
935  for (const auto impl: *_implements_) {
937  while (super) {
938  // If the attribute is defined in an interface, we set it as an
939  // OutputNode
940  if (impl->exists(elt->name())) {
941  try {
942  this->getIOFlag_(*elt).second = true;
943  } catch (NotFound&) { this->setIOFlag_(*elt, std::make_pair(false, true)); }
944  }
945  try {
946  super = &(super->super());
947  } catch (NotFound&) { super = nullptr; }
948  }
949  }
950  }
951  }
virtual std::pair< bool, bool > & getIOFlag_(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
friend class PRMInterface< GUM_SCALAR >
Definition: PRMClass.h:66
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
virtual void setIOFlag_(const PRMClassElement< GUM_SCALAR > &elt, const std::pair< bool, bool > &flags)
Defines the IO flags of a PRMClassElement<GUM_SCALAR>.
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.

◆ _checkInterface_()

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::_checkInterface_ ( PRMClassElement< GUM_SCALAR > *  elt,
PRMInterface< GUM_SCALAR > *  i 
)
private

Check that a given element respects a specific interface.

Definition at line 518 of file PRMClass_tpl.h.

519  {
520  const auto& i_elt = i->get(elt->name());
521  bool is_attr = PRMClassElement< GUM_SCALAR >::isAttribute(i_elt);
522  bool is_agg = PRMClassElement< GUM_SCALAR >::isAggregate(i_elt);
523 
524  if (!(is_attr || is_agg)) {
525  GUM_ERROR(OperationNotAllowed, "Class does not respect it's interface")
526  }
527 
528  if (!elt->type().isSubTypeOf(i_elt.type())) {
529  GUM_ERROR(OperationNotAllowed, "Attribute type does not respect class interface")
530  }
531 
532  if (elt->type() != i_elt.type()) {
533  if (!this->exists(i_elt.safeName())) {
534  GUM_ERROR(OperationNotAllowed, "Attribute type does not respect class interface")
535  }
536  elt = &(this->get(i_elt.safeName()));
537  }
538 
539  // Node must be reserved by constructor
540  if (!_dag_.existsNode(i_elt.id())) {
541  GUM_ERROR(FatalError, "Class does not reserved implemented nodes")
542  }
543 
544  // Removing unused node and changing to proper node
545  if (elt->id() != i_elt.id()) {
546  // Update cast descendants
547  for (auto child: _dag_.children(elt->id())) {
548  _dag_.addArc(i_elt.id(), child);
549  }
550  _dag_.eraseNode(elt->id());
551  }
552  _nodeIdMap_.erase(elt->id());
553  elt->setId(i_elt.id());
554  _nodeIdMap_.insert(elt->id(), elt);
555  }
void addArc(NodeId tail, NodeId head) final
insert a new arc into the directed graph
Definition: DAG_inl.h:42
NodeSet children(const NodeSet &ids) const
returns the set of children of a set of nodes
virtual bool exists(const std::string &name) const
Returns true if a member with the given name exists in this PRMClassElementContainer or in the PRMCla...
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
static INLINE bool isAggregate(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMAggregate.
virtual void eraseNode(const NodeId id)
remove a node and its adjacent arcs from the graph
Definition: diGraph_inl.h:67
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ _checkInterfaces_()

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::_checkInterfaces_ ( PRMClassElement< GUM_SCALAR > *  elt)
private

Check that a given element respects all the class interfaces.

Definition at line 507 of file PRMClass_tpl.h.

507  {
508  try {
509  for (auto i: implements()) {
510  if (i->exists(elt->name())) { _checkInterface_(elt, i); }
511  }
512  } catch (NotFound&) {
513  // No interface
514  }
515  }
const Set< PRMInterface< GUM_SCALAR > *> & implements() const
Returns the Set of PRMInterface<GUM_SCALAR> implemented by this Class<GUM_SCALAR>.
void _checkInterface_(PRMClassElement< GUM_SCALAR > *elt, PRMInterface< GUM_SCALAR > *i)
Check that a given element respects a specific interface.
Definition: PRMClass_tpl.h:518

◆ _checkOverloadLegality_()

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMClass< GUM_SCALAR >::_checkOverloadLegality_ ( const PRMClassElement< GUM_SCALAR > *  overloaded,
const PRMClassElement< GUM_SCALAR > *  overloader 
)
private

Return true of overloaded can be overload by overloader.

Definition at line 1143 of file PRMClass_tpl.h.

1145  {
1146  if (overloaded->elt_type() != overloader->elt_type()) { return false; }
1147 
1148  switch (overloaded->elt_type()) {
1150  if (!overloader->type().isSubTypeOf(overloaded->type())) { return false; }
1151  break;
1152  }
1153 
1155  const auto& new_slot_type
1156  = static_cast< const PRMReferenceSlot< GUM_SCALAR >* >(overloader)->slotType();
1157  const auto& old_slot_type
1158  = static_cast< const PRMReferenceSlot< GUM_SCALAR >* >(overloaded)->slotType();
1159 
1160  if (!new_slot_type.isSubTypeOf(old_slot_type)) { return false; }
1161 
1162  break;
1163  }
1164 
1166  auto overloaded_param = static_cast< const PRMParameter< GUM_SCALAR >* >(overloaded);
1167  auto overloader_param = static_cast< const PRMParameter< GUM_SCALAR >* >(overloader);
1168 
1169  return overloaded_param->valueType() == overloader_param->valueType();
1170  break;
1171  }
1172 
1173  default: {
1174  return false;
1175  }
1176  }
1177  return true;
1178  }

◆ _checkRefInterface_()

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::_checkRefInterface_ ( PRMReferenceSlot< GUM_SCALAR > *  elt,
PRMInterface< GUM_SCALAR > *  i 
)
private

Check that a given element respects a specific interface.

Definition at line 569 of file PRMClass_tpl.h.

570  {
571  auto& i_elt = i->get(ref->name());
572  if (i_elt.elt_type() != ref->elt_type()) {
573  GUM_ERROR(OperationNotAllowed, "Class does not respect it's interface")
574  }
575  auto& i_ref = static_cast< PRMReferenceSlot< GUM_SCALAR >& >(i_elt);
576  if (!ref->slotType().isSubTypeOf(i_ref.slotType())) {
577  GUM_ERROR(OperationNotAllowed, "ReferenceSlot type does not respect class interface")
578  }
579  // Node must be reserved by constructor
580  if (!_dag_.exists(i_ref.id())) {
581  GUM_ERROR(FatalError,
582  "class " << this->name() << " does not respect interface " << i->name()
583  << " implementation");
584  }
585  // Removing unused node and changin to propoer node
586  if (ref->id() != i_ref.id()) { _dag_.eraseNode(ref->id()); }
587  _nodeIdMap_.erase(ref->id());
588  ref->setId(i_ref.id());
589  _nodeIdMap_.insert(ref->id(), ref);
590  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
bool exists(const NodeId id) const
alias for existsNode
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
virtual void eraseNode(const NodeId id)
remove a node and its adjacent arcs from the graph
Definition: diGraph_inl.h:67
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ _checkRefInterfaces_()

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::_checkRefInterfaces_ ( PRMReferenceSlot< GUM_SCALAR > *  elt)
private

Check that a given element respects all the class interfaces.

Definition at line 558 of file PRMClass_tpl.h.

558  {
559  try {
560  for (auto i: implements()) {
561  if (i->exists(ref->name())) { _checkRefInterface_(ref, i); }
562  }
563  } catch (NotFound&) {
564  // No interface to check
565  }
566  }
const Set< PRMInterface< GUM_SCALAR > *> & implements() const
Returns the Set of PRMInterface<GUM_SCALAR> implemented by this Class<GUM_SCALAR>.
void _checkRefInterface_(PRMReferenceSlot< GUM_SCALAR > *elt, PRMInterface< GUM_SCALAR > *i)
Check that a given element respects a specific interface.
Definition: PRMClass_tpl.h:569

◆ _implementInterfaces_()

template<typename GUM_SCALAR >
void gum::prm::PRMClass< GUM_SCALAR >::_implementInterfaces_ ( bool  delayInheritance)
private

Proceed with the implementation of interfaces.

Definition at line 98 of file PRMClass_tpl.h.

98  {
99  for (const auto impl: *_implements_) {
100  impl->_addImplementation_(this);
101  if ((!_superClass_) || (!super().isSubTypeOf(*impl)) || delayedInheritance) {
102  // Reserve reference id in DAG
103  for (auto ref: impl->referenceSlots()) {
104  _dag_.addNodeWithId(ref->id());
105  }
106  // Reserve attribute id in DAG
107  for (auto attr: impl->attributes()) {
108  _dag_.addNodeWithId(attr->id());
109  }
110  }
111  }
112  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
virtual bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const
Test if this Class<GUM_SCALAR> is a subclass of cec.
Definition: PRMClass_tpl.h:428
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ _inheritClass_()

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::_inheritClass_ ( const PRMClass< GUM_SCALAR > &  c)
private

Proceed with the copy when this inherits c.

Definition at line 299 of file PRMClass_tpl.h.

299  {
300  if (_superClass_) {
301  _superClass_->_addExtension_(this);
302  // Adding implemented interfaces of c, if any
303  if (c._implements_) {
304  if (!_implements_) {
305  _implements_ = new Set< PRMInterface< GUM_SCALAR >* >(*(c._implements_));
306  } else {
307  for (auto i: *(c._implements_)) {
308  _implements_->insert(i);
309  }
310  }
311  }
312 
313  // Copying attributes, the bijection's firsts are attributes in this and
314  // its
315  // seconds are attributes
316  // in c.
317  Bijection< const DiscreteVariable*, const DiscreteVariable* > bij;
318 
319  // Copying parameters
320  for (const auto c_param: c._parameters_) {
321  auto param = new PRMParameter< GUM_SCALAR >(c_param->name(),
322  c_param->valueType(),
323  c_param->value());
324 
325  _parameters_.insert(param);
326 
327  param->setId(c_param->id());
328  _nodeIdMap_.insert(param->id(), param);
329  _nameMap_.insert(param->name(), param);
330  }
331 
332  // Copying attributes
333  for (const auto c_attr: c._attributes_) {
334  // using multiDimSparse to prevent unecessary memory allocation for
335  // large arrays (the potentials are copied latter)
336  auto attr = c_attr->newFactory(*this);
337 
338  bij.insert(&(c_attr->type().variable()), &(attr->type().variable()));
339  attr->setId(c_attr->id());
340  _nodeIdMap_.insert(attr->id(), attr);
341  _attributes_.insert(attr);
342 
343  if (c._nameMap_[c_attr->name()] == c._nameMap_[c_attr->safeName()]) {
344  _nameMap_.insert(attr->name(), attr);
345  }
346 
347  _nameMap_.insert(attr->safeName(), attr);
348  }
349 
350  // Copying aggregates
351  for (const auto c_agg: c._aggregates_) {
352  PRMAggregate< GUM_SCALAR >* agg = nullptr;
353 
354  try {
355  agg = new PRMAggregate< GUM_SCALAR >(c_agg->name(),
356  c_agg->agg_type(),
357  c_agg->type(),
358  c_agg->label());
359  } catch (OperationNotAllowed&) {
360  agg = new PRMAggregate< GUM_SCALAR >(c_agg->name(), c_agg->agg_type(), c_agg->type());
361  }
362 
363  bij.insert(&(c_agg->type().variable()), &(agg->type().variable()));
364  agg->setId(c_agg->id());
365  _nodeIdMap_.insert(agg->id(), agg);
366  _aggregates_.insert(agg);
367 
368  if (c._nameMap_[c_agg->name()] == c._nameMap_[c_agg->safeName()])
369  _nameMap_.insert(agg->name(), agg);
370 
371  _nameMap_.insert(agg->safeName(), agg);
372  }
373 
374  // Copying reference slots
375  for (const auto c_refslot: c._referenceSlots_) {
376  PRMReferenceSlot< GUM_SCALAR >* ref = new PRMReferenceSlot< GUM_SCALAR >(
377  c_refslot->name(),
378  const_cast< PRMClassElementContainer< GUM_SCALAR >& >(c_refslot->slotType()),
379  c_refslot->isArray());
380 
381  ref->setId(c_refslot->id());
382  _nodeIdMap_.insert(ref->id(), ref);
383  _referenceSlots_.insert(ref);
384 
385  if (c._nameMap_[c_refslot->name()] == c._nameMap_[c_refslot->safeName()])
386  _nameMap_.insert(ref->name(), ref);
387 
388  _nameMap_.insert(ref->safeName(), ref);
389  }
390 
391  // Copying slot chains
392  for (const auto c_slotchain: c._slotChains_) {
393  // We just need to change the first PRMReferenceSlot<GUM_SCALAR> in
394  // the
395  // chain
396  Sequence< PRMClassElement< GUM_SCALAR >* > chain(c_slotchain->chain());
397 
398  chain.setAtPos(0, _nameMap_[c_slotchain->chain().front()->name()]);
399 
400  PRMSlotChain< GUM_SCALAR >* sc
401  = new PRMSlotChain< GUM_SCALAR >(c_slotchain->name(), chain);
402  bij.insert(&(c_slotchain->type().variable()), &(sc->type().variable()));
403  sc->setId(c_slotchain->id());
404  _nodeIdMap_.insert(sc->id(), sc);
405  _slotChains_.insert(sc);
406 
407  _nameMap_.insert(sc->name(), sc);
408  _nameMap_.insert(sc->safeName(), sc);
409  }
410 
411  // Copying dependencies yield by arcs
412  for (const auto& arc: c.containerDag().arcs()) {
413  _nodeIdMap_[arc.tail()]->addChild(*(_nodeIdMap_[arc.head()]));
414  _nodeIdMap_[arc.head()]->addParent(*(_nodeIdMap_[arc.tail()]));
415  }
416 
417  // Copying the IO flag
418  this->copyIOFlags_(c);
419  // Copying content of CPF
420  for (const auto attr: c._attributes_) {
421  auto a = static_cast< PRMAttribute< GUM_SCALAR >* >(_nameMap_[attr->safeName()]);
422  a->copyCpf(bij, *attr);
423  }
424  }
425  }
Set< PRMAggregate< GUM_SCALAR > *> _aggregates_
The sequence of aggregate.
Definition: PRMClass.h:360
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
Set< PRMAttribute< GUM_SCALAR > *> _attributes_
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:354
Set< PRMParameter< GUM_SCALAR > *> _parameters_
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:366
Set< PRMSlotChain< GUM_SCALAR > *> _slotChains_
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:363
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
virtual void copyIOFlags_(const PRMClassElementContainer< GUM_SCALAR > &c)
Copy the IO Flags of c in this PRMClassElementContainer.
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
Set< PRMReferenceSlot< GUM_SCALAR > *> _referenceSlots_
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:357
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ _overloadAggregate_()

template<typename GUM_SCALAR>
INLINE void gum::prm::PRMClass< GUM_SCALAR >::_overloadAggregate_ ( PRMAggregate< GUM_SCALAR > *  overloader,
PRMClassElement< GUM_SCALAR > *  overloaded 
)
private

Overloads an aggregate.

Definition at line 1136 of file PRMClass_tpl.h.

1137  {
1138  _nameMap_.insert(overloader->safeName(), overloader);
1139  _aggregates_.insert(overloader);
1140  }
Set< PRMAggregate< GUM_SCALAR > *> _aggregates_
The sequence of aggregate.
Definition: PRMClass.h:360
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351

◆ _overloadAttribute_()

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::_overloadAttribute_ ( PRMAttribute< GUM_SCALAR > *  overloader,
PRMAttribute< GUM_SCALAR > *  overloaded 
)
private

Overloads an attribute.

Definition at line 765 of file PRMClass_tpl.h.

766  {
767  _dag_.eraseParents(overloaded->id());
768 
769  // Checking if we have to add cast descendant
770  if (overloader->type() != overloaded->type()) {
771  overloader->setId(nextNodeId());
772  _dag_.addNodeWithId(overloader->id());
773  _nodeIdMap_.insert(overloader->id(), overloader);
774  _nameMap_[overloader->name()] = overloader;
775  _nameMap_.insert(overloader->safeName(), overloader);
776  _attributes_.insert(overloader);
777  _addCastDescendants_(overloader, overloaded);
778  } else {
779  overloader->setId(overloaded->id());
780  _nodeIdMap_[overloader->id()] = overloader;
781  _nameMap_[overloader->name()] = overloader;
782  _nameMap_[overloader->safeName()] = overloader;
783  _attributes_.erase(overloaded);
784  _attributes_.insert(overloader);
785  overloader->overload(overloaded);
786  delete overloaded;
787  }
788  }
void _addCastDescendants_(PRMClassElement< GUM_SCALAR > *attr)
Recursively adds cast descendant of attr in this Class<GUM_SCALAR>.
Definition: PRMClass_tpl.h:666
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
Set< PRMAttribute< GUM_SCALAR > *> _attributes_
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:354
NodeId nextNodeId()
Returns the next value of an unique counter for PRM&#39;s node id.
Definition: utils_prm.cpp:64
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
void eraseParents(NodeId id)
erase all the parents of a given node
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337

◆ _overloadParameter_()

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::_overloadParameter_ ( PRMParameter< GUM_SCALAR > *  overloader,
PRMParameter< GUM_SCALAR > *  overloaded 
)
private

Overloads a parameter.

Definition at line 886 of file PRMClass_tpl.h.

887  {
888  overloader->setId(overloaded->id());
889  _nodeIdMap_[overloader->id()] = overloader;
890  _nameMap_[overloader->name()] = overloader;
891  _nameMap_[overloader->safeName()] = overloader;
892  _parameters_.erase(overloaded);
893  _parameters_.insert(overloader);
894  delete overloaded;
895  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
Set< PRMParameter< GUM_SCALAR > *> _parameters_
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:366
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341

◆ _overloadReference_()

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::_overloadReference_ ( PRMReferenceSlot< GUM_SCALAR > *  overloader,
PRMReferenceSlot< GUM_SCALAR > *  overloaded 
)
private

Overloads a reference slot.

Definition at line 791 of file PRMClass_tpl.h.

792  {
793  // Adding overloading reference
794  overloader->setId(overloaded->id());
795  _nodeIdMap_[overloader->id()] = overloader;
796  _nameMap_[overloader->name()] = overloader;
797  _nameMap_.insert(overloader->safeName(), overloader);
798  _referenceSlots_.insert(overloader);
799  PRMSlotChain< GUM_SCALAR >* sc = 0;
800  PRMReferenceSlot< GUM_SCALAR >* ref = 0;
801  PRMClassElement< GUM_SCALAR >* next = 0;
802  std::vector< PRMSlotChain< GUM_SCALAR >* > toRemove, toAdd;
803 
804  // Updating PRMSlotChain<GUM_SCALAR> which started with overloaded
805  for (const auto slotchain: _slotChains_) {
806  // If the attribute pointed by this slotchain is overloaded, we need to
807  // change the slotchain
808  // names to it's safename version: ref.attr is replaced by
809  // ref.(type)attr.
810  if ((slotchain->chain().atPos(0) == overloaded)) {
811  Sequence< PRMClassElement< GUM_SCALAR >* > seq;
812  seq.insert(overloader);
813 
814  auto elt = ++(slotchain->chain().begin());
815 
816  while (elt != slotchain->chain().end()) {
817  ref = static_cast< PRMReferenceSlot< GUM_SCALAR >* >(seq.back());
818  next = &(ref->slotType().get((*elt)->name()));
819  seq.insert(next);
820  ++elt;
821  }
822 
823  // If the slotchain last element type changes, we change the slotchain
824  // to
825  // point towards the cast decendant
826  // with the correct type
827  if (seq.back()->type() != slotchain->lastElt().type()) {
828  seq.erase(seq.back());
829  seq.insert(&(static_cast< PRMReferenceSlot< GUM_SCALAR >* >(seq.back())
830  ->slotType()
831  .get(slotchain->lastElt().safeName())));
832  std::string sc_name;
833  std::string dot = ".";
834 
835  for (Size i = 0; i < seq.size() - 1; ++i) {
836  sc_name += seq.atPos(i)->name() + dot;
837  }
838 
839  sc_name += seq.back()->safeName();
840  sc = new PRMSlotChain< GUM_SCALAR >(sc_name, seq);
841  sc->setId(slotchain->id());
842 
843  for (const auto child: this->containerDag().children(sc->id())) {
844  auto& elt = get(child);
846  auto& attr = static_cast< PRMAttribute< GUM_SCALAR >& >(elt);
847  auto& old_type = slotchain->lastElt().type();
848  auto& new_type = sc->lastElt().type();
849  attr.swap(old_type, new_type);
850  } else {
851  GUM_ERROR(OperationNotAllowed, "unexpected ClassElement")
852  // get( child ).cpf().replace(
853  // slotchain->lastElt().type().variable(),
854  // sc->lastElt().type().variable() );
855  }
856  }
857 
858  toAdd.push_back(sc);
859  toRemove.push_back(slotchain);
860  } else {
861  // Types are identical, we just need to change the first reference
862  slotchain->chain().setAtPos(0, overloader);
863  }
864  }
865  }
866 
867  for (const auto torem: toRemove) {
868  _nameMap_.erase(torem->name());
869  _slotChains_.erase(torem);
870  delete torem;
871  }
872 
873  for (const auto toadd: toAdd) {
874  _nameMap_.insert(toadd->name(), toadd);
875  _nodeIdMap_[toadd->id()] = toadd;
876  _slotChains_.insert(sc);
877  }
878 
879  // Removing overloaded PRMReferenceSlot<GUM_SCALAR>
880  _referenceSlots_.erase(overloaded);
881  _nameMap_.erase(overloaded->safeName());
882  delete overloaded;
883  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
NodeSet children(const NodeSet &ids) const
returns the set of children of a set of nodes
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
Set< PRMSlotChain< GUM_SCALAR > *> _slotChains_
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:363
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
Set< PRMReferenceSlot< GUM_SCALAR > *> _referenceSlots_
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:357
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
virtual const DAG & containerDag() const
Returns the gum::DAG of this PRMClassElementContainer.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ add()

template<typename GUM_SCALAR>
NodeId gum::prm::PRMClass< GUM_SCALAR >::add ( PRMClassElement< GUM_SCALAR > *  elt)
virtual

See gum::prm::add(PRMClassElement<GUM_SCALAR>*).

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 593 of file PRMClass_tpl.h.

593  {
594  if (_nameMap_.exists(elt->name())) {
595  GUM_ERROR(DuplicateElement,
596  "name " << elt->name() << " already used by another ClassElement");
597  }
598 
599  elt->setId(nextNodeId());
600  _dag_.addNodeWithId(elt->id());
601  _nodeIdMap_.insert(elt->id(), elt);
602  _nameMap_.insert(elt->name(), elt);
603 
604  try {
605  _nameMap_.insert(elt->safeName(), elt);
606  } catch (DuplicateElement& e) {
609  throw DuplicateElement(e);
610  }
611  }
612 
613  switch (elt->elt_type()) {
615  _attributes_.insert(static_cast< PRMAttribute< GUM_SCALAR >* >(elt));
616  _addCastDescendants_(static_cast< PRMAttribute< GUM_SCALAR >* >(elt));
617 
618  // Update attribute or cast descendant id to respect implemented
619  // interface
620  _checkInterfaces_(elt);
621 
623  break;
624  }
625 
627  _aggregates_.insert(static_cast< PRMAggregate< GUM_SCALAR >* >(elt));
628  _addCastDescendants_(static_cast< PRMAttribute< GUM_SCALAR >* >(elt));
629 
630  // Update attribute or cast descendant id to respect implemented
631  // interface
632  _checkInterfaces_(elt);
633 
635  break;
636  }
637 
639  auto ref = static_cast< PRMReferenceSlot< GUM_SCALAR >* >(elt);
640  _referenceSlots_.insert(ref);
641 
642  // Updating ref's id if ref implements an interface
644  break;
645  }
646 
648  _slotChains_.insert(static_cast< PRMSlotChain< GUM_SCALAR >* >(elt));
649  break;
650  }
651 
653  _parameters_.insert(static_cast< PRMParameter< GUM_SCALAR >* >(elt));
654  break;
655  }
656 
657  default: {
658  GUM_ERROR(FatalError, "unknown ClassElement<GUM_SCALAR> type")
659  }
660  }
661 
662  return elt->id();
663  }
Set< PRMAggregate< GUM_SCALAR > *> _aggregates_
The sequence of aggregate.
Definition: PRMClass.h:360
void _addCastDescendants_(PRMClassElement< GUM_SCALAR > *attr)
Recursively adds cast descendant of attr in this Class<GUM_SCALAR>.
Definition: PRMClass_tpl.h:666
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
Set< PRMAttribute< GUM_SCALAR > *> _attributes_
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:354
static INLINE bool isParameter(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMParameter.
void _checkInterfaces_(PRMClassElement< GUM_SCALAR > *elt)
Check that a given element respects all the class interfaces.
Definition: PRMClass_tpl.h:507
Set< PRMParameter< GUM_SCALAR > *> _parameters_
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:366
void _addIOInterfaceFlags_(PRMClassElement< GUM_SCALAR > *elt)
Check if elt is present in an implementation. If it is, its IO flags are updated. ...
Definition: PRMClass_tpl.h:932
void _checkRefInterfaces_(PRMReferenceSlot< GUM_SCALAR > *elt)
Check that a given element respects all the class interfaces.
Definition: PRMClass_tpl.h:558
Set< PRMSlotChain< GUM_SCALAR > *> _slotChains_
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:363
NodeId nextNodeId()
Returns the next value of an unique counter for PRM&#39;s node id.
Definition: utils_prm.cpp:64
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
Set< PRMReferenceSlot< GUM_SCALAR > *> _referenceSlots_
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:357
static INLINE bool isSlotChain(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMSlotChain.
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ addArc()

template<typename GUM_SCALAR >
void gum::prm::PRMClass< GUM_SCALAR >::addArc ( const std::string &  tail,
const std::string &  head 
)
virtual

See gum::prm::PRMClassElementContainer<GUM_SCALAR>::addArc().

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 464 of file PRMClass_tpl.h.

465  {
466  PRMClassElement< GUM_SCALAR >* tail = 0;
467  PRMClassElement< GUM_SCALAR >* head = 0;
468 
469  try {
470  tail = _nameMap_[tail_name];
471  head = _nameMap_[head_name];
472  } catch (NotFound&) {
473  GUM_ERROR(NotFound, "tail and/or head of arc does not exists in this Class")
474  }
475 
476  if ((tail->elt_type() == PRMClassElement< GUM_SCALAR >::prm_refslot)
477  || (head->elt_type() == PRMClassElement< GUM_SCALAR >::prm_refslot)) {
478  GUM_ERROR(OperationNotAllowed,
479  "a PRMReferenceSlot<GUM_SCALAR> can "
480  "not on neither side of an arc");
481  }
482 
483  if ((tail->elt_type() == PRMClassElement< GUM_SCALAR >::prm_slotchain)
484  && (head->elt_type() == PRMClassElement< GUM_SCALAR >::prm_slotchain)) {
485  GUM_ERROR(OperationNotAllowed,
486  "illegal insertion of an arc between two SlotChain<GUM_SCALAR>")
487  }
488 
489  if (!_dag_.existsArc(Arc(tail->id(), head->id()))) {
490  _dag_.addArc(tail->id(), head->id());
491  } else {
492  GUM_ERROR(DuplicateElement, "duplicate arc " << tail_name << "->" << head_name)
493  }
494 
495  get(tail->id()).addChild(get(head->id()));
496  get(head->id()).addParent(get(tail->id()));
497 
498  // Defining input / output nodes
499  if (tail->elt_type() == PRMClassElement< GUM_SCALAR >::prm_slotchain) {
500  PRMSlotChain< GUM_SCALAR >* sc = static_cast< PRMSlotChain< GUM_SCALAR >* >(tail);
501  this->setInputNode(*head, true);
502  sc->end().setOutputNode(sc->end().get(sc->lastElt().safeName()), true);
503  }
504  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
void addArc(NodeId tail, NodeId head) final
insert a new arc into the directed graph
Definition: DAG_inl.h:42
virtual void setInputNode(const PRMClassElement< GUM_SCALAR > &elt, bool b)
Set the input flag value of id at b.
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
bool existsArc(const Arc &arc) const
indicates whether a given arc exists
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ aggregates()

template<typename GUM_SCALAR >
INLINE const Set< PRMAggregate< GUM_SCALAR > *> & gum::prm::PRMClass< GUM_SCALAR >::aggregates ( ) const

Returns the set of PRMAggregate<GUM_SCALAR> of this Class<GUM_SCALAR>.

Returns
Returns the set of PRMAggregate<GUM_SCALAR> of this Class<GUM_SCALAR>.

Definition at line 1078 of file PRMClass_tpl.h.

1078  {
1079  return _aggregates_;
1080  }
Set< PRMAggregate< GUM_SCALAR > *> _aggregates_
The sequence of aggregate.
Definition: PRMClass.h:360

◆ attributes()

template<typename GUM_SCALAR >
INLINE const Set< PRMAttribute< GUM_SCALAR > *> & gum::prm::PRMClass< GUM_SCALAR >::attributes ( ) const

Returns the set of PRMAttribute<GUM_SCALAR> of this Class<GUM_SCALAR>.

Returns
Returns the set of PRMAttribute<GUM_SCALAR> of this Class<GUM_SCALAR>.

Definition at line 1016 of file PRMClass_tpl.h.

1016  {
1017  return _attributes_;
1018  }
Set< PRMAttribute< GUM_SCALAR > *> _attributes_
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:354

◆ belongsTo()

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMClassElementContainer< GUM_SCALAR >::belongsTo ( const PRMClassElement< GUM_SCALAR > &  elt) const
virtualinherited

Returns true if elt belongs to this PRMClassElementContainer.

Parameters
eltA PRMClassElement<GUM_SCALAR>.
Returns
true if elt beglons to this PRMClassElementContainer.

Definition at line 170 of file PRMClassElementContainer_tpl.h.

171  {
172  try {
173  return &elt == &(get(elt.safeName()));
174  } catch (NotFound&) { return false; }
175  }

◆ completeInheritance()

template<typename GUM_SCALAR >
void gum::prm::PRMClass< GUM_SCALAR >::completeInheritance ( const std::string &  attr)

Definition at line 278 of file PRMClass_tpl.h.

278  {
279  if (_superClass_) {
280  auto& elt = this->get(name);
283  GUM_ERROR(OperationNotAllowed, "you can only complete inheritance for attributes")
284  }
285 
286  for (const auto& prnt: super().containerDag().parents(elt.id())) {
287  this->addArc(super().get(prnt).safeName(), elt.safeName());
288  }
289 
291  auto& attr = static_cast< PRMAttribute< GUM_SCALAR >& >(elt);
292  auto& super_attr = static_cast< const PRMAttribute< GUM_SCALAR >& >(super().get(name));
293  attr.copyCpf(*_bijection_, super_attr);
294  }
295  }
296  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
virtual void addArc(const std::string &tail, const std::string &head)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::addArc().
Definition: PRMClass_tpl.h:464
Bijection< const DiscreteVariable *, const DiscreteVariable *> * _bijection_
The bijection between variables in super and variables in this The bijection&#39;s firsts are attributes ...
Definition: PRMClass.h:397
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.
static INLINE bool isAggregate(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMAggregate.
virtual const DAG & containerDag() const
Returns the gum::DAG of this PRMClassElementContainer.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ containerDag()

template<typename GUM_SCALAR >
INLINE const DAG & gum::prm::PRMClassElementContainer< GUM_SCALAR >::containerDag ( ) const
virtualinherited

Returns the gum::DAG of this PRMClassElementContainer.

Be very careful when using NodeId with PRMClassElement<GUM_SCALAR>: there is no guarantee that an inherited PRMClassElement<GUM_SCALAR> will have the same NodeId than its superclass counterpart.

When dealing with different classes and interfaces ALWAYS use safe-name as identifier.

Returns
the DAG of this PRMClassElementContainer.

Definition at line 178 of file PRMClassElementContainer_tpl.h.

178  {
179  return dag_();
180  }
virtual const DAG & dag_() const =0

◆ copyIOFlags_()

template<typename GUM_SCALAR>
void gum::prm::PRMClassElementContainer< GUM_SCALAR >::copyIOFlags_ ( const PRMClassElementContainer< GUM_SCALAR > &  c)
protectedvirtualinherited

Copy the IO Flags of c in this PRMClassElementContainer.

Parameters
cA PRMClassElementContainer.

Definition at line 36 of file PRMClassElementContainer_tpl.h.

37  {
38  for (const auto& flag: c._IOFlags_)
39  setIOFlag_(get(flag.first), flag.second);
40  }
virtual void setIOFlag_(const PRMClassElement< GUM_SCALAR > &elt, const std::pair< bool, bool > &flags)
Defines the IO flags of a PRMClassElement<GUM_SCALAR>.

◆ dag_() [1/2]

template<typename GUM_SCALAR >
INLINE const DAG & gum::prm::PRMClass< GUM_SCALAR >::dag_ ( ) const
protectedvirtual

returns a constant reference over this interface's dag.

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 969 of file PRMClass_tpl.h.

969  {
970  return _dag_;
971  }
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337

◆ dag_() [2/2]

template<typename GUM_SCALAR >
INLINE DAG & gum::prm::PRMClass< GUM_SCALAR >::dag_ ( )
protectedvirtual

Returns a non constant reference over this PRMInterface<GUM_SCALAR>'s DAG.

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 974 of file PRMClass_tpl.h.

974  {
975  return _dag_;
976  }
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337

◆ 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() [1/2]

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

Returns true if a member with the given name exists in this PRMClassElementContainer or in the PRMClassElementContainer hierarchy.

Definition at line 162 of file PRMClassElementContainer_tpl.h.

162  {
163  try {
164  get(name);
165  return true;
166  } catch (NotFound&) { return false; }
167  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34

◆ exists() [2/2]

template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists ( NodeId  id) const
virtualinherited

Returns true if a member with the given id exists in this PRMClassElementContainer or in the PRMClassElementContainer hierarchy.

Parameters
idA NodeId.
Returns
true if id matches a PRMClassElement<GUM_SCALAR>.

Definition at line 157 of file PRMClassElementContainer_tpl.h.

157  {
158  return containerDag().exists(id);
159  }
bool exists(const NodeId id) const
alias for existsNode
virtual const DAG & containerDag() const
Returns the gum::DAG of this PRMClassElementContainer.

◆ extensions()

template<typename GUM_SCALAR >
INLINE const Set< PRMClass< GUM_SCALAR > *> & gum::prm::PRMClass< GUM_SCALAR >::extensions ( ) const

Returns the set of Class<GUM_SCALAR> which are direct sub-Class<GUM_SCALAR> of this Class<GUM_SCALAR>.

Definition at line 1181 of file PRMClass_tpl.h.

1181  {
1182  return _extensions_;
1183  }
Set< PRMClass< GUM_SCALAR > *> _extensions_
The set of Class<GUM_SCALAR> which are extension of this Class<GUM_SCALAR> (i.e. direct subtypes)...
Definition: PRMClass.h:392

◆ findAllSubtypes_()

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::findAllSubtypes_ ( Set< PRMClassElementContainer< GUM_SCALAR > * > &  set)
protectedvirtual

Fills set with all the subtypes of this Class<GUM_SCALAR>.

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 923 of file PRMClass_tpl.h.

924  {
925  for (auto ext: _extensions_) {
926  set.insert(ext);
927  ext->findAllSubtypes_(set);
928  }
929  }
Set< PRMClass< GUM_SCALAR > *> _extensions_
The set of Class<GUM_SCALAR> which are extension of this Class<GUM_SCALAR> (i.e. direct subtypes)...
Definition: PRMClass.h:392

◆ get() [1/4]

template<typename GUM_SCALAR >
INLINE PRMClassElement< GUM_SCALAR > & gum::prm::PRMClass< GUM_SCALAR >::get ( NodeId  id)
virtual

See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(NodeId).

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 979 of file PRMClass_tpl.h.

979  {
980  try {
981  return *(_nodeIdMap_[id]);
982  } catch (NotFound&) {
983  GUM_ERROR(NotFound, "no ClassElement<GUM_SCALAR> with the given NodeId")
984  }
985  }
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ get() [2/4]

template<typename GUM_SCALAR >
INLINE const PRMClassElement< GUM_SCALAR > & gum::prm::PRMClass< GUM_SCALAR >::get ( NodeId  id) const
virtual

See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(NodeId).

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 988 of file PRMClass_tpl.h.

988  {
989  try {
990  return *(_nodeIdMap_[id]);
991  } catch (NotFound&) {
992  GUM_ERROR(NotFound, "no ClassElement<GUM_SCALAR> with the given NodeId (" << id << ")");
993  }
994  }
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ get() [3/4]

template<typename GUM_SCALAR >
INLINE PRMClassElement< GUM_SCALAR > & gum::prm::PRMClass< GUM_SCALAR >::get ( const std::string &  name)
virtual

See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(const std::string&).

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 997 of file PRMClass_tpl.h.

997  {
998  try {
999  return *(_nameMap_[name]);
1000  } catch (NotFound&) {
1001  GUM_ERROR(NotFound, "no ClassElement<GUM_SCALAR> with the given name (" << name << ")");
1002  }
1003  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
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

◆ get() [4/4]

template<typename GUM_SCALAR >
INLINE const PRMClassElement< GUM_SCALAR > & gum::prm::PRMClass< GUM_SCALAR >::get ( const std::string &  name) const
virtual

See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(const std::string&).

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 1007 of file PRMClass_tpl.h.

1007  {
1008  try {
1009  return *(_nameMap_[name]);
1010  } catch (NotFound&) {
1011  GUM_ERROR(NotFound, "no ClassElement<GUM_SCALAR> with the given name (" << name << ")");
1012  }
1013  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
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

◆ getIOFlag_() [1/2]

template<typename GUM_SCALAR>
INLINE std::pair< bool, bool > & gum::prm::PRMClassElementContainer< GUM_SCALAR >::getIOFlag_ ( const PRMClassElement< GUM_SCALAR > &  elt)
protectedvirtualinherited

Returns the IO flags of a PRMClassElement<GUM_SCALAR>.

Parameters
eltThe PRMClassElement<GUM_SCALAR>.
Returns
elt's IO flags.
Exceptions
NotFoundRaised if elt does not have any IO flags.

Definition at line 128 of file PRMClassElementContainer_tpl.h.

129  {
130  try {
131  return _IOFlags_[elt.safeName()];
132  } catch (NotFound&) {
133  GUM_ERROR(NotFound, "this ClassElement<GUM_SCALAR> does not have any IO flags")
134  }
135  }
HashTable< std::string, std::pair< bool, bool > > _IOFlags_
input / output flags, useful when inheriting or copying.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ getIOFlag_() [2/2]

template<typename GUM_SCALAR>
INLINE const std::pair< bool, bool > & gum::prm::PRMClassElementContainer< GUM_SCALAR >::getIOFlag_ ( const PRMClassElement< GUM_SCALAR > &  elt) const
protectedvirtualinherited

Returns the IO flags of a PRMClassElement<GUM_SCALAR>.

Parameters
eltThe PRMClassElement<GUM_SCALAR>.
Returns
elt's IO flags.
Exceptions
NotFoundRaised if elt does not have any IO flags.

Definition at line 138 of file PRMClassElementContainer_tpl.h.

139  {
140  try {
141  return _IOFlags_[elt.safeName()];
142  } catch (NotFound&) {
143  GUM_ERROR(NotFound, "this ClassElement<GUM_SCALAR> does not have any IO flags")
144  }
145  }
HashTable< std::string, std::pair< bool, bool > > _IOFlags_
input / output flags, useful when inheriting or copying.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ implements()

template<typename GUM_SCALAR >
INLINE const Set< PRMInterface< GUM_SCALAR > *> & gum::prm::PRMClass< GUM_SCALAR >::implements ( ) const

Returns the Set of PRMInterface<GUM_SCALAR> implemented by this Class<GUM_SCALAR>.

Returns
Returns the Set of PRMInterface<GUM_SCALAR> implemented by this Class<GUM_SCALAR>.
Exceptions
NotFoundRaised if this Class<GUM_SCALAR> doesn't implement any PRMInterface<GUM_SCALAR>.

Definition at line 1103 of file PRMClass_tpl.h.

1103  {
1104  if (_implements_) {
1105  return *_implements_;
1106  } else {
1107  GUM_ERROR(NotFound, "this Class does not implement any Interface<GUM_SCALAR>")
1108  }
1109  }
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ inheritAggregates()

template<typename GUM_SCALAR >
void gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates ( )

Definition at line 219 of file PRMClass_tpl.h.

219  {
220  if (_superClass_) {
221  for (const auto c_agg: _superClass_->_aggregates_) {
222  PRMAggregate< GUM_SCALAR >* agg = nullptr;
223 
224  try {
225  agg = new PRMAggregate< GUM_SCALAR >(c_agg->name(),
226  c_agg->agg_type(),
227  c_agg->type(),
228  c_agg->label());
229  } catch (OperationNotAllowed&) {
230  agg = new PRMAggregate< GUM_SCALAR >(c_agg->name(), c_agg->agg_type(), c_agg->type());
231  agg->sharedLabel(c_agg->sharedLabel());
232  agg->setLabel(c_agg->labelValue());
233  }
234 
235  _bijection_->insert(&(c_agg->type().variable()), &(agg->type().variable()));
236  agg->setId(c_agg->id());
237  _dag_.addNodeWithId(agg->id());
238  _nodeIdMap_.insert(agg->id(), agg);
239  _aggregates_.insert(agg);
240 
241  if (_superClass_->_nameMap_[c_agg->name()] == _superClass_->_nameMap_[c_agg->safeName()])
242  _nameMap_.insert(agg->name(), agg);
243 
244  _nameMap_.insert(agg->safeName(), agg);
245  }
246  }
247  }
Set< PRMAggregate< GUM_SCALAR > *> _aggregates_
The sequence of aggregate.
Definition: PRMClass.h:360
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
Bijection< const DiscreteVariable *, const DiscreteVariable *> * _bijection_
The bijection between variables in super and variables in this The bijection&#39;s firsts are attributes ...
Definition: PRMClass.h:397
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ inheritAttributes()

template<typename GUM_SCALAR >
void gum::prm::PRMClass< GUM_SCALAR >::inheritAttributes ( )

Definition at line 191 of file PRMClass_tpl.h.

191  {
192  if (_superClass_) {
193  for (const auto c_attr: _superClass_->_attributes_) {
194  // using multiDimSparse to prevent unecessary memory allocation for
195  // large arrays (the potentials are copied latter)
196  auto attr = c_attr->newFactory(*this);
197 
198  _bijection_->insert(&(c_attr->type().variable()), &(attr->type().variable()));
199  attr->setId(c_attr->id());
200  try {
201  _dag_.addNodeWithId(attr->id());
202  } catch (gum::Exception&) {
203  // Node reserved by an interface
204  }
205  _nodeIdMap_.insert(attr->id(), attr);
206  _attributes_.insert(attr);
207 
208  if (_superClass_->_nameMap_[c_attr->name()]
209  == _superClass_->_nameMap_[c_attr->safeName()]) {
210  _nameMap_.insert(attr->name(), attr);
211  }
212 
213  _nameMap_.insert(attr->safeName(), attr);
214  }
215  }
216  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
Set< PRMAttribute< GUM_SCALAR > *> _attributes_
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:354
Bijection< const DiscreteVariable *, const DiscreteVariable *> * _bijection_
The bijection between variables in super and variables in this The bijection&#39;s firsts are attributes ...
Definition: PRMClass.h:397
Base class for all aGrUM&#39;s exceptions.
Definition: exceptions.h:102
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ inheritParameters()

template<typename GUM_SCALAR >
void gum::prm::PRMClass< GUM_SCALAR >::inheritParameters ( )

Definition at line 172 of file PRMClass_tpl.h.

172  {
173  if (_superClass_) {
174  // Copying parameters
175  for (const auto c_param: _superClass_->_parameters_) {
176  auto param = new PRMParameter< GUM_SCALAR >(c_param->name(),
177  c_param->valueType(),
178  c_param->value());
179 
180  _parameters_.insert(param);
181 
182  param->setId(c_param->id());
183  _dag_.addNodeWithId(param->id());
184  _nodeIdMap_.insert(param->id(), param);
185  _nameMap_.insert(param->name(), param);
186  }
187  }
188  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
Set< PRMParameter< GUM_SCALAR > *> _parameters_
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:366
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ inheritReferenceSlots()

template<typename GUM_SCALAR >
void gum::prm::PRMClass< GUM_SCALAR >::inheritReferenceSlots ( )

Definition at line 146 of file PRMClass_tpl.h.

146  {
147  if (_superClass_) {
148  // Copying reference slots
149  for (const auto c_refslot: _superClass_->_referenceSlots_) {
150  auto ref = new PRMReferenceSlot< GUM_SCALAR >(
151  c_refslot->name(),
152  const_cast< PRMClassElementContainer< GUM_SCALAR >& >(c_refslot->slotType()),
153  c_refslot->isArray());
154 
155  ref->setId(c_refslot->id());
156  // Not reserved by an interface
157  if (!_dag_.existsNode(ref->id())) { _dag_.addNodeWithId(ref->id()); }
158  _nodeIdMap_.insert(ref->id(), ref);
159  _referenceSlots_.insert(ref);
160 
161  if (_superClass_->_nameMap_[c_refslot->name()]
162  == _superClass_->_nameMap_[c_refslot->safeName()]) {
163  _nameMap_.insert(ref->name(), ref);
164  }
165 
166  _nameMap_.insert(ref->safeName(), ref);
167  }
168  }
169  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
Set< PRMReferenceSlot< GUM_SCALAR > *> _referenceSlots_
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:357
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ inheritSlotChains()

template<typename GUM_SCALAR >
void gum::prm::PRMClass< GUM_SCALAR >::inheritSlotChains ( )

Definition at line 250 of file PRMClass_tpl.h.

250  {
251  if (_superClass_) {
252  // Copying slot chains
253  for (const auto c_sc: _superClass_->_slotChains_) {
254  // Because of aggregators, some slotchains may exists already
255  if (!(_nameMap_.exists(c_sc->name()) && _nameMap_.exists(c_sc->safeName()))) {
256  // We just need to change the first PRMReferenceSlot<GUM_SCALAR> in
257  // the
258  // chain
259  auto chain = c_sc->chain();
260 
261  chain.setAtPos(0, _nameMap_[c_sc->chain().front()->name()]);
262 
263  auto sc = new PRMSlotChain< GUM_SCALAR >(c_sc->name(), chain);
264  _bijection_->insert(&(c_sc->type().variable()), &(sc->type().variable()));
265  sc->setId(c_sc->id());
266  _dag_.addNodeWithId(sc->id());
267  _nodeIdMap_.insert(sc->id(), sc);
268  _slotChains_.insert(sc);
269 
270  if (!_nameMap_.exists(sc->name())) { _nameMap_.insert(sc->name(), sc); }
271  if (!_nameMap_.exists(sc->safeName())) { _nameMap_.insert(sc->safeName(), sc); }
272  }
273  }
274  }
275  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
Set< PRMSlotChain< GUM_SCALAR > *> _slotChains_
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:363
Bijection< const DiscreteVariable *, const DiscreteVariable *> * _bijection_
The bijection between variables in super and variables in this The bijection&#39;s firsts are attributes ...
Definition: PRMClass.h:397
NodeProperty< PRMClassElement< GUM_SCALAR > *> _nodeIdMap_
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:341
DAG _dag_
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:337
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ initializeInheritance()

template<typename GUM_SCALAR >
void gum::prm::PRMClass< GUM_SCALAR >::initializeInheritance ( )

Definition at line 128 of file PRMClass_tpl.h.

128  {
129  if (_superClass_) {
130  _superClass_->_addExtension_(this);
131  // Adding implemented interfaces, if any
132  if (_superClass_->_implements_) {
133  if (!_implements_) {
134  _implements_ = new Set< PRMInterface< GUM_SCALAR >* >(*(_superClass_->_implements_));
135  } else {
136  for (auto i: *(_superClass_->_implements_)) {
137  _implements_->insert(i);
138  }
139  }
140  }
141  }
142  if (_implements_) { _implementInterfaces_(true); }
143  }
void _implementInterfaces_(bool delayInheritance)
Proceed with the implementation of interfaces.
Definition: PRMClass_tpl.h:98
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ isCastDescendant()

template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMClass< GUM_SCALAR >::isCastDescendant ( const std::string &  safe_name) const

Return true if the attribute named safe_name is a cast descendant.

Cast descendant are automatically added PRMAttribute<GUM_SCALAR> for type casting.

Parameters
safe_nameThe safe name of an PRMAttribute<GUM_SCALAR> of this class.
Returns
true if safe_name is a cast descendant.
Exceptions
NotFoundRaised if safe_name does not name an PRMAttribute<GUM_SCALAR> in this Class<GUM_SCALAR>.

Definition at line 1191 of file PRMClass_tpl.h.

1191  {
1192  const PRMClassElement< GUM_SCALAR >& elt = get(safe_name);
1193 
1194  try {
1195  return elt.type().name() == get(elt.name()).type().name();
1196  } catch (OperationNotAllowed&) { GUM_ERROR(NotFound, "no attribute with the given name") }
1197  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ 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:

◆ isInnerNode()

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMClassElementContainer< GUM_SCALAR >::isInnerNode ( const PRMClassElement< GUM_SCALAR > &  elt) const
virtualinherited

Returns true if the node is an inner node.

PRMAttribute or PRMAggregate can either be input, output, both or internal nodes.

By defaut, attributes and aggregates are inner nodes.

Parameters
eltA PRMClassElement<GUM_SCALAR>.
Returns
true if elt is an inner node.
Exceptions
NotFoundRaised if NodeId does'nt match any PRMClassElement<GUM_SCALAR> in this.
WrongClassElementRaised if NodeId is neither an PRMAttribute nor an PRMAggregate.

Definition at line 114 of file PRMClassElementContainer_tpl.h.

115  {
116  try {
117  return !(getIOFlag_(elt).first || getIOFlag_(elt).second);
118  } catch (NotFound&) { return true; }
119  }
virtual std::pair< bool, bool > & getIOFlag_(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.

◆ isInputNode()

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMClassElementContainer< GUM_SCALAR >::isInputNode ( const PRMClassElement< GUM_SCALAR > &  elt) const
virtualinherited

Returns true if the node is an input node.

PRMAttribute or PRMAggregate can either be input, output, both or internal nodes.

By defaut, attributes and aggregates are inner nodes.

Parameters
eltA PRMClassElement<GUM_SCALAR>.
Returns
Returns true if id is an input node.

Definition at line 70 of file PRMClassElementContainer_tpl.h.

71  {
72  try {
73  return getIOFlag_(elt).first;
74  } catch (NotFound&) { return false; }
75  }
virtual std::pair< bool, bool > & getIOFlag_(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.

◆ isInstance()

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:

◆ 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:

◆ isOutputNode()

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMClass< GUM_SCALAR >::isOutputNode ( const PRMClassElement< GUM_SCALAR > &  elt) const
virtual

Returns true if elt is an output node.

Parameters
eltA node of this class.
Returns
Returns true if elt is an output node.

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 1201 of file PRMClass_tpl.h.

1201  {
1202  try {
1203  if (!this->getIOFlag_(elt).second) {
1204  if (_implements_) {
1205  for (auto i: *_implements_) {
1206  if (i->isOutputNode(elt)) { return true; }
1207  }
1208  }
1209 
1210  if (_superClass_ && (_superClass_->isOutputNode(elt))) { return true; }
1211 
1212  } else {
1213  return true;
1214  }
1215  } catch (NotFound&) {}
1216  return false;
1217  }
virtual std::pair< bool, bool > & getIOFlag_(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ isSubTypeOf()

template<typename GUM_SCALAR>
bool gum::prm::PRMClass< GUM_SCALAR >::isSubTypeOf ( const PRMClassElementContainer< GUM_SCALAR > &  cec) const
virtual

Test if this Class<GUM_SCALAR> is a subclass of cec.

If cec is a Class<GUM_SCALAR> then this Class<GUM_SCALAR> is a subclass of cec if they are equal or there exists a superclass of this Class<GUM_SCALAR> which is equal to cec.

If cec is an PRMInterface<GUM_SCALAR> then this Class<GUM_SCALAR> is a subclass of cec if it implements cec or if there exists a superclass of this Class<GUM_SCALAR> which implements cec.

Parameters
cecThe PRMClassElementContainer<GUM_SCALAR> for which we determine if this Class<GUM_SCALAR> is a subclass of it.
Returns
Returns true if this Class<GUM_SCALAR> is a subclass of cec.

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 428 of file PRMClass_tpl.h.

429  {
430  switch (cec.obj_type()) {
432  const PRMClass< GUM_SCALAR >* current = this;
433 
434  while (current != 0) {
435  if (current == &(cec)) return true;
436 
437  current = current->_superClass_;
438  }
439 
440  return false;
441  }
442 
444  if (_implements_ != nullptr) {
446  = static_cast< const PRMInterface< GUM_SCALAR >& >(cec);
447 
448  if (_implements_->exists(const_cast< PRMInterface< GUM_SCALAR >* >(&i))) return true;
449 
450  for (const auto impl: *_implements_)
451  if (impl->isSubTypeOf(i)) return true;
452  }
453 
454  return false;
455  }
456 
457  default: {
458  GUM_ERROR(FatalError, "unknown ClassElementContainer<GUM_SCALAR>")
459  }
460  }
461  }
friend class PRMInterface< GUM_SCALAR >
Definition: PRMClass.h:66
Set< PRMInterface< GUM_SCALAR > *> * _implements_
The Set of implemented interface of this.
Definition: PRMClass.h:388
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ isSuperTypeOf()

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMClassElementContainer< GUM_SCALAR >::isSuperTypeOf ( const PRMClassElementContainer< GUM_SCALAR > &  cec) const
virtualinherited

Test if this PRMClassElementContainer is a super type of cec.

This returns cec.isSubTypeOf(*this).

Parameters
cec
Returns
return true if this PRMClassElementContainer is a super type of cec.

Definition at line 122 of file PRMClassElementContainer_tpl.h.

123  {
124  return cec.isSubTypeOf(*this);
125  }

◆ 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::PRMClass< GUM_SCALAR >::obj_type ( ) const
virtual

Implementation of pure virtual method of PRMObject.

Implements gum::prm::PRMObject.

Definition at line 964 of file PRMClass_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=() [1/2]

template<typename GUM_SCALAR>
PRMClass< GUM_SCALAR >& gum::prm::PRMClass< GUM_SCALAR >::operator= ( const PRMClass< GUM_SCALAR > &  source)
delete

Copy operator. Don't use it.

◆ operator=() [2/2]

template<typename GUM_SCALAR>
PRMClass< GUM_SCALAR >& gum::prm::PRMClass< GUM_SCALAR >::operator= ( const PRMClass< GUM_SCALAR > &&  source)
delete

Move 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:

◆ operator[]() [1/4]

template<typename GUM_SCALAR >
INLINE PRMClassElement< GUM_SCALAR > & gum::prm::PRMClass< GUM_SCALAR >::operator[] ( NodeId  id)
virtual

See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](NodeId).

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 1112 of file PRMClass_tpl.h.

1112  {
1113  return get(id);
1114  }

◆ operator[]() [2/4]

template<typename GUM_SCALAR >
INLINE const PRMClassElement< GUM_SCALAR > & gum::prm::PRMClass< GUM_SCALAR >::operator[] ( NodeId  id) const
virtual

See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](NodeId).

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 1118 of file PRMClass_tpl.h.

1118  {
1119  return get(id);
1120  }

◆ operator[]() [3/4]

template<typename GUM_SCALAR >
INLINE PRMClassElement< GUM_SCALAR > & gum::prm::PRMClass< GUM_SCALAR >::operator[] ( const std::string &  name)
virtual

See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](const std::string&).

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 1124 of file PRMClass_tpl.h.

1124  {
1125  return get(name);
1126  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34

◆ operator[]() [4/4]

template<typename GUM_SCALAR >
INLINE const PRMClassElement< GUM_SCALAR > & gum::prm::PRMClass< GUM_SCALAR >::operator[] ( const std::string &  name) const
virtual

See gum::prm::PRMClassElementContainer<GUM_SCALAR>::operator[](const std::string&).

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 1130 of file PRMClass_tpl.h.

1130  {
1131  return get(name);
1132  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34

◆ overload()

template<typename GUM_SCALAR>
NodeId gum::prm::PRMClass< GUM_SCALAR >::overload ( PRMClassElement< GUM_SCALAR > *  elt)
virtual

See gum::prm::overload(PRMClassElement<GUM_SCALAR>*).

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 703 of file PRMClass_tpl.h.

703  {
704  try {
705  if (!super().exists(overloader->name())) {
706  GUM_ERROR(OperationNotAllowed, "found no ClassElement<GUM_SCALAR> to overload")
707  }
708  } catch (NotFound&) {
709  GUM_ERROR(OperationNotAllowed, "overload is possible only with subclasses")
710  }
711 
712  PRMClassElement< GUM_SCALAR >* overloaded = _nameMap_[overloader->name()];
713  if (overloaded == overloader) {
714  GUM_ERROR(DuplicateElement, "dupplicate ClassElement " << overloader->name())
715  }
716  // Checking overload legality
717  if (!_checkOverloadLegality_(overloaded, overloader)) {
718  GUM_ERROR(OperationNotAllowed, "illegal overload")
719  }
720 
721  switch (overloader->elt_type()) {
723  auto overloader_attr = static_cast< PRMAttribute< GUM_SCALAR >* >(overloader);
724  auto overloaded_attr = static_cast< PRMAttribute< GUM_SCALAR >* >(overloaded);
725  _overloadAttribute_(overloader_attr, overloaded_attr);
726  _addIOInterfaceFlags_(overloader);
727  break;
728  }
729 
731  _overloadAggregate_(static_cast< PRMAggregate< GUM_SCALAR >* >(overloader), overloaded);
732  _addIOInterfaceFlags_(overloader);
733  break;
734  }
735 
737  // _checkOverloadLegality_ guaranties that overloaded is a
738  // PRMReferenceSlot<GUM_SCALAR>
739  auto overloader_ref = static_cast< PRMReferenceSlot< GUM_SCALAR >* >(overloader);
740  auto overloaded_ref = static_cast< PRMReferenceSlot< GUM_SCALAR >* >(overloaded);
741  _overloadReference_(overloader_ref, overloaded_ref);
742  break;
743  }
744 
746  GUM_ERROR(OperationNotAllowed, "SlotChain<GUM_SCALAR> can not be overloaded")
747  break;
748  }
749 
750  case PRMClassElement< GUM_SCALAR >::prm_parameter: {
751  auto overloaded_param = static_cast< PRMParameter< GUM_SCALAR >* >(overloaded);
752  auto overloader_param = static_cast< PRMParameter< GUM_SCALAR >* >(overloader);
753  _overloadParameter_(overloader_param, overloaded_param);
754  break;
755  }
756  default: {
757  GUM_ERROR(OperationNotAllowed, "unknown ClassElement<GUM_SCALAR> type")
758  }
759  }
760 
761  return overloader->id();
762  }
HashTable< std::string, PRMClassElement< GUM_SCALAR > *> _nameMap_
Mapping between a member&#39;s name and itself. Used for fast access to a member given it&#39;s name...
Definition: PRMClass.h:351
virtual bool exists(const std::string &name) const
Returns true if a member with the given name exists in this PRMClassElementContainer or in the PRMCla...
void _overloadParameter_(PRMParameter< GUM_SCALAR > *overloader, PRMParameter< GUM_SCALAR > *overloaded)
Overloads a parameter.
Definition: PRMClass_tpl.h:886
bool _checkOverloadLegality_(const PRMClassElement< GUM_SCALAR > *overloaded, const PRMClassElement< GUM_SCALAR > *overloader)
Return true of overloaded can be overload by overloader.
void _addIOInterfaceFlags_(PRMClassElement< GUM_SCALAR > *elt)
Check if elt is present in an implementation. If it is, its IO flags are updated. ...
Definition: PRMClass_tpl.h:932
void _overloadAggregate_(PRMAggregate< GUM_SCALAR > *overloader, PRMClassElement< GUM_SCALAR > *overloaded)
Overloads an aggregate.
void _overloadReference_(PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
Overloads a reference slot.
Definition: PRMClass_tpl.h:791
void _overloadAttribute_(PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
Overloads an attribute.
Definition: PRMClass_tpl.h:765
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ parameters()

template<typename GUM_SCALAR >
INLINE const Set< PRMParameter< GUM_SCALAR > *> & gum::prm::PRMClass< GUM_SCALAR >::parameters ( ) const

Returns the set of parameters of this Class<GUM_SCALAR>.

Returns
Returns the set of parameters of this Class<GUM_SCALAR>.

Definition at line 1021 of file PRMClass_tpl.h.

1021  {
1022  return _parameters_;
1023  }
Set< PRMParameter< GUM_SCALAR > *> _parameters_
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:366

◆ referenceSlots()

template<typename GUM_SCALAR >
INLINE const Set< PRMReferenceSlot< GUM_SCALAR > *> & gum::prm::PRMClass< GUM_SCALAR >::referenceSlots ( ) const

Returns the set of PRMReferenceSlot<GUM_SCALAR> of this Class<GUM_SCALAR>.

Returns
Returns the set of PRMReferenceSlot<GUM_SCALAR> of this Class<GUM_SCALAR>.

Definition at line 1084 of file PRMClass_tpl.h.

1084  {
1085  return _referenceSlots_;
1086  }
Set< PRMReferenceSlot< GUM_SCALAR > *> _referenceSlots_
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:357

◆ 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 ")"; }

◆ scope()

template<typename GUM_SCALAR >
INLINE HashTable< std::string, const PRMParameter< GUM_SCALAR > *> gum::prm::PRMClass< GUM_SCALAR >::scope ( ) const

Returns all the parameters in the scope of this class.

&return all the parameters in the scope of this class.

Definition at line 1039 of file PRMClass_tpl.h.

1039  {
1040  HashTable< std::string, const PRMParameter< GUM_SCALAR >* > params;
1041 
1042  for (const auto p: parameters()) {
1043  params.insert(p->name(), p);
1044  }
1045 
1046  std::queue< ParamScopeData< GUM_SCALAR > > queue;
1047 
1048  for (const auto ref: referenceSlots()) {
1049  if (PRMObject::isClass(ref->slotType())) {
1050  queue.push(ParamScopeData< GUM_SCALAR >("", *ref, 1));
1051  }
1052  }
1053 
1054  while (!queue.empty()) {
1055  auto data = queue.front();
1056  queue.pop();
1057 
1058  if (data.depth < 5) {
1059  for (const auto p: data.c->parameters()) {
1060  params.insert(data.prefix + p->name(), p);
1061  }
1062 
1063  for (const auto ref: data.c->referenceSlots()) {
1064  if (PRMObject::isClass(ref->slotType())) {
1065  queue.push(ParamScopeData< GUM_SCALAR >(data.prefix, *ref, data.depth + 1));
1066  }
1067  }
1068  } else {
1069  // @todo depth>5 is a workaround. Cycle detection is needed here !
1070  GUM_ERROR(FatalError, "Depth limit reached when looking up parameters")
1071  }
1072  }
1073 
1074  return params;
1075  }
static INLINE bool isClass(const PRMObject &obj)
Returns true if obj_ptr is of type Class.
Definition: PRMObject.h:109
const Set< PRMParameter< GUM_SCALAR > *> & parameters() const
Returns the set of parameters of this Class<GUM_SCALAR>.
const Set< PRMReferenceSlot< GUM_SCALAR > *> & referenceSlots() const
Returns the set of PRMReferenceSlot<GUM_SCALAR> of this Class<GUM_SCALAR>.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ setInputNode()

template<typename GUM_SCALAR>
INLINE void gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode ( const PRMClassElement< GUM_SCALAR > &  elt,
bool  b 
)
virtualinherited

Set the input flag value of id at b.

PRMAttribute or PRMAggregate can either be input, output, both or internal nodes.

By defaut, attributes and aggregates are inner nodes.

Parameters
eltA PRMClassElement<GUM_SCALAR>.
bThe flag value.
Exceptions
NotFoundRaised if id does'nt match any PRMClassElement<GUM_SCALAR> in this.
WrongClassElementRaised if NodeId is neither an PRMAttribute nor an PRMAggregate.

Definition at line 78 of file PRMClassElementContainer_tpl.h.

80  {
81  if (!exists(elt.safeName())) {
82  GUM_ERROR(NotFound, ": <" + elt.safeName() + "> is not in <" + name() + ">")
85  try {
86  getIOFlag_(elt).first = b;
87  } catch (NotFound&) { setIOFlag_(elt, std::make_pair(b, false)); }
88  } else {
89  GUM_ERROR(WrongClassElement, "given id is not an PRMAttribute or an PRMAggregate")
90  }
91  }
virtual std::pair< bool, bool > & getIOFlag_(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
virtual bool exists(const std::string &name) const
Returns true if a member with the given name exists in this PRMClassElementContainer or in the PRMCla...
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
virtual void setIOFlag_(const PRMClassElement< GUM_SCALAR > &elt, const std::pair< bool, bool > &flags)
Defines the IO flags of a PRMClassElement<GUM_SCALAR>.
static INLINE bool isAggregate(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMAggregate.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ setIOFlag_()

template<typename GUM_SCALAR>
INLINE void gum::prm::PRMClassElementContainer< GUM_SCALAR >::setIOFlag_ ( const PRMClassElement< GUM_SCALAR > &  elt,
const std::pair< bool, bool > &  flags 
)
protectedvirtualinherited

Defines the IO flags of a PRMClassElement<GUM_SCALAR>.

Parameters
eltThe PRMClassElement<GUM_SCALAR>.
flagsThe IO flags of elt. Overwrite any existing flags.
Returns
elt's IO flags.
Exceptions
NotFoundRaised if elt does not have any IO flags.

Definition at line 149 of file PRMClassElementContainer_tpl.h.

150  {
151  try {
152  _IOFlags_[elt.safeName()] = flags;
153  } catch (NotFound&) { _IOFlags_.insert(elt.safeName(), flags); }
154  }
HashTable< std::string, std::pair< bool, bool > > _IOFlags_
input / output flags, useful when inheriting or copying.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.

◆ setOutputNode()

template<typename GUM_SCALAR>
INLINE void gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode ( const PRMClassElement< GUM_SCALAR > &  elt,
bool  b 
)
virtualinherited

Set the output flag value of id at b.

PRMAttribute or PRMAggregate can either be input, output, both or internal nodes.

By defaut, attributes and aggregates are inner nodes.

Parameters
eltA PRMClassElement<GUM_SCALAR>.
bThe flag value.
Exceptions
NotFoundRaised if id does'nt match any PRMClassElement<GUM_SCALAR> in this.
WrongClassElementRaised if NodeId is neither an PRMAttribute nor an PRMAggregate.

Definition at line 94 of file PRMClassElementContainer_tpl.h.

96  {
97  if (!exists(elt.safeName())) {
98  GUM_ERROR(NotFound, "<" + elt.safeName() + "> is not in <" + name() + ">")
101  try {
102  getIOFlag_(elt).second = b;
103  } catch (NotFound&) { setIOFlag_(elt, std::make_pair(false, b)); }
104 
105  if (b) { updateDescendants_(elt); }
106  } else {
107  GUM_ERROR(WrongClassElement,
108  "given ClassElement<GUM_SCALAR> is not an "
109  "PRMAttribute or an PRMAggregate");
110  }
111  }
virtual void updateDescendants_(const PRMClassElement< GUM_SCALAR > &elt)=0
When a PRMClassElement<GUM_SCALAR> becomes an Output node we must update any the IO flags of every de...
virtual std::pair< bool, bool > & getIOFlag_(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
virtual bool exists(const std::string &name) const
Returns true if a member with the given name exists in this PRMClassElementContainer or in the PRMCla...
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
virtual void setIOFlag_(const PRMClassElement< GUM_SCALAR > &elt, const std::pair< bool, bool > &flags)
Defines the IO flags of a PRMClassElement<GUM_SCALAR>.
static INLINE bool isAggregate(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMAggregate.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ slotChains()

template<typename GUM_SCALAR >
INLINE const Set< PRMSlotChain< GUM_SCALAR > *> & gum::prm::PRMClass< GUM_SCALAR >::slotChains ( ) const

Returns the set of PRMSlotChain<GUM_SCALAR> of this Class<GUM_SCALAR>.

Returns
Returns the set of PRMSlotChain<GUM_SCALAR> of this Class<GUM_SCALAR>.

Definition at line 1089 of file PRMClass_tpl.h.

1089  {
1090  return _slotChains_;
1091  }
Set< PRMSlotChain< GUM_SCALAR > *> _slotChains_
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:363

◆ super()

template<typename GUM_SCALAR >
INLINE const PRMClass< GUM_SCALAR > & gum::prm::PRMClass< GUM_SCALAR >::super ( ) const

Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.

Returns
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.
Exceptions
NotFoundRaised if this has no super Class<GUM_SCALAR>.

Definition at line 1094 of file PRMClass_tpl.h.

1094  {
1095  if (_superClass_) {
1096  return *_superClass_;
1097  } else {
1098  GUM_ERROR(NotFound, "this Class is not a subclass")
1099  }
1100  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
PRMClass< GUM_SCALAR > * _superClass_
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:385

◆ updateDescendants_()

template<typename GUM_SCALAR>
void gum::prm::PRMClass< GUM_SCALAR >::updateDescendants_ ( const PRMClassElement< GUM_SCALAR > &  elt)
protectedvirtual

See gum::prm::PRMClassElementContainer<GUM_SCALAR>(const PRMClassElement<GUM_SCALAR>&).

Implements gum::prm::PRMClassElementContainer< GUM_SCALAR >.

Definition at line 954 of file PRMClass_tpl.h.

954  {
955  // for ( const auto ext : _extensions_ ) {
956  // // We test to prevent unnecessary recursive call from iter
957  // if ( !ext->isOutputNode( elt ) ) {
958  // ext->setOutputNode( elt, true );
959  // }
960  //}
961  }

Friends And Related Function Documentation

◆ PRMInterface< GUM_SCALAR >

template<typename GUM_SCALAR>
friend class PRMInterface< GUM_SCALAR >
friend

Definition at line 66 of file PRMClass.h.

Member Data Documentation

◆ _aggregates_

template<typename GUM_SCALAR>
Set< PRMAggregate< GUM_SCALAR >* > gum::prm::PRMClass< GUM_SCALAR >::_aggregates_
private

The sequence of aggregate.

Definition at line 360 of file PRMClass.h.

◆ _attributes_

template<typename GUM_SCALAR>
Set< PRMAttribute< GUM_SCALAR >* > gum::prm::PRMClass< GUM_SCALAR >::_attributes_
private

The sequence of PRMAttribute<GUM_SCALAR>s.

Definition at line 354 of file PRMClass.h.

◆ _bijection_

template<typename GUM_SCALAR>
Bijection< const DiscreteVariable*, const DiscreteVariable* >* gum::prm::PRMClass< GUM_SCALAR >::_bijection_
private

The bijection between variables in super and variables in this The bijection's firsts are attributes in this and its seconds are attributes in c.

Definition at line 397 of file PRMClass.h.

◆ _dag_

template<typename GUM_SCALAR>
DAG gum::prm::PRMClass< GUM_SCALAR >::_dag_
private

The dag representing dependencies between formal attributes and slots.

Definition at line 337 of file PRMClass.h.

◆ _dummy_hashfunc_

template<typename GUM_SCALAR>
HashFunc< PRMClassElementContainer< GUM_SCALAR >* > gum::prm::PRMClass< GUM_SCALAR >::_dummy_hashfunc_
private

a dummy member used to fix a compilation issue in clang4

Definition at line 400 of file PRMClass.h.

◆ _extensions_

template<typename GUM_SCALAR>
Set< PRMClass< GUM_SCALAR >* > gum::prm::PRMClass< GUM_SCALAR >::_extensions_
private

The set of Class<GUM_SCALAR> which are extension of this Class<GUM_SCALAR> (i.e. direct subtypes).

Definition at line 392 of file PRMClass.h.

◆ _implements_

template<typename GUM_SCALAR>
Set< PRMInterface< GUM_SCALAR >* >* gum::prm::PRMClass< GUM_SCALAR >::_implements_
private

The Set of implemented interface of this.

Definition at line 388 of file PRMClass.h.

◆ _nameMap_

template<typename GUM_SCALAR>
HashTable< std::string, PRMClassElement< GUM_SCALAR >* > gum::prm::PRMClass< GUM_SCALAR >::_nameMap_
private

Mapping between a member's name and itself. Used for fast access to a member given it's name.

Definition at line 351 of file PRMClass.h.

◆ _nodeIdMap_

template<typename GUM_SCALAR>
NodeProperty< PRMClassElement< GUM_SCALAR >* > gum::prm::PRMClass< GUM_SCALAR >::_nodeIdMap_
private

Mapping between node's id and their name (being an attribute or a slot). Used for fast access to a member given it's node id.

Definition at line 341 of file PRMClass.h.

◆ _parameters_

template<typename GUM_SCALAR>
Set< PRMParameter< GUM_SCALAR >* > gum::prm::PRMClass< GUM_SCALAR >::_parameters_
private

The Set of parameters in this Class<GUM_SCALAR>.

Definition at line 366 of file PRMClass.h.

◆ _referenceSlots_

template<typename GUM_SCALAR>
Set< PRMReferenceSlot< GUM_SCALAR >* > gum::prm::PRMClass< GUM_SCALAR >::_referenceSlots_
private

The sequence of PRMReferenceSlot<GUM_SCALAR>.

Definition at line 357 of file PRMClass.h.

◆ _slotChains_

template<typename GUM_SCALAR>
Set< PRMSlotChain< GUM_SCALAR >* > gum::prm::PRMClass< GUM_SCALAR >::_slotChains_
private

The set of gum::PRMSlotChain<GUM_SCALAR>s.

Definition at line 363 of file PRMClass.h.

◆ _superClass_

template<typename GUM_SCALAR>
PRMClass< GUM_SCALAR >* gum::prm::PRMClass< GUM_SCALAR >::_superClass_
private

The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this. Note that this is first searched for gum::PRMClassElement<GUM_SCALAR>.

Definition at line 385 of file PRMClass.h.


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