aGrUM  0.13.2
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 &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 DAG_dag () const
 returns a constant reference over this interface's dag. More...
 
virtual DAG_dag ()
 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 &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...
 
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 58 of file PRMClass.h.

Member Enumeration Documentation

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 66 of file PRMObject.h.

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

Constructor & Destructor Documentation

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),
41  __implements(nullptr), __bijection(nullptr) {
42  GUM_CONSTRUCTOR(PRMClass);
43  }
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
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:396
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:39
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.

References gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__inheritClass(), and gum::prm::PRMClassElementContainer< GUM_SCALAR >::containerDag().

48  :
49  PRMClassElementContainer< GUM_SCALAR >(name),
50  __superClass(&super), __implements(nullptr),
52  new Bijection< const DiscreteVariable*, const DiscreteVariable* >()) {
53  GUM_CONSTRUCTOR(PRMClass);
54  if (!delayInheritance) {
55  __dag = super.containerDag();
57  }
58  }
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
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:396
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:39
void __inheritClass(const PRMClass< GUM_SCALAR > &c)
Proceed with the copy when this inherits c.
Definition: PRMClass_tpl.h:314
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.

+ Here is the call graph for this function:

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 61 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__implementInterfaces().

63  :
64  PRMClassElementContainer< GUM_SCALAR >(name),
65  __superClass(nullptr),
66  __implements(new Set< PRMInterface< GUM_SCALAR >* >(set)),
67  __bijection(nullptr) {
68  GUM_CONSTRUCTOR(PRMClass);
69 
70  if (!delayInheritance) { __implementInterfaces(false); }
71  }
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
friend class PRMInterface< GUM_SCALAR >
Definition: PRMClass.h:59
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
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:396
void __implementInterfaces(bool delayInheritance)
Proceed with the implementation of interfaces.
Definition: PRMClass_tpl.h:101
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:39

+ Here is the call graph for this function:

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 74 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__implementInterfaces(), gum::prm::PRMClass< GUM_SCALAR >::__implements, gum::prm::PRMClass< GUM_SCALAR >::__inheritClass(), and gum::prm::PRMClassElementContainer< GUM_SCALAR >::containerDag().

77  :
78  PRMClassElementContainer< GUM_SCALAR >(name),
79  __superClass(&super), __implements(nullptr),
81  new Bijection< const DiscreteVariable*, const DiscreteVariable* >()) {
82  GUM_CONSTRUCTOR(PRMClass);
83  if (!delayInheritance) {
84  __dag = super.containerDag();
86  }
87 
88  // Adding other implementation
89  if (__implements == nullptr) { // super has not created __implements
90  __implements = new Set< PRMInterface< GUM_SCALAR >* >(set);
91  } else { // we just add the new implementations
92  for (const auto elt : set) {
93  __implements->insert(elt);
94  }
95  }
96 
97  if (!delayInheritance) { __implementInterfaces(false); }
98  }
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
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:396
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
void __implementInterfaces(bool delayInheritance)
Proceed with the implementation of interfaces.
Definition: PRMClass_tpl.h:101
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:39
void __inheritClass(const PRMClass< GUM_SCALAR > &c)
Proceed with the copy when this inherits c.
Definition: PRMClass_tpl.h:314
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.

+ Here is the call graph for this function:

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

Copy constructor.

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

Move constructor.

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

Destructor.

Definition at line 119 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__bijection, gum::prm::PRMClass< GUM_SCALAR >::__implements, and gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap.

119  {
120  GUM_DESTRUCTOR(PRMClass);
121 
122  for (const auto& elt : __nodeIdMap) {
123  delete elt.second;
124  }
125 
126  if (__implements) { delete __implements; }
127 
128  if (__bijection) { delete __bijection; }
129  }
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:338
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
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:396
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:39

Member Function Documentation

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 692 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__attributes, gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::DAG::addArc(), gum::NodeGraphPart::addNodeWithId(), gum::prm::PRMAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMClass< GUM_SCALAR >::implements(), gum::prm::nextNodeId(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), and gum::prm::PRMClassElement< GUM_SCALAR >::setId().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__overloadAttribute(), and gum::prm::PRMClass< GUM_SCALAR >::add().

693  {
694  auto parent = attr;
695  PRMAttribute< GUM_SCALAR >* child = 0;
696 
697  while (parent->type().isSubType()) {
698  child = parent->getCastDescendant();
699 
700  // Check if id was reserved by one of the class interfaces
701  bool found = false;
702  try {
703  for (auto i : implements()) {
704  if (i->exists(child->safeName())) {
705  child->setId(i->get(child->safeName()).id());
706  found = true;
707  break;
708  }
709  }
710  } catch (NotFound&) {
711  // No interface
712  }
713  if (!found) {
714  child->setId(nextNodeId());
715  __dag.addNodeWithId(child->id());
716  }
717  __nodeIdMap.insert(child->id(), child);
718  // Only use child's safe name when adding to the name map!
719  __nameMap.insert(child->safeName(), child);
720  __attributes.insert(child);
721  // Do not use Class<GUM_SCALAR>::insertArc(), child's CPF is already
722  // initialized properly
723  __dag.addArc(parent->id(), child->id());
724 
725  parent = child;
726  }
727  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
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:338
const Set< PRMInterface< GUM_SCALAR > * > & implements() const
Returns the Set of PRMInterface<GUM_SCALAR> implemented by this Class<GUM_SCALAR>.
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: DAG_inl.h:40
NodeId nextNodeId()
Returns the next value of an unique counter for PRM&#39;s node id.
Definition: utils_prm.cpp:63
Set< PRMAttribute< GUM_SCALAR > * > __attributes
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:351
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:348

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 939 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__addIOInterfaceFlags(), gum::prm::PRMClass< GUM_SCALAR >::__attributes, gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::DAG::addArc(), gum::NodeGraphPart::addNodeWithId(), gum::prm::PRMAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::nextNodeId(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), gum::prm::PRMAttribute< GUM_SCALAR >::setAsCastDescendant(), gum::prm::PRMClassElement< GUM_SCALAR >::setId(), and gum::prm::PRMAttribute< GUM_SCALAR >::type().

940  {
941  PRMAttribute< GUM_SCALAR >* parent = start;
942  PRMAttribute< GUM_SCALAR >* child = 0;
943 
944  while (parent->type().superType() != end->type()) {
945  child = parent->getCastDescendant();
946  child->setId(nextNodeId());
947  __nodeIdMap.insert(child->id(), child);
948  __dag.addNodeWithId(child->id());
949  // Only use child's safe name when adding to the name map!
950  __nameMap.insert(child->safeName(), child);
951  __attributes.insert(child);
952  __addIOInterfaceFlags(child);
953  // Do not use Class<GUM_SCALAR>::insertArc(), child's CPF is already
954  // initialized properly
955  __dag.addArc(parent->id(), child->id());
956  parent = child;
957  }
958 
959  parent->setAsCastDescendant(end);
960  __dag.addArc(parent->id(), end->id());
961  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
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:338
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: DAG_inl.h:40
NodeId nextNodeId()
Returns the next value of an unique counter for PRM&#39;s node id.
Definition: utils_prm.cpp:63
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:973
Set< PRMAttribute< GUM_SCALAR > * > __attributes
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:351
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:348

+ Here is the call graph for this function:

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 1255 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__extensions.

1255  {
1256  __extensions.insert(c);
1257  }
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:391
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 973 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__implements, gum::prm::PRMClassElementContainer< GUM_SCALAR >::_getIOFlag(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::_setIOFlag(), gum::prm::PRMObject::name(), gum::prm::PRMInterface< GUM_SCALAR >::super(), and gum::prm::PRMClass< GUM_SCALAR >::super().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__addCastDescendants(), gum::prm::PRMClass< GUM_SCALAR >::add(), and gum::prm::PRMClass< GUM_SCALAR >::overload().

974  {
975  // We only add IO Flags if elt matches is required by and interface
976  if (__implements != nullptr) {
977  for (const auto impl : *__implements) {
979  while (super) {
980  // If the attribute is defined in an interface, we set it as an
981  // OutputNode
982  if (impl->exists(elt->name())) {
983  try {
984  this->_getIOFlag(*elt).second = true;
985  } catch (NotFound&) {
986  this->_setIOFlag(*elt, std::make_pair(false, true));
987  }
988  }
989  try {
990  super = &(super->super());
991  } catch (NotFound&) { super = nullptr; }
992  }
993  }
994  }
995  }
friend class PRMInterface< GUM_SCALAR >
Definition: PRMClass.h:59
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
virtual std::pair< bool, bool > & _getIOFlag(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
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>.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 540 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::DAG::addArc(), gum::ArcGraphPart::children(), gum::DiGraph::eraseNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::NodeGraphPart::existsNode(), gum::prm::PRMInterface< GUM_SCALAR >::get(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMClassElement< GUM_SCALAR >::isAggregate(), gum::prm::PRMClassElement< GUM_SCALAR >::isAttribute(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::setId(), and gum::prm::PRMClassElement< GUM_SCALAR >::type().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__checkInterfaces().

541  {
542  const auto& i_elt = i->get(elt->name());
543  bool is_attr = PRMClassElement< GUM_SCALAR >::isAttribute(i_elt);
544  bool is_agg = PRMClassElement< GUM_SCALAR >::isAggregate(i_elt);
545 
546  if (!(is_attr || is_agg)) {
547  GUM_ERROR(OperationNotAllowed, "Class does not respect it's interface");
548  }
549 
550  if (!elt->type().isSubTypeOf(i_elt.type())) {
551  GUM_ERROR(OperationNotAllowed,
552  "Attribute type does not respect class interface");
553  }
554 
555  if (elt->type() != i_elt.type()) {
556  if (!this->exists(i_elt.safeName())) {
557  GUM_ERROR(OperationNotAllowed,
558  "Attribute type does not respect class interface");
559  }
560  elt = &(this->get(i_elt.safeName()));
561  }
562 
563  // Node must be reserved by constructor
564  if (!__dag.existsNode(i_elt.id())) {
565  GUM_ERROR(FatalError, "Class does not reserved implemented nodes");
566  }
567 
568  // Removing unused node and changing to proper node
569  if (elt->id() != i_elt.id()) {
570  // Update cast descendants
571  for (auto child : __dag.children(elt->id())) {
572  __dag.addArc(i_elt.id(), child);
573  }
574  __dag.eraseNode(elt->id());
575  }
576  __nodeIdMap.erase(elt->id());
577  elt->setId(i_elt.id());
578  __nodeIdMap.insert(elt->id(), elt);
579  }
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...
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:338
static INLINE bool isAttribute(const PRMClassElement &elt)
Returns true if obj_ptr is of type PRMAttribute.
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: DAG_inl.h:40
static INLINE bool isAggregate(const PRMClassElement &elt)
Return true if obj is of type PRMAggregate.
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
virtual void eraseNode(const NodeId id)
remove a node and its adjacent arcs from the graph
Definition: diGraph_inl.h:66
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 527 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__checkInterface(), gum::prm::PRMClass< GUM_SCALAR >::implements(), and gum::prm::PRMObject::name().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::add().

528  {
529  try {
530  for (auto i : implements()) {
531  if (i->exists(elt->name())) { __checkInterface(elt, i); }
532  }
533  } catch (NotFound&) {
534  // No interface
535  }
536  }
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:540

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 1207 of file PRMClass_tpl.h.

References gum::prm::PRMClassElement< GUM_SCALAR >::elt_type(), gum::prm::PRMClassElement< GUM_SCALAR >::type(), and gum::prm::PRMParameter< GUM_SCALAR >::valueType().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::overload().

1209  {
1210  if (overloaded->elt_type() != overloader->elt_type()) { return false; }
1211 
1212  switch (overloaded->elt_type()) {
1214  if (!overloader->type().isSubTypeOf(overloaded->type())) {
1215  return false;
1216  }
1217  break;
1218  }
1219 
1221  const auto& new_slot_type =
1222  static_cast< const PRMReferenceSlot< GUM_SCALAR >* >(overloader)
1223  ->slotType();
1224  const auto& old_slot_type =
1225  static_cast< const PRMReferenceSlot< GUM_SCALAR >* >(overloaded)
1226  ->slotType();
1227 
1228  if (!new_slot_type.isSubTypeOf(old_slot_type)) { return false; }
1229 
1230  break;
1231  }
1232 
1234  auto overloaded_param =
1235  static_cast< const PRMParameter< GUM_SCALAR >* >(overloaded);
1236  auto overloader_param =
1237  static_cast< const PRMParameter< GUM_SCALAR >* >(overloader);
1238 
1239  return overloaded_param->valueType() == overloader_param->valueType();
1240  break;
1241  }
1242 
1243  default: { return false; }
1244  }
1245  return true;
1246  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 594 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMReferenceSlot< GUM_SCALAR >::elt_type(), gum::DiGraph::eraseNode(), gum::NodeGraphPart::exists(), gum::prm::PRMInterface< GUM_SCALAR >::get(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::setId(), and gum::prm::PRMReferenceSlot< GUM_SCALAR >::slotType().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__checkRefInterfaces().

595  {
596  auto& i_elt = i->get(ref->name());
597  if (i_elt.elt_type() != ref->elt_type()) {
598  GUM_ERROR(OperationNotAllowed, "Class does not respect it's interface");
599  }
600  auto& i_ref = static_cast< PRMReferenceSlot< GUM_SCALAR >& >(i_elt);
601  if (!ref->slotType().isSubTypeOf(i_ref.slotType())) {
602  GUM_ERROR(OperationNotAllowed,
603  "ReferenceSlot type does not respect class interface");
604  }
605  // Node must be reserved by constructor
606  if (!__dag.exists(i_ref.id())) {
607  GUM_ERROR(FatalError,
608  "class " << this->name() << " does not respect interface "
609  << i->name() << " implementation");
610  }
611  // Removing unused node and changin to propoer node
612  if (ref->id() != i_ref.id()) { __dag.eraseNode(ref->id()); }
613  __nodeIdMap.erase(ref->id());
614  ref->setId(i_ref.id());
615  __nodeIdMap.insert(ref->id(), ref);
616  }
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:338
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
bool exists(const NodeId id) const
alias for existsNode
virtual void eraseNode(const NodeId id)
remove a node and its adjacent arcs from the graph
Definition: diGraph_inl.h:66
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 582 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__checkRefInterface(), gum::prm::PRMClass< GUM_SCALAR >::implements(), and gum::prm::PRMObject::name().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::add().

583  {
584  try {
585  for (auto i : implements()) {
586  if (i->exists(ref->name())) { __checkRefInterface(ref, i); }
587  }
588  } catch (NotFound&) {
589  // No interface to check
590  }
591  }
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:594

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Proceed with the implementation of interfaces.

Definition at line 101 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__implements, gum::prm::PRMClass< GUM_SCALAR >::__superClass, gum::NodeGraphPart::addNodeWithId(), gum::prm::PRMClass< GUM_SCALAR >::isSubTypeOf(), and gum::prm::PRMClass< GUM_SCALAR >::super().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::initializeInheritance(), and gum::prm::PRMClass< GUM_SCALAR >::PRMClass().

101  {
102  for (const auto impl : *__implements) {
103  impl->__addImplementation(this);
104  if ((!__superClass) || (!super().isSubTypeOf(*impl))
105  || delayedInheritance) {
106  // Reserve reference id in DAG
107  for (auto ref : impl->referenceSlots()) {
108  __dag.addNodeWithId(ref->id());
109  }
110  // Reserve attribute id in DAG
111  for (auto attr : impl->attributes()) {
112  __dag.addNodeWithId(attr->id());
113  }
114  }
115  }
116  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
virtual bool isSubTypeOf(const PRMClassElementContainer< GUM_SCALAR > &cec) const
Test if this Class<GUM_SCALAR> is a subclass of cec.
Definition: PRMClass_tpl.h:444
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 314 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__aggregates, gum::prm::PRMClass< GUM_SCALAR >::__attributes, gum::prm::PRMClass< GUM_SCALAR >::__implements, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMClass< GUM_SCALAR >::__parameters, gum::prm::PRMClass< GUM_SCALAR >::__referenceSlots, gum::prm::PRMClass< GUM_SCALAR >::__slotChains, gum::prm::PRMClass< GUM_SCALAR >::__superClass, gum::prm::PRMClassElementContainer< GUM_SCALAR >::_copyIOFlags(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::containerDag(), gum::prm::PRMAttribute< GUM_SCALAR >::copyCpf(), gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::BijectionImplementation< T1, T2, Alloc, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::insert(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), gum::SequenceImplementation< Key, Alloc, Gen >::setAtPos(), gum::prm::PRMClassElement< GUM_SCALAR >::setId(), gum::prm::PRMSlotChain< GUM_SCALAR >::type(), and gum::prm::PRMAggregate< GUM_SCALAR >::type().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::PRMClass().

314  {
315  if (__superClass) {
316  __superClass->__addExtension(this);
317  // Adding implemented interfaces of c, if any
318  if (c.__implements) {
319  if (!__implements) {
320  __implements =
321  new Set< PRMInterface< GUM_SCALAR >* >(*(c.__implements));
322  } else {
323  for (auto i : *(c.__implements)) {
324  __implements->insert(i);
325  }
326  }
327  }
328 
329  // Copying attributes, the bijection's firsts are attributes in this and
330  // its
331  // seconds are attributes
332  // in c.
333  Bijection< const DiscreteVariable*, const DiscreteVariable* > bij;
334 
335  // Copying parameters
336  for (const auto c_param : c.__parameters) {
337  auto param = new PRMParameter< GUM_SCALAR >(
338  c_param->name(), c_param->valueType(), c_param->value());
339 
340  __parameters.insert(param);
341 
342  param->setId(c_param->id());
343  __nodeIdMap.insert(param->id(), param);
344  __nameMap.insert(param->name(), param);
345  }
346 
347  // Copying attributes
348  for (const auto c_attr : c.__attributes) {
349  // using multiDimSparse to prevent unecessary memory allocation for
350  // large arrays (the potentials are copied latter)
351  auto attr = c_attr->newFactory(*this);
352 
353  bij.insert(&(c_attr->type().variable()), &(attr->type().variable()));
354  attr->setId(c_attr->id());
355  __nodeIdMap.insert(attr->id(), attr);
356  __attributes.insert(attr);
357 
358  if (c.__nameMap[c_attr->name()] == c.__nameMap[c_attr->safeName()]) {
359  __nameMap.insert(attr->name(), attr);
360  }
361 
362  __nameMap.insert(attr->safeName(), attr);
363  }
364 
365  // Copying aggregates
366  for (const auto c_agg : c.__aggregates) {
367  PRMAggregate< GUM_SCALAR >* agg = nullptr;
368 
369  try {
370  agg = new PRMAggregate< GUM_SCALAR >(
371  c_agg->name(), c_agg->agg_type(), c_agg->type(), c_agg->label());
372  } catch (OperationNotAllowed&) {
373  agg = new PRMAggregate< GUM_SCALAR >(
374  c_agg->name(), c_agg->agg_type(), c_agg->type());
375  }
376 
377  bij.insert(&(c_agg->type().variable()), &(agg->type().variable()));
378  agg->setId(c_agg->id());
379  __nodeIdMap.insert(agg->id(), agg);
380  __aggregates.insert(agg);
381 
382  if (c.__nameMap[c_agg->name()] == c.__nameMap[c_agg->safeName()])
383  __nameMap.insert(agg->name(), agg);
384 
385  __nameMap.insert(agg->safeName(), agg);
386  }
387 
388  // Copying reference slots
389  for (const auto c_refslot : c.__referenceSlots) {
390  PRMReferenceSlot< GUM_SCALAR >* ref = new PRMReferenceSlot< GUM_SCALAR >(
391  c_refslot->name(),
392  const_cast< PRMClassElementContainer< GUM_SCALAR >& >(
393  c_refslot->slotType()),
394  c_refslot->isArray());
395 
396  ref->setId(c_refslot->id());
397  __nodeIdMap.insert(ref->id(), ref);
398  __referenceSlots.insert(ref);
399 
400  if (c.__nameMap[c_refslot->name()] == c.__nameMap[c_refslot->safeName()])
401  __nameMap.insert(ref->name(), ref);
402 
403  __nameMap.insert(ref->safeName(), ref);
404  }
405 
406  // Copying slot chains
407  for (const auto c_slotchain : c.__slotChains) {
408  // We just need to change the first PRMReferenceSlot<GUM_SCALAR> in
409  // the
410  // chain
411  Sequence< PRMClassElement< GUM_SCALAR >* > chain(c_slotchain->chain());
412 
413  chain.setAtPos(0, __nameMap[c_slotchain->chain().front()->name()]);
414 
415  PRMSlotChain< GUM_SCALAR >* sc =
416  new PRMSlotChain< GUM_SCALAR >(c_slotchain->name(), chain);
417  bij.insert(&(c_slotchain->type().variable()), &(sc->type().variable()));
418  sc->setId(c_slotchain->id());
419  __nodeIdMap.insert(sc->id(), sc);
420  __slotChains.insert(sc);
421 
422  __nameMap.insert(sc->name(), sc);
423  __nameMap.insert(sc->safeName(), sc);
424  }
425 
426  // Copying dependencies yield by arcs
427  for (const auto& arc : c.containerDag().arcs()) {
428  __nodeIdMap[arc.tail()]->addChild(*(__nodeIdMap[arc.head()]));
429  __nodeIdMap[arc.head()]->addParent(*(__nodeIdMap[arc.tail()]));
430  }
431 
432  // Copying the IO flag
433  this->_copyIOFlags(c);
434  // Copying content of CPF
435  for (const auto attr : c.__attributes) {
436  auto a = static_cast< PRMAttribute< GUM_SCALAR >* >(
437  __nameMap[attr->safeName()]);
438  a->copyCpf(bij, *attr);
439  }
440  }
441  }
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
Set< PRMReferenceSlot< GUM_SCALAR > * > __referenceSlots
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:354
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:338
Set< PRMAggregate< GUM_SCALAR > * > __aggregates
The sequence of aggregate.
Definition: PRMClass.h:357
virtual void _copyIOFlags(const PRMClassElementContainer &c)
Copy the IO Flags of c in this PRMClassElementContainer.
Set< PRMSlotChain< GUM_SCALAR > * > __slotChains
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:360
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
Set< PRMAttribute< GUM_SCALAR > * > __attributes
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:351
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:348
Set< PRMParameter< GUM_SCALAR > * > __parameters
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:363

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 1199 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__aggregates, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, and gum::prm::PRMClassElement< GUM_SCALAR >::safeName().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::overload().

1201  {
1202  __nameMap.insert(overloader->safeName(), overloader);
1203  __aggregates.insert(overloader);
1204  }
Set< PRMAggregate< GUM_SCALAR > * > __aggregates
The sequence of aggregate.
Definition: PRMClass.h:357
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:348

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 803 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__addCastDescendants(), gum::prm::PRMClass< GUM_SCALAR >::__attributes, gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::NodeGraphPart::addNodeWithId(), gum::ArcGraphPart::eraseParents(), gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMObject::name(), gum::prm::nextNodeId(), gum::prm::PRMAttribute< GUM_SCALAR >::overload(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), gum::prm::PRMClassElement< GUM_SCALAR >::setId(), and gum::prm::PRMAttribute< GUM_SCALAR >::type().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::overload().

805  {
806  __dag.eraseParents(overloaded->id());
807 
808  // Checking if we have to add cast descendant
809  if (overloader->type() != overloaded->type()) {
810  overloader->setId(nextNodeId());
811  __dag.addNodeWithId(overloader->id());
812  __nodeIdMap.insert(overloader->id(), overloader);
813  __nameMap[overloader->name()] = overloader;
814  __nameMap.insert(overloader->safeName(), overloader);
815  __attributes.insert(overloader);
816  __addCastDescendants(overloader, overloaded);
817  } else {
818  overloader->setId(overloaded->id());
819  __nodeIdMap[overloader->id()] = overloader;
820  __nameMap[overloader->name()] = overloader;
821  __nameMap[overloader->safeName()] = overloader;
822  __attributes.erase(overloaded);
823  __attributes.insert(overloader);
824  overloader->overload(overloaded);
825  delete overloaded;
826  }
827  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
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:338
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
NodeId nextNodeId()
Returns the next value of an unique counter for PRM&#39;s node id.
Definition: utils_prm.cpp:63
Set< PRMAttribute< GUM_SCALAR > * > __attributes
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:351
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:348
void __addCastDescendants(PRMClassElement< GUM_SCALAR > *attr)
Recursively adds cast descendant of attr in this Class<GUM_SCALAR>.
Definition: PRMClass_tpl.h:692
void eraseParents(const NodeId id)
erase all the parents of a given node

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 926 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMClass< GUM_SCALAR >::__parameters, gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), and gum::prm::PRMClassElement< GUM_SCALAR >::setId().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::overload().

928  {
929  overloader->setId(overloaded->id());
930  __nodeIdMap[overloader->id()] = overloader;
931  __nameMap[overloader->name()] = overloader;
932  __nameMap[overloader->safeName()] = overloader;
933  __parameters.erase(overloaded);
934  __parameters.insert(overloader);
935  delete overloaded;
936  }
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:338
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:348
Set< PRMParameter< GUM_SCALAR > * > __parameters
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:363

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 830 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMClass< GUM_SCALAR >::__referenceSlots, gum::prm::PRMClass< GUM_SCALAR >::__slotChains, gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::atPos(), gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::back(), gum::ArcGraphPart::children(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::containerDag(), gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::erase(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::insert(), gum::prm::PRMSlotChain< GUM_SCALAR >::lastElt(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), gum::prm::PRMClassElement< GUM_SCALAR >::setId(), gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::size(), gum::prm::PRMReferenceSlot< GUM_SCALAR >::slotType(), and gum::prm::PRMAttribute< GUM_SCALAR >::type().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::overload().

832  {
833  // Adding overloading reference
834  overloader->setId(overloaded->id());
835  __nodeIdMap[overloader->id()] = overloader;
836  __nameMap[overloader->name()] = overloader;
837  __nameMap.insert(overloader->safeName(), overloader);
838  __referenceSlots.insert(overloader);
839  PRMSlotChain< GUM_SCALAR >* sc = 0;
840  PRMReferenceSlot< GUM_SCALAR >* ref = 0;
841  PRMClassElement< GUM_SCALAR >* next = 0;
842  std::vector< PRMSlotChain< GUM_SCALAR >* > toRemove, toAdd;
843 
844  // Updating PRMSlotChain<GUM_SCALAR> which started with overloaded
845  for (const auto slotchain : __slotChains) {
846  // If the attribute pointed by this slotchain is overloaded, we need to
847  // change the slotchain
848  // names to it's safename version: ref.attr is replaced by
849  // ref.(type)attr.
850  if ((slotchain->chain().atPos(0) == overloaded)) {
851  Sequence< PRMClassElement< GUM_SCALAR >* > seq;
852  seq.insert(overloader);
853 
854  auto elt = ++(slotchain->chain().begin());
855 
856  while (elt != slotchain->chain().end()) {
857  ref = static_cast< PRMReferenceSlot< GUM_SCALAR >* >(seq.back());
858  next = &(ref->slotType().get((*elt)->name()));
859  seq.insert(next);
860  ++elt;
861  }
862 
863  // If the slotchain last element type changes, we change the slotchain
864  // to
865  // point towards the cast decendant
866  // with the correct type
867  if (seq.back()->type() != slotchain->lastElt().type()) {
868  seq.erase(seq.back());
869  seq.insert(&(static_cast< PRMReferenceSlot< GUM_SCALAR >* >(seq.back())
870  ->slotType()
871  .get(slotchain->lastElt().safeName())));
872  std::string sc_name;
873  std::string dot = ".";
874 
875  for (Size i = 0; i < seq.size() - 1; ++i) {
876  sc_name += seq.atPos(i)->name() + dot;
877  }
878 
879  sc_name += seq.back()->safeName();
880  sc = new PRMSlotChain< GUM_SCALAR >(sc_name, seq);
881  sc->setId(slotchain->id());
882 
883  for (const auto child : this->containerDag().children(sc->id())) {
884  auto& elt = get(child);
886  auto& attr = static_cast< PRMAttribute< GUM_SCALAR >& >(elt);
887  auto& old_type = slotchain->lastElt().type();
888  auto& new_type = sc->lastElt().type();
889  attr.swap(old_type, new_type);
890  } else {
891  GUM_ERROR(OperationNotAllowed, "unexpected ClassElement");
892  // get( child ).cpf().replace(
893  // slotchain->lastElt().type().variable(),
894  // sc->lastElt().type().variable() );
895  }
896  }
897 
898  toAdd.push_back(sc);
899  toRemove.push_back(slotchain);
900  } else {
901  // Types are identical, we just need to change the first reference
902  slotchain->chain().setAtPos(0, overloader);
903  }
904  }
905  }
906 
907  for (const auto torem : toRemove) {
908  __nameMap.erase(torem->name());
909  __slotChains.erase(torem);
910  delete torem;
911  }
912 
913  for (const auto toadd : toAdd) {
914  __nameMap.insert(toadd->name(), toadd);
915  __nodeIdMap[toadd->id()] = toadd;
916  __slotChains.insert(sc);
917  }
918 
919  // Removing overloaded PRMReferenceSlot<GUM_SCALAR>
920  __referenceSlots.erase(overloaded);
921  __nameMap.erase(overloaded->safeName());
922  delete overloaded;
923  }
unsigned long Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:50
Set< PRMReferenceSlot< GUM_SCALAR > * > __referenceSlots
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:354
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:338
virtual const DAG & containerDag() const
Returns the gum::DAG of this PRMClassElementContainer.
static INLINE bool isAttribute(const PRMClassElement &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:360
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
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:348
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 34 of file PRMClassElementContainer_tpl.h.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::__IOFlags.

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__inheritClass().

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

+ Here is the caller graph for this function:

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 1014 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__dag.

1014  {
1015  return __dag;
1016  }
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
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 1019 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__dag.

1019  {
1020  return __dag;
1021  }
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
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 964 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__extensions.

965  {
966  for (const auto ext : __extensions) {
967  set.insert(ext);
968  ext->_findAllSubtypes(set);
969  }
970  }
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:391
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.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::__IOFlags, GUM_ERROR, and gum::prm::PRMClassElement< GUM_SCALAR >::safeName().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__addIOInterfaceFlags(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::isInnerNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::isInputNode(), gum::prm::PRMInterface< GUM_SCALAR >::isOutputNode(), gum::prm::PRMClass< GUM_SCALAR >::isOutputNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode(), and gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 140 of file PRMClassElementContainer_tpl.h.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::__IOFlags, GUM_ERROR, and gum::prm::PRMClassElement< GUM_SCALAR >::safeName().

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

+ Here is the call graph for this function:

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 151 of file PRMClassElementContainer_tpl.h.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::__IOFlags, gum::HashTable< Key, Val, Alloc >::insert(), and gum::prm::PRMClassElement< GUM_SCALAR >::safeName().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__addIOInterfaceFlags(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode(), and gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode().

153  {
154  try {
155  __IOFlags[elt.safeName()] = flags;
156  } catch (NotFound&) { __IOFlags.insert(elt.safeName(), flags); }
157  }
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.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 998 of file PRMClass_tpl.h.

999  {
1000  // for ( const auto ext : __extensions ) {
1001  // // We test to prevent unnecessary recursive call from iter
1002  // if ( !ext->isOutputNode( elt ) ) {
1003  // ext->setOutputNode( elt, true );
1004  // }
1005  //}
1006  }
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 619 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__addCastDescendants(), gum::prm::PRMClass< GUM_SCALAR >::__addIOInterfaceFlags(), gum::prm::PRMClass< GUM_SCALAR >::__aggregates, gum::prm::PRMClass< GUM_SCALAR >::__attributes, gum::prm::PRMClass< GUM_SCALAR >::__checkInterfaces(), gum::prm::PRMClass< GUM_SCALAR >::__checkRefInterfaces(), gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMClass< GUM_SCALAR >::__parameters, gum::prm::PRMClass< GUM_SCALAR >::__referenceSlots, gum::prm::PRMClass< GUM_SCALAR >::__slotChains, gum::NodeGraphPart::addNodeWithId(), gum::prm::PRMClassElement< GUM_SCALAR >::elt_type(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMObject::name(), gum::prm::nextNodeId(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), and gum::prm::PRMClassElement< GUM_SCALAR >::setId().

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::__retrieveInputs(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::PRMFactory< GUM_SCALAR >::addAttribute(), gum::prm::PRMFactory< GUM_SCALAR >::addNoisyOrCompound(), and gum::prm::PRMFactory< GUM_SCALAR >::startAggregator().

619  {
620  if (__nameMap.exists(elt->name())) {
621  GUM_ERROR(DuplicateElement,
622  "name already used by another ClassElement<GUM_SCALAR>");
623  }
624 
625  elt->setId(nextNodeId());
626  __dag.addNodeWithId(elt->id());
627  __nodeIdMap.insert(elt->id(), elt);
628  __nameMap.insert(elt->name(), elt);
629 
630  try {
631  __nameMap.insert(elt->safeName(), elt);
632  } catch (DuplicateElement& e) {
635  throw DuplicateElement(e);
636  }
637  }
638 
639  switch (elt->elt_type()) {
641  __attributes.insert(static_cast< PRMAttribute< GUM_SCALAR >* >(elt));
642  __addCastDescendants(static_cast< PRMAttribute< GUM_SCALAR >* >(elt));
643 
644  // Update attribute or cast descendant id to respect implemented
645  // interface
646  __checkInterfaces(elt);
647 
649  break;
650  }
651 
653  __aggregates.insert(static_cast< PRMAggregate< GUM_SCALAR >* >(elt));
654  __addCastDescendants(static_cast< PRMAttribute< GUM_SCALAR >* >(elt));
655 
656  // Update attribute or cast descendant id to respect implemented
657  // interface
658  __checkInterfaces(elt);
659 
661  break;
662  }
663 
665  auto ref = static_cast< PRMReferenceSlot< GUM_SCALAR >* >(elt);
666  __referenceSlots.insert(ref);
667 
668  // Updating ref's id if ref implements an interface
670  break;
671  }
672 
674  __slotChains.insert(static_cast< PRMSlotChain< GUM_SCALAR >* >(elt));
675  break;
676  }
677 
679  __parameters.insert(static_cast< PRMParameter< GUM_SCALAR >* >(elt));
680  break;
681  }
682 
683  default: {
684  GUM_ERROR(FatalError, "unknown ClassElement<GUM_SCALAR> type");
685  }
686  }
687 
688  return elt->id();
689  }
void __checkInterfaces(PRMClassElement< GUM_SCALAR > *elt)
Check that a given element respects all the class interfaces.
Definition: PRMClass_tpl.h:527
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
Set< PRMReferenceSlot< GUM_SCALAR > * > __referenceSlots
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:354
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:338
Set< PRMAggregate< GUM_SCALAR > * > __aggregates
The sequence of aggregate.
Definition: PRMClass.h:357
void __checkRefInterfaces(PRMReferenceSlot< GUM_SCALAR > *elt)
Check that a given element respects all the class interfaces.
Definition: PRMClass_tpl.h:582
Set< PRMSlotChain< GUM_SCALAR > * > __slotChains
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:360
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
NodeId nextNodeId()
Returns the next value of an unique counter for PRM&#39;s node id.
Definition: utils_prm.cpp:63
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:973
Set< PRMAttribute< GUM_SCALAR > * > __attributes
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:351
static INLINE bool isSlotChain(const PRMClassElement &elt)
Return true if obj is of type PRMSlotChain.
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:348
void __addCastDescendants(PRMClassElement< GUM_SCALAR > *attr)
Recursively adds cast descendant of attr in this Class<GUM_SCALAR>.
Definition: PRMClass_tpl.h:692
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
static INLINE bool isParameter(const PRMClassElement &elt)
Return true if obj is of type PRMParameter.
Set< PRMParameter< GUM_SCALAR > * > __parameters
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:363

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 482 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::DAG::addArc(), gum::prm::PRMClassElement< GUM_SCALAR >::elt_type(), gum::prm::PRMSlotChain< GUM_SCALAR >::end(), gum::ArcGraphPart::existsArc(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMSlotChain< GUM_SCALAR >::lastElt(), and gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode().

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::__addParent(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::PRMFactory< GUM_SCALAR >::addAttribute(), and gum::prm::PRMClass< GUM_SCALAR >::completeInheritance().

483  {
484  PRMClassElement< GUM_SCALAR >* tail = 0;
485  PRMClassElement< GUM_SCALAR >* head = 0;
486 
487  try {
488  tail = __nameMap[tail_name];
489  head = __nameMap[head_name];
490  } catch (NotFound&) {
491  GUM_ERROR(NotFound,
492  "tail and/or head of arc does not exists in this Class");
493  }
494 
495  if ((tail->elt_type() == PRMClassElement< GUM_SCALAR >::prm_refslot)
496  || (head->elt_type() == PRMClassElement< GUM_SCALAR >::prm_refslot)) {
497  GUM_ERROR(OperationNotAllowed,
498  "a PRMReferenceSlot<GUM_SCALAR> can "
499  "not on neither side of an arc");
500  }
501 
502  if ((tail->elt_type() == PRMClassElement< GUM_SCALAR >::prm_slotchain)
503  && (head->elt_type() == PRMClassElement< GUM_SCALAR >::prm_slotchain)) {
504  GUM_ERROR(OperationNotAllowed,
505  "illegal insertion of an arc between two SlotChain<GUM_SCALAR>");
506  }
507 
508  if (!__dag.existsArc(Arc(tail->id(), head->id()))) {
509  __dag.addArc(tail->id(), head->id());
510  } else {
511  GUM_ERROR(DuplicateElement, "duplicate arc");
512  }
513 
514  get(tail->id()).addChild(get(head->id()));
515  get(head->id()).addParent(get(tail->id()));
516 
517  // Defining input / output nodes
518  if (tail->elt_type() == PRMClassElement< GUM_SCALAR >::prm_slotchain) {
519  PRMSlotChain< GUM_SCALAR >* sc =
520  static_cast< PRMSlotChain< GUM_SCALAR >* >(tail);
521  this->setInputNode(*head, true);
522  sc->end().setOutputNode(sc->end().get(sc->lastElt().safeName()), true);
523  }
524  }
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:334
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: DAG_inl.h:40
bool existsArc(const Arc &arc) const
indicates whether a given arc exists
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:348
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 1138 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__aggregates.

1138  {
1139  return __aggregates;
1140  }
Set< PRMAggregate< GUM_SCALAR > * > __aggregates
The sequence of aggregate.
Definition: PRMClass.h:357
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 1070 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__attributes.

1070  {
1071  return __attributes;
1072  }
Set< PRMAttribute< GUM_SCALAR > * > __attributes
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:351
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 174 of file PRMClassElementContainer_tpl.h.

References gum::prm::PRMClassElement< GUM_SCALAR >::safeName().

175  {
176  try {
177  return &elt == &(get(elt.safeName()));
178  } catch (NotFound&) { return false; }
179  }

+ Here is the call graph for this function:

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

Definition at line 291 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__bijection, gum::prm::PRMClass< GUM_SCALAR >::__superClass, gum::prm::PRMClass< GUM_SCALAR >::addArc(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::containerDag(), gum::prm::PRMAttribute< GUM_SCALAR >::copyCpf(), GUM_ERROR, gum::prm::PRMObject::name(), and gum::prm::PRMClass< GUM_SCALAR >::super().

291  {
292  if (__superClass) {
293  auto& elt = this->get(name);
296  GUM_ERROR(OperationNotAllowed,
297  "you can only complete inheritance for attributes");
298  }
299 
300  for (const auto& prnt : super().containerDag().parents(elt.id())) {
301  this->addArc(super().get(prnt).safeName(), elt.safeName());
302  }
303 
305  auto& attr = static_cast< PRMAttribute< GUM_SCALAR >& >(elt);
306  auto& super_attr =
307  static_cast< const PRMAttribute< GUM_SCALAR >& >(super().get(name));
308  attr.copyCpf(*__bijection, super_attr);
309  }
310  }
311  }
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
virtual const DAG & containerDag() const
Returns the gum::DAG of this PRMClassElementContainer.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
static INLINE bool isAttribute(const PRMClassElement &elt)
Returns true if obj_ptr is of type PRMAttribute.
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:396
virtual void addArc(const std::string &tail, const std::string &head)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::addArc().
Definition: PRMClass_tpl.h:482
static INLINE bool isAggregate(const PRMClassElement &elt)
Return true if obj is of type PRMAggregate.
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:66

+ Here is the call graph for this function:

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 183 of file PRMClassElementContainer_tpl.h.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::_dag().

Referenced by gum::prm::ClassDependencyGraph< GUM_SCALAR >::__addArcs(), gum::prm::PRMClass< GUM_SCALAR >::__inheritClass(), gum::prm::ClassBayesNet< GUM_SCALAR >::__init(), gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes(), gum::prm::PRMClass< GUM_SCALAR >::__overloadReference(), gum::prm::PRMFactory< GUM_SCALAR >::addAttribute(), gum::prm::PRMClass< GUM_SCALAR >::completeInheritance(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), operator<<(), and gum::prm::PRMClass< GUM_SCALAR >::PRMClass().

183  {
184  return _dag();
185  }
virtual const DAG & _dag() const =0

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Returns the string representation of a PRMObject.

Definition at line 80 of file PRMObject.h.

References gum::prm::PRMObject::CLASS, gum::prm::PRMObject::CLASS_ELT, gum::prm::PRMObject::INSTANCE, gum::prm::PRMObject::PRM_INTERFACE, gum::prm::PRMObject::SYSTEM, and gum::prm::PRMObject::TYPE.

Referenced by gum::prm::operator<<().

80  {
81  switch (type) {
82  case prm_type::CLASS: return "PRMType::CLASS";
83 
84  case prm_type::CLASS_ELT: return "PRMType::CLASS_ELT";
85 
86  case prm_type::TYPE: return "PRMType::TYPE";
87 
88  case prm_type::SYSTEM: return "PRMType::SYSTEM";
89 
90  case prm_type::INSTANCE: return "PRMType::INSTANCE";
91 
92  case prm_type::PRM_INTERFACE: return "PRMType::PRM_INTERFACE";
93 
94  default: return "unknown";
95  }
96  }

+ Here is the caller graph for this function:

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 165 of file PRMClassElementContainer_tpl.h.

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

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__checkInterface(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkLocalParent(), gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::__checkParameters(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkSlotChainLink(), gum::prm::PRMFactory< GUM_SCALAR >::addNoisyOrCompound(), gum::prm::PRMFactory< GUM_SCALAR >::continueAggregator(), gum::prm::PRMFactory< GUM_SCALAR >::continueAttribute(), gum::prm::PRMClass< GUM_SCALAR >::overload(), gum::prm::PRMInterface< GUM_SCALAR >::overload(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode(), and gum::prm::PRMFactory< GUM_SCALAR >::startAttribute().

166  {
167  try {
168  get(name);
169  return true;
170  } catch (NotFound&) { return false; }
171  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 160 of file PRMClassElementContainer_tpl.h.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::containerDag(), and gum::NodeGraphPart::exists().

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

+ Here is the call graph for this function:

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 1250 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__extensions.

1250  {
1251  return __extensions;
1252  }
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:391
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 1024 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, and GUM_ERROR.

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::__checkInterfaceImplementation(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkLocalParent(), gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::__checkParameters(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkRawCPT(), gum::prm::ClassBayesNet< GUM_SCALAR >::__init(), gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes(), gum::prm::PRMFactory< GUM_SCALAR >::__retrieveInputs(), gum::prm::PRMFactory< GUM_SCALAR >::addAttribute(), and gum::prm::PRMFactory< GUM_SCALAR >::addNoisyOrCompound().

1024  {
1025  try {
1026  return *(__nodeIdMap[id]);
1027  } catch (NotFound&) {
1028  GUM_ERROR(NotFound, "no ClassElement<GUM_SCALAR> with the given NodeId");
1029  }
1030  }
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:338
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the caller graph for this function:

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 1034 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, and GUM_ERROR.

1034  {
1035  try {
1036  return *(__nodeIdMap[id]);
1037  } catch (NotFound&) {
1038  GUM_ERROR(NotFound,
1039  "no ClassElement<GUM_SCALAR> with the given NodeId (" << id
1040  << ")");
1041  }
1042  }
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:338
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
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 1046 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__nameMap, GUM_ERROR, and gum::prm::PRMObject::name().

1046  {
1047  try {
1048  return *(__nameMap[name]);
1049  } catch (NotFound&) {
1050  GUM_ERROR(NotFound,
1051  "no ClassElement<GUM_SCALAR> with the given name (" << name
1052  << ")");
1053  }
1054  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
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:348
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

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 1058 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__nameMap, GUM_ERROR, and gum::prm::PRMObject::name().

1058  {
1059  try {
1060  return *(__nameMap[name]);
1061  } catch (NotFound&) {
1062  GUM_ERROR(NotFound,
1063  "no ClassElement<GUM_SCALAR> with the given name (" << name
1064  << ")");
1065  }
1066  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
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:348
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

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 1165 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__implements, GUM_ERROR, and gum::prm::PRMClass< GUM_SCALAR >::operator[]().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__addCastDescendants(), gum::prm::PRMFactory< GUM_SCALAR >::__checkInterfaceImplementation(), gum::prm::PRMClass< GUM_SCALAR >::__checkInterfaces(), and gum::prm::PRMClass< GUM_SCALAR >::__checkRefInterfaces().

1165  {
1166  if (__implements) {
1167  return *__implements;
1168  } else {
1169  GUM_ERROR(NotFound,
1170  "this Class does not implement any Interface<GUM_SCALAR>");
1171  }
1172  }
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 225 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__aggregates, gum::prm::PRMClass< GUM_SCALAR >::__bijection, gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMClass< GUM_SCALAR >::__superClass, gum::NodeGraphPart::addNodeWithId(), gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), gum::prm::PRMClassElement< GUM_SCALAR >::setId(), gum::prm::PRMAggregate< GUM_SCALAR >::setLabel(), gum::prm::PRMAggregate< GUM_SCALAR >::sharedLabel(), and gum::prm::PRMAggregate< GUM_SCALAR >::type().

225  {
226  if (__superClass) {
227  for (const auto c_agg : __superClass->__aggregates) {
228  PRMAggregate< GUM_SCALAR >* agg = nullptr;
229 
230  try {
231  agg = new PRMAggregate< GUM_SCALAR >(
232  c_agg->name(), c_agg->agg_type(), c_agg->type(), c_agg->label());
233  } catch (OperationNotAllowed&) {
234  agg = new PRMAggregate< GUM_SCALAR >(
235  c_agg->name(), c_agg->agg_type(), c_agg->type());
236  agg->sharedLabel(c_agg->sharedLabel());
237  agg->setLabel(c_agg->labelValue());
238  }
239 
240  __bijection->insert(&(c_agg->type().variable()),
241  &(agg->type().variable()));
242  agg->setId(c_agg->id());
243  __dag.addNodeWithId(agg->id());
244  __nodeIdMap.insert(agg->id(), agg);
245  __aggregates.insert(agg);
246 
247  if (__superClass->__nameMap[c_agg->name()]
248  == __superClass->__nameMap[c_agg->safeName()])
249  __nameMap.insert(agg->name(), agg);
250 
251  __nameMap.insert(agg->safeName(), agg);
252  }
253  }
254  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
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:338
Set< PRMAggregate< GUM_SCALAR > * > __aggregates
The sequence of aggregate.
Definition: PRMClass.h:357
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:396
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
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:348

+ Here is the call graph for this function:

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

Definition at line 196 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__attributes, gum::prm::PRMClass< GUM_SCALAR >::__bijection, gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMClass< GUM_SCALAR >::__superClass, and gum::NodeGraphPart::addNodeWithId().

196  {
197  if (__superClass) {
198  for (const auto c_attr : __superClass->__attributes) {
199  // using multiDimSparse to prevent unecessary memory allocation for
200  // large arrays (the potentials are copied latter)
201  auto attr = c_attr->newFactory(*this);
202 
203  __bijection->insert(&(c_attr->type().variable()),
204  &(attr->type().variable()));
205  attr->setId(c_attr->id());
206  try {
207  __dag.addNodeWithId(attr->id());
208  } catch (gum::Exception&) {
209  // Node reserved by an interface
210  }
211  __nodeIdMap.insert(attr->id(), attr);
212  __attributes.insert(attr);
213 
214  if (__superClass->__nameMap[c_attr->name()]
215  == __superClass->__nameMap[c_attr->safeName()]) {
216  __nameMap.insert(attr->name(), attr);
217  }
218 
219  __nameMap.insert(attr->safeName(), attr);
220  }
221  }
222  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
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:338
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:396
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
Base class for all aGrUM&#39;s exceptions.
Definition: exceptions.h:103
Set< PRMAttribute< GUM_SCALAR > * > __attributes
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:351
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:348

+ Here is the call graph for this function:

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

Definition at line 178 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMClass< GUM_SCALAR >::__parameters, gum::prm::PRMClass< GUM_SCALAR >::__superClass, and gum::NodeGraphPart::addNodeWithId().

178  {
179  if (__superClass) {
180  // Copying parameters
181  for (const auto c_param : __superClass->__parameters) {
182  auto param = new PRMParameter< GUM_SCALAR >(
183  c_param->name(), c_param->valueType(), c_param->value());
184 
185  __parameters.insert(param);
186 
187  param->setId(c_param->id());
188  __dag.addNodeWithId(param->id());
189  __nodeIdMap.insert(param->id(), param);
190  __nameMap.insert(param->name(), param);
191  }
192  }
193  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
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:338
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
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:348
Set< PRMParameter< GUM_SCALAR > * > __parameters
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:363

+ Here is the call graph for this function:

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

Definition at line 151 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMClass< GUM_SCALAR >::__referenceSlots, gum::prm::PRMClass< GUM_SCALAR >::__superClass, gum::NodeGraphPart::addNodeWithId(), gum::NodeGraphPart::existsNode(), and gum::prm::PRMClassElement< GUM_SCALAR >::setId().

151  {
152  if (__superClass) {
153  // Copying reference slots
154  for (const auto c_refslot : __superClass->__referenceSlots) {
155  auto ref = new PRMReferenceSlot< GUM_SCALAR >(
156  c_refslot->name(),
157  const_cast< PRMClassElementContainer< GUM_SCALAR >& >(
158  c_refslot->slotType()),
159  c_refslot->isArray());
160 
161  ref->setId(c_refslot->id());
162  // Not reserved by an interface
163  if (!__dag.existsNode(ref->id())) { __dag.addNodeWithId(ref->id()); }
164  __nodeIdMap.insert(ref->id(), ref);
165  __referenceSlots.insert(ref);
166 
167  if (__superClass->__nameMap[c_refslot->name()]
168  == __superClass->__nameMap[c_refslot->safeName()]) {
169  __nameMap.insert(ref->name(), ref);
170  }
171 
172  __nameMap.insert(ref->safeName(), ref);
173  }
174  }
175  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
Set< PRMReferenceSlot< GUM_SCALAR > * > __referenceSlots
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:354
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:338
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
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:348

+ Here is the call graph for this function:

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

Definition at line 257 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__bijection, gum::prm::PRMClass< GUM_SCALAR >::__dag, gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMClass< GUM_SCALAR >::__slotChains, gum::prm::PRMClass< GUM_SCALAR >::__superClass, and gum::NodeGraphPart::addNodeWithId().

257  {
258  if (__superClass) {
259  // Copying slot chains
260  for (const auto c_sc : __superClass->__slotChains) {
261  // Because of aggregators, some slotchains may exists already
262  if (!(__nameMap.exists(c_sc->name())
263  && __nameMap.exists(c_sc->safeName()))) {
264  // We just need to change the first PRMReferenceSlot<GUM_SCALAR> in
265  // the
266  // chain
267  auto chain = c_sc->chain();
268 
269  chain.setAtPos(0, __nameMap[c_sc->chain().front()->name()]);
270 
271  auto sc = new PRMSlotChain< GUM_SCALAR >(c_sc->name(), chain);
272  __bijection->insert(&(c_sc->type().variable()),
273  &(sc->type().variable()));
274  sc->setId(c_sc->id());
275  __dag.addNodeWithId(sc->id());
276  __nodeIdMap.insert(sc->id(), sc);
277  __slotChains.insert(sc);
278 
279  if (!__nameMap.exists(sc->name())) {
280  __nameMap.insert(sc->name(), sc);
281  }
282  if (!__nameMap.exists(sc->safeName())) {
283  __nameMap.insert(sc->safeName(), sc);
284  }
285  }
286  }
287  }
288  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
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:338
Set< PRMSlotChain< GUM_SCALAR > * > __slotChains
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:360
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:396
DAG __dag
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:334
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:348

+ Here is the call graph for this function:

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

Definition at line 132 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__implementInterfaces(), gum::prm::PRMClass< GUM_SCALAR >::__implements, and gum::prm::PRMClass< GUM_SCALAR >::__superClass.

132  {
133  if (__superClass) {
134  __superClass->__addExtension(this);
135  // Adding implemented interfaces, if any
136  if (__superClass->__implements) {
137  if (!__implements) {
138  __implements = new Set< PRMInterface< GUM_SCALAR >* >(
139  *(__superClass->__implements));
140  } else {
141  for (auto i : *(__superClass->__implements)) {
142  __implements->insert(i);
143  }
144  }
145  }
146  }
147  if (__implements) { __implementInterfaces(true); }
148  }
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
void __implementInterfaces(bool delayInheritance)
Proceed with the implementation of interfaces.
Definition: PRMClass_tpl.h:101

+ Here is the call graph for this function:

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 1260 of file PRMClass_tpl.h.

References GUM_ERROR, gum::prm::PRMObject::name(), and gum::prm::PRMClassElement< GUM_SCALAR >::type().

1261  {
1262  const PRMClassElement< GUM_SCALAR >& elt = get(safe_name);
1263 
1264  try {
1265  return elt.type().name() == get(elt.name()).type().name();
1266  } catch (OperationNotAllowed&) {
1267  GUM_ERROR(NotFound, "no attribute with the given name");
1268  }
1269  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

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

Returns true if obj_ptr is of type Class.

Definition at line 99 of file PRMObject.h.

References gum::prm::PRMObject::CLASS, and gum::prm::PRMObject::obj_type().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::scope(), and gum::prm::PRMFactory< GUM_SCALAR >::startAttribute().

99  {
100  return obj.obj_type() == prm_type::CLASS;
101  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 113 of file PRMClassElementContainer_tpl.h.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::_getIOFlag().

Referenced by gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 69 of file PRMClassElementContainer_tpl.h.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::_getIOFlag().

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

+ Here is the call graph for this function:

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 109 of file PRMObject.h.

References gum::prm::PRMObject::INSTANCE, gum::prm::PRMObject::name(), gum::prm::PRMObject::obj_type(), gum::prm::PRMObject::operator!=(), gum::prm::PRMObject::operator=(), gum::prm::PRMObject::operator==(), gum::prm::PRMObject::PRMObject(), and gum::prm::PRMObject::~PRMObject().

109  {
110  return obj.obj_type() == prm_type::INSTANCE;
111  }

+ Here is the call graph for this function:

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 104 of file PRMObject.h.

References gum::prm::PRMObject::obj_type(), and gum::prm::PRMObject::PRM_INTERFACE.

104  {
105  return obj.obj_type() == prm_type::PRM_INTERFACE;
106  }

+ Here is the call graph for this function:

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 1272 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__implements, gum::prm::PRMClass< GUM_SCALAR >::__superClass, and gum::prm::PRMClassElementContainer< GUM_SCALAR >::_getIOFlag().

Referenced by gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), and gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes().

1273  {
1274  try {
1275  if (!this->_getIOFlag(elt).second) {
1276  if (__implements) {
1277  for (auto i : *__implements) {
1278  if (i->isOutputNode(elt)) { return true; }
1279  }
1280  }
1281 
1282  if (__superClass && (__superClass->isOutputNode(elt))) { return true; }
1283 
1284  } else {
1285  return true;
1286  }
1287  } catch (NotFound&) {}
1288  return false;
1289  }
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
virtual std::pair< bool, bool > & _getIOFlag(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 444 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__implements, gum::prm::PRMClass< GUM_SCALAR >::__superClass, gum::prm::PRMObject::CLASS, GUM_ERROR, gum::prm::PRMObject::obj_type(), and gum::prm::PRMObject::PRM_INTERFACE.

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__implementInterfaces().

445  {
446  switch (cec.obj_type()) {
448  const PRMClass< GUM_SCALAR >* current = this;
449 
450  while (current != 0) {
451  if (current == &(cec)) return true;
452 
453  current = current->__superClass;
454  }
455 
456  return false;
457  }
458 
460  if (__implements != nullptr) {
461  const PRMInterface< GUM_SCALAR >& i =
462  static_cast< const PRMInterface< GUM_SCALAR >& >(cec);
463 
464  if (__implements->exists(
465  const_cast< PRMInterface< GUM_SCALAR >* >(&i)))
466  return true;
467 
468  for (const auto impl : *__implements)
469  if (impl->isSubTypeOf(i)) return true;
470  }
471 
472  return false;
473  }
474 
475  default: {
476  GUM_ERROR(FatalError, "unknown ClassElementContainer<GUM_SCALAR>");
477  }
478  }
479  }
friend class PRMInterface< GUM_SCALAR >
Definition: PRMClass.h:59
Set< PRMInterface< GUM_SCALAR > * > * __implements
The Set of implemented interface of this.
Definition: PRMClass.h:386
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 121 of file PRMClassElementContainer_tpl.h.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::isSubTypeOf().

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

+ Here is the call graph for this function:

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 76 of file PRMObject.h.

Referenced by gum::prm::PRMClassElement< GUM_SCALAR >::cast(), gum::prm::decomposePath(), gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMReferenceSlot< GUM_SCALAR >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), and gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain().

76 { return "("; }

+ Here is the caller graph for this function:

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

Returns the name of this object.

Definition at line 32 of file PRMObject_inl.h.

References gum::prm::PRMObject::__name.

Referenced by gum::prm::SVE< GUM_SCALAR >::__addDelayedVariable(), gum::prm::PRMClass< GUM_SCALAR >::__addIOInterfaceFlags(), gum::prm::PRMFactory< GUM_SCALAR >::__addParent(), gum::prm::PRMInstance< GUM_SCALAR >::__addReferingInstance(), gum::prm::PRMClass< GUM_SCALAR >::__checkInterface(), gum::prm::PRMFactory< GUM_SCALAR >::__checkInterfaceImplementation(), gum::prm::PRMClass< GUM_SCALAR >::__checkInterfaces(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkRawCPT(), gum::prm::PRMClass< GUM_SCALAR >::__checkRefInterface(), gum::prm::PRMClass< GUM_SCALAR >::__checkRefInterfaces(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkRuleCPTSumsTo1(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAggregates(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttribute(), gum::prm::PRMSlotChain< GUM_SCALAR >::__copyLastElt(), gum::prm::PRMSystem< GUM_SCALAR >::__groundAttr(), gum::prm::PRMSystem< GUM_SCALAR >::__groundPotential(), gum::prm::PRMSystem< GUM_SCALAR >::__groundRef(), gum::prm::PRMClass< GUM_SCALAR >::__inheritClass(), gum::prm::PRMInterface< GUM_SCALAR >::__overloadAttribute(), gum::prm::PRMClass< GUM_SCALAR >::__overloadAttribute(), gum::prm::PRMClass< GUM_SCALAR >::__overloadParameter(), gum::prm::PRMClass< GUM_SCALAR >::__overloadReference(), gum::prm::PRMInterface< GUM_SCALAR >::__overloadReferenceSlot(), gum::prm::__print_attribute__(), gum::prm::__print_instance__(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::__str(), gum::prm::StructuredInference< GUM_SCALAR >::__str(), gum::prm::PRMInterface< GUM_SCALAR >::add(), gum::prm::PRMSystem< GUM_SCALAR >::add(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::PRMFormAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMClassElement< GUM_SCALAR >::cast(), gum::prm::PRMClass< GUM_SCALAR >::completeInheritance(), gum::prm::PRMFormAttribute< GUM_SCALAR >::copy(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::o3prmr::O3prmrInterpreter::findAttributeName(), gum::prm::o3prmr::O3prmrInterpreter::findInstanceName(), gum::prm::PRMInterface< GUM_SCALAR >::get(), gum::prm::PRMSystem< GUM_SCALAR >::get(), gum::prm::PRMClass< GUM_SCALAR >::get(), gum::prm::PRMSystem< GUM_SCALAR >::getArray(), gum::prm::PRMSystem< GUM_SCALAR >::getArrayType(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMAggregate< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMSystem< GUM_SCALAR >::groundedBN(), gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates(), gum::prm::PRMClass< GUM_SCALAR >::isCastDescendant(), gum::prm::PRMObject::isInstance(), gum::prm::PRMObject::name(), gum::prm::PRMType< GUM_SCALAR >::name(), gum::prm::PRMFormAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMType< GUM_SCALAR >::operator!=(), gum::prm::PRMObject::operator!=(), operator<<(), gum::prm::PRMType< GUM_SCALAR >::operator==(), gum::prm::PRMObject::operator==(), gum::prm::PRMInterface< GUM_SCALAR >::operator[](), gum::prm::PRMClass< GUM_SCALAR >::operator[](), gum::prm::PRMInterface< GUM_SCALAR >::overload(), gum::prm::PRMClass< GUM_SCALAR >::overload(), gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMParameter< GUM_SCALAR >::PRMParameter(), gum::prm::PRMReferenceSlot< GUM_SCALAR >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode(), and gum::prm::PRMAggregate< double >::str2enum().

32 { return __name; }
std::string __name
Definition: PRMObject.h:197
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 wath you are doing !

Definition at line 36 of file PRMObject_inl.h.

References gum::prm::PRMObject::__name, and gum::prm::PRMObject::name().

36 { __name = name; }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
std::string __name
Definition: PRMObject.h:197

+ Here is the call graph for this function:

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 1009 of file PRMClass_tpl.h.

References gum::prm::PRMObject::CLASS.

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::PRMObject::__name, and gum::prm::PRMObject::name().

Referenced by gum::prm::PRMObject::isInstance().

46  {
47  return __name != obj.name();
48  }
std::string __name
Definition: PRMObject.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

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.

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 40 of file PRMObject_inl.h.

References gum::prm::PRMObject::__name, and gum::prm::PRMObject::name().

Referenced by gum::prm::PRMObject::isInstance().

40  {
41  return __name == obj.name();
42  }
std::string __name
Definition: PRMObject.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 1176 of file PRMClass_tpl.h.

Referenced by gum::prm::PRMClass< GUM_SCALAR >::implements(), and gum::prm::PRMClass< GUM_SCALAR >::operator[]().

1176  {
1177  return get(id);
1178  }

+ Here is the caller graph for this function:

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 1182 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::operator[]().

1182  {
1183  return get(id);
1184  }

+ Here is the call graph for this function:

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 1188 of file PRMClass_tpl.h.

References gum::prm::PRMObject::name(), and gum::prm::PRMClass< GUM_SCALAR >::operator[]().

1188  {
1189  return get(name);
1190  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32

+ Here is the call graph for this function:

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 1194 of file PRMClass_tpl.h.

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

1194  {
1195  return get(name);
1196  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32

+ Here is the call graph for this function:

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 731 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__addIOInterfaceFlags(), gum::prm::PRMClass< GUM_SCALAR >::__checkOverloadLegality(), gum::prm::PRMClass< GUM_SCALAR >::__nameMap, gum::prm::PRMClass< GUM_SCALAR >::__overloadAggregate(), gum::prm::PRMClass< GUM_SCALAR >::__overloadAttribute(), gum::prm::PRMClass< GUM_SCALAR >::__overloadParameter(), gum::prm::PRMClass< GUM_SCALAR >::__overloadReference(), gum::prm::PRMClassElement< GUM_SCALAR >::elt_type(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMObject::name(), and gum::prm::PRMClass< GUM_SCALAR >::super().

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), and gum::prm::PRMFactory< GUM_SCALAR >::startAggregator().

731  {
732  try {
733  if (!super().exists(overloader->name())) {
734  GUM_ERROR(OperationNotAllowed,
735  "found no ClassElement<GUM_SCALAR> to overload");
736  }
737  } catch (NotFound&) {
738  GUM_ERROR(OperationNotAllowed,
739  "overload is possible only with subclasses");
740  }
741 
742  PRMClassElement< GUM_SCALAR >* overloaded = __nameMap[overloader->name()];
743  if (overloaded == overloader) {
744  GUM_ERROR(DuplicateElement, "dupplicate ClassElement");
745  }
746  // Checking overload legality
747  if (!__checkOverloadLegality(overloaded, overloader)) {
748  GUM_ERROR(OperationNotAllowed, "illegal overload");
749  }
750 
751  switch (overloader->elt_type()) {
753  auto overloader_attr =
754  static_cast< PRMAttribute< GUM_SCALAR >* >(overloader);
755  auto overloaded_attr =
756  static_cast< PRMAttribute< GUM_SCALAR >* >(overloaded);
757  __overloadAttribute(overloader_attr, overloaded_attr);
758  __addIOInterfaceFlags(overloader);
759  break;
760  }
761 
764  static_cast< PRMAggregate< GUM_SCALAR >* >(overloader), overloaded);
765  __addIOInterfaceFlags(overloader);
766  break;
767  }
768 
770  // __checkOverloadLegality guaranties that overloaded is a
771  // PRMReferenceSlot<GUM_SCALAR>
772  auto overloader_ref =
773  static_cast< PRMReferenceSlot< GUM_SCALAR >* >(overloader);
774  auto overloaded_ref =
775  static_cast< PRMReferenceSlot< GUM_SCALAR >* >(overloaded);
776  __overloadReference(overloader_ref, overloaded_ref);
777  break;
778  }
779 
781  GUM_ERROR(OperationNotAllowed,
782  "SlotChain<GUM_SCALAR> can not be overloaded");
783  break;
784  }
785 
787  auto overloaded_param =
788  static_cast< PRMParameter< GUM_SCALAR >* >(overloaded);
789  auto overloader_param =
790  static_cast< PRMParameter< GUM_SCALAR >* >(overloader);
791  __overloadParameter(overloader_param, overloaded_param);
792  break;
793  }
794  default: {
795  GUM_ERROR(OperationNotAllowed, "unknown ClassElement<GUM_SCALAR> type");
796  }
797  }
798 
799  return overloader->id();
800  }
void __overloadAttribute(PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
Overloads an attribute.
Definition: PRMClass_tpl.h:803
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...
bool __checkOverloadLegality(const PRMClassElement< GUM_SCALAR > *overloaded, const PRMClassElement< GUM_SCALAR > *overloader)
Return true of overloaded can be overload by overloader.
void __overloadAggregate(PRMAggregate< GUM_SCALAR > *overloader, PRMClassElement< GUM_SCALAR > *overloaded)
Overloads an aggregate.
void __overloadParameter(PRMParameter< GUM_SCALAR > *overloader, PRMParameter< GUM_SCALAR > *overloaded)
Overloads a parameter.
Definition: PRMClass_tpl.h:926
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:973
void __overloadReference(PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
Overloads a reference slot.
Definition: PRMClass_tpl.h:830
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:348
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:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 1076 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__parameters.

Referenced by gum::prm::PRMClass< GUM_SCALAR >::scope().

1076  {
1077  return __parameters;
1078  }
Set< PRMParameter< GUM_SCALAR > * > __parameters
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:363

+ Here is the caller graph for this function:

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 1144 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__referenceSlots.

Referenced by gum::prm::PRMClass< GUM_SCALAR >::scope().

1144  {
1145  return __referenceSlots;
1146  }
Set< PRMReferenceSlot< GUM_SCALAR > * > __referenceSlots
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:354

+ Here is the caller graph for this function:

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 77 of file PRMObject.h.

Referenced by gum::prm::PRMClassElement< GUM_SCALAR >::cast(), gum::prm::decomposePath(), gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMReferenceSlot< GUM_SCALAR >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), and gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain().

77 { return ")"; }

+ Here is the caller graph for this function:

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 1097 of file PRMClass_tpl.h.

References gum::HashTable< Key, Val, Alloc >::insert(), gum::prm::PRMObject::isClass(), gum::prm::PRMClass< GUM_SCALAR >::parameters(), and gum::prm::PRMClass< GUM_SCALAR >::referenceSlots().

Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkRawCPT(), and gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkRuleCPT().

1097  {
1098  HashTable< std::string, const PRMParameter< GUM_SCALAR >* > params;
1099 
1100  for (const auto p : parameters()) {
1101  params.insert(p->name(), p);
1102  }
1103 
1104  std::queue< ParamScopeData< GUM_SCALAR > > queue;
1105 
1106  for (const auto ref : referenceSlots()) {
1107  if (PRMObject::isClass(ref->slotType())) {
1108  queue.push(ParamScopeData< GUM_SCALAR >("", *ref, 1));
1109  }
1110  }
1111 
1112  while (!queue.empty()) {
1113  auto data = queue.front();
1114  queue.pop();
1115 
1116  if (data.depth < 5) {
1117  for (const auto p : data.c->parameters()) {
1118  params.insert(data.prefix + p->name(), p);
1119  }
1120 
1121  for (const auto ref : data.c->referenceSlots()) {
1122  if (PRMObject::isClass(ref->slotType())) {
1123  queue.push(
1124  ParamScopeData< GUM_SCALAR >(data.prefix, *ref, data.depth + 1));
1125  }
1126  }
1127  } else {
1128  // @todo depth>5 is a workaround. Cycle detection is needed here !
1129  GUM_TRACE("Depth limit reached when looking up parameters");
1130  }
1131  }
1132 
1133  return params;
1134  }
static INLINE bool isClass(const PRMObject &obj)
Returns true if obj_ptr is of type Class.
Definition: PRMObject.h:99
const Set< PRMReferenceSlot< GUM_SCALAR > * > & referenceSlots() const
Returns the set of PRMReferenceSlot<GUM_SCALAR> of this Class<GUM_SCALAR>.
const Set< PRMParameter< GUM_SCALAR > * > & parameters() const
Returns the set of parameters of this Class<GUM_SCALAR>.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 77 of file PRMClassElementContainer_tpl.h.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::_getIOFlag(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::_setIOFlag(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::isAggregate(), gum::prm::PRMObject::name(), and gum::prm::PRMClassElement< GUM_SCALAR >::safeName().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::addArc().

78  {
79  if (!exists(elt.safeName())) {
80  GUM_ERROR(NotFound,
81  ": <" + elt.safeName() + "> is not in <" + name() + ">");
84  try {
85  _getIOFlag(elt).first = b;
86  } catch (NotFound&) { _setIOFlag(elt, std::make_pair(b, false)); }
87  } else {
88  GUM_ERROR(WrongClassElement,
89  "given id is not an PRMAttribute or an PRMAggregate");
90  }
91  }
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...
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
static INLINE bool isAttribute(const PRMClassElement &elt)
Returns true if obj_ptr is of type PRMAttribute.
virtual std::pair< bool, bool > & _getIOFlag(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
static INLINE bool isAggregate(const PRMClassElement &elt)
Return true if obj is of type PRMAggregate.
virtual void _setIOFlag(const PRMClassElement< GUM_SCALAR > &elt, const std::pair< bool, bool > &flags)
Defines the IO flags of a PRMClassElement<GUM_SCALAR>.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::_getIOFlag(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::_setIOFlag(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::_updateDescendants(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::isAggregate(), gum::prm::PRMObject::name(), and gum::prm::PRMClassElement< GUM_SCALAR >::safeName().

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::__buildSlotChain().

95  {
96  if (!exists(elt.safeName())) {
97  GUM_ERROR(NotFound, "<" + elt.safeName() + "> is not in <" + name() + ">");
100  try {
101  _getIOFlag(elt).second = b;
102  } catch (NotFound&) { _setIOFlag(elt, std::make_pair(false, b)); }
103 
104  if (b) { _updateDescendants(elt); }
105  } else {
106  GUM_ERROR(WrongClassElement,
107  "given ClassElement<GUM_SCALAR> is not an "
108  "PRMAttribute or an PRMAggregate");
109  }
110  }
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...
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
static INLINE bool isAttribute(const PRMClassElement &elt)
Returns true if obj_ptr is of type PRMAttribute.
virtual std::pair< bool, bool > & _getIOFlag(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
static INLINE bool isAggregate(const PRMClassElement &elt)
Return true if obj is of type PRMAggregate.
virtual void _setIOFlag(const PRMClassElement< GUM_SCALAR > &elt, const std::pair< bool, bool > &flags)
Defines the IO flags of a PRMClassElement<GUM_SCALAR>.
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...
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 1150 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__slotChains.

1150  {
1151  return __slotChains;
1152  }
Set< PRMSlotChain< GUM_SCALAR > * > __slotChains
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:360
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 1155 of file PRMClass_tpl.h.

References gum::prm::PRMClass< GUM_SCALAR >::__superClass, and GUM_ERROR.

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__addIOInterfaceFlags(), gum::prm::PRMClass< GUM_SCALAR >::__implementInterfaces(), gum::prm::PRMClass< GUM_SCALAR >::completeInheritance(), and gum::prm::PRMClass< GUM_SCALAR >::overload().

1155  {
1156  if (__superClass) {
1157  return *__superClass;
1158  } else {
1159  GUM_ERROR(NotFound, "this Class is not a subclass");
1160  }
1161  }
PRMClass< GUM_SCALAR > * __superClass
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:383
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the caller graph for this function:

Friends And Related Function Documentation

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

Definition at line 59 of file PRMClass.h.

Member Data Documentation

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 396 of file PRMClass.h.

Referenced by gum::prm::PRMClass< GUM_SCALAR >::completeInheritance(), gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates(), gum::prm::PRMClass< GUM_SCALAR >::inheritAttributes(), gum::prm::PRMClass< GUM_SCALAR >::inheritSlotChains(), and gum::prm::PRMClass< GUM_SCALAR >::~PRMClass().

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

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__addExtension(), gum::prm::PRMClass< GUM_SCALAR >::_findAllSubtypes(), and gum::prm::PRMClass< GUM_SCALAR >::extensions().


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