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

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

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

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

Public Member Functions

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

Protected Member Functions

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

Friends

class PRMInterface< GUM_SCALAR >
 

PRMClassElement<GUM_SCALAR> members

HashTable< std::string, PRMClassElement< GUM_SCALAR > *> nameMap__
 Mapping between a member's name and itself. Used for fast access to a member given it's name. More...
 
Set< PRMAttribute< GUM_SCALAR > *> attributes__
 The sequence of PRMAttribute<GUM_SCALAR>s. More...
 
Set< PRMReferenceSlot< GUM_SCALAR > *> referenceSlots__
 The sequence of PRMReferenceSlot<GUM_SCALAR>. More...
 
Set< PRMAggregate< GUM_SCALAR > *> aggregates__
 The sequence of aggregate. More...
 
Set< PRMSlotChain< GUM_SCALAR > *> slotChains__
 The set of gum::PRMSlotChain<GUM_SCALAR>s. More...
 
Set< PRMParameter< GUM_SCALAR > *> parameters__
 The Set of parameters in this Class<GUM_SCALAR>. More...
 
void addCastDescendants__ (PRMClassElement< GUM_SCALAR > *attr)
 Recursively adds cast descendant of attr in this Class<GUM_SCALAR>. More...
 
void addCastDescendants__ (PRMAttribute< GUM_SCALAR > *start, PRMAttribute< GUM_SCALAR > *end)
 Recursively adds cast descendant from start to end in this Class<GUM_SCALAR>. More...
 

Inheritance members

PRMClass< GUM_SCALAR > * superClass__
 The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this. Note that this is first searched for gum::PRMClassElement<GUM_SCALAR>. More...
 
Set< PRMInterface< GUM_SCALAR > *> * implements__
 The Set of implemented interface of this. More...
 
Set< PRMClass< GUM_SCALAR > *> extensions__
 The set of Class<GUM_SCALAR> which are extension of this Class<GUM_SCALAR> (i.e. direct subtypes). More...
 
Bijection< const DiscreteVariable *, const DiscreteVariable *> * bijection__
 The bijection between variables in super and variables in this The bijection's firsts are attributes in this and its seconds are attributes in c. More...
 
HashFunc< PRMClassElementContainer< GUM_SCALAR > *> dummy_hashfunc__
 a dummy member used to fix a compilation issue in clang4 More...
 
void inheritClass__ (const PRMClass< GUM_SCALAR > &c)
 Proceed with the copy when this inherits c. More...
 
void implementInterfaces__ (bool delayInheritance)
 Proceed with the implementation of interfaces. More...
 
void checkInterfaces__ (PRMClassElement< GUM_SCALAR > *elt)
 Check that a given element respects all the class interfaces. More...
 
void checkInterface__ (PRMClassElement< GUM_SCALAR > *elt, PRMInterface< GUM_SCALAR > *i)
 Check that a given element respects a specific interface. More...
 
void checkRefInterfaces__ (PRMReferenceSlot< GUM_SCALAR > *elt)
 Check that a given element respects all the class interfaces. More...
 
void checkRefInterface__ (PRMReferenceSlot< GUM_SCALAR > *elt, PRMInterface< GUM_SCALAR > *i)
 Check that a given element respects a specific interface. More...
 
void addIOInterfaceFlags__ (PRMClassElement< GUM_SCALAR > *elt)
 Check if elt is present in an implementation. If it is, its IO flags are updated. More...
 
void addExtension__ (PRMClass< GUM_SCALAR > *c)
 This method is called when a sub-Class<GUM_SCALAR> of this Class<GUM_SCALAR> is created. More...
 
bool checkOverloadLegality__ (const PRMClassElement< GUM_SCALAR > *overloaded, const PRMClassElement< GUM_SCALAR > *overloader)
 Return true of overloaded can be overload by overloader. More...
 
void overloadAttribute__ (PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
 Overloads an attribute. More...
 
void overloadAggregate__ (PRMAggregate< GUM_SCALAR > *overloader, PRMClassElement< GUM_SCALAR > *overloaded)
 Overloads an aggregate. More...
 
void overloadReference__ (PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
 Overloads a reference slot. More...
 
void overloadParameter__ (PRMParameter< GUM_SCALAR > *overloader, PRMParameter< GUM_SCALAR > *overloaded)
 Overloads a parameter. More...
 

Built-in types.

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

Detailed Description

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

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

See also
PRMClassElement

Definition at line 66 of file PRMClass.h.

Member Enumeration Documentation

◆ prm_type

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

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

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

Enumerator
ALL 
CLASS 
PRM_INTERFACE 
CLASS_ELT 
TYPE 
SYSTEM 
INSTANCE 

Definition at line 69 of file PRMObject.h.

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

Constructor & Destructor Documentation

◆ PRMClass() [1/6]

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

Default constructor.

Parameters
nameThe class name.

Definition at line 40 of file PRMClass_tpl.h.

40  :
41  PRMClassElementContainer< GUM_SCALAR >(name), superClass__(nullptr),
42  implements__(nullptr), bijection__(nullptr) {
43  GUM_CONSTRUCTOR(PRMClass);
44  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:40
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:403
Set< PRMInterface< GUM_SCALAR > *> * implements__
The Set of implemented interface of this.
Definition: PRMClass.h:394
PRMClass< GUM_SCALAR > * superClass__
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:391

◆ PRMClass() [2/6]

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

Constructor for building a subclass of super.

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

Definition at line 47 of file PRMClass_tpl.h.

49  :
50  PRMClassElementContainer< GUM_SCALAR >(name),
51  superClass__(&super), implements__(nullptr),
53  new Bijection< const DiscreteVariable*, const DiscreteVariable* >()) {
54  GUM_CONSTRUCTOR(PRMClass);
55  if (!delayInheritance) {
56  dag__ = super.containerDag();
58  }
59  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
DAG dag__
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:342
void inheritClass__(const PRMClass< GUM_SCALAR > &c)
Proceed with the copy when this inherits c.
Definition: PRMClass_tpl.h:315
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:40
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:403
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.
Set< PRMInterface< GUM_SCALAR > *> * implements__
The Set of implemented interface of this.
Definition: PRMClass.h:394
PRMClass< GUM_SCALAR > * superClass__
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:391

◆ PRMClass() [3/6]

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

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

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

Definition at line 62 of file PRMClass_tpl.h.

64  :
65  PRMClassElementContainer< GUM_SCALAR >(name),
66  superClass__(nullptr),
67  implements__(new Set< PRMInterface< GUM_SCALAR >* >(set)),
68  bijection__(nullptr) {
69  GUM_CONSTRUCTOR(PRMClass);
70 
71  if (!delayInheritance) { implementInterfaces__(false); }
72  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
friend class PRMInterface< GUM_SCALAR >
Definition: PRMClass.h:67
void implementInterfaces__(bool delayInheritance)
Proceed with the implementation of interfaces.
Definition: PRMClass_tpl.h:102
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:40
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:403
Set< PRMInterface< GUM_SCALAR > *> * implements__
The Set of implemented interface of this.
Definition: PRMClass.h:394
PRMClass< GUM_SCALAR > * superClass__
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:391

◆ PRMClass() [4/6]

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

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

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

Definition at line 75 of file PRMClass_tpl.h.

78  :
79  PRMClassElementContainer< GUM_SCALAR >(name),
80  superClass__(&super), implements__(nullptr),
82  new Bijection< const DiscreteVariable*, const DiscreteVariable* >()) {
83  GUM_CONSTRUCTOR(PRMClass);
84  if (!delayInheritance) {
85  dag__ = super.containerDag();
87  }
88 
89  // Adding other implementation
90  if (implements__ == nullptr) { // super has not created implements__
91  implements__ = new Set< PRMInterface< GUM_SCALAR >* >(set);
92  } else { // we just add the new implementations
93  for (const auto elt: set) {
94  implements__->insert(elt);
95  }
96  }
97 
98  if (!delayInheritance) { implementInterfaces__(false); }
99  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
DAG dag__
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:342
void inheritClass__(const PRMClass< GUM_SCALAR > &c)
Proceed with the copy when this inherits c.
Definition: PRMClass_tpl.h:315
void implementInterfaces__(bool delayInheritance)
Proceed with the implementation of interfaces.
Definition: PRMClass_tpl.h:102
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:40
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:403
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.
Set< PRMInterface< GUM_SCALAR > *> * implements__
The Set of implemented interface of this.
Definition: PRMClass.h:394
PRMClass< GUM_SCALAR > * superClass__
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:391

◆ PRMClass() [5/6]

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

Copy constructor.

◆ PRMClass() [6/6]

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

Move constructor.

◆ ~PRMClass()

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

Destructor.

Definition at line 120 of file PRMClass_tpl.h.

120  {
121  GUM_DESTRUCTOR(PRMClass);
122 
123  for (const auto& elt: nodeIdMap__) {
124  delete elt.second;
125  }
126 
127  if (implements__) { delete implements__; }
128 
129  if (bijection__) { delete bijection__; }
130  }
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:346
PRMClass(const std::string &name)
Default constructor.
Definition: PRMClass_tpl.h:40
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:403
Set< PRMInterface< GUM_SCALAR > *> * implements__
The Set of implemented interface of this.
Definition: PRMClass.h:394

Member Function Documentation

◆ add()

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

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

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

Definition at line 621 of file PRMClass_tpl.h.

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

621  {
622  if (nameMap__.exists(elt->name())) {
623  GUM_ERROR(DuplicateElement,
624  "name " << elt->name()
625  << " already used by another ClassElement");
626  }
627 
628  elt->setId(nextNodeId());
629  dag__.addNodeWithId(elt->id());
630  nodeIdMap__.insert(elt->id(), elt);
631  nameMap__.insert(elt->name(), elt);
632 
633  try {
634  nameMap__.insert(elt->safeName(), elt);
635  } catch (DuplicateElement& e) {
638  throw DuplicateElement(e);
639  }
640  }
641 
642  switch (elt->elt_type()) {
644  attributes__.insert(static_cast< PRMAttribute< GUM_SCALAR >* >(elt));
645  addCastDescendants__(static_cast< PRMAttribute< GUM_SCALAR >* >(elt));
646 
647  // Update attribute or cast descendant id to respect implemented
648  // interface
649  checkInterfaces__(elt);
650 
652  break;
653  }
654 
656  aggregates__.insert(static_cast< PRMAggregate< GUM_SCALAR >* >(elt));
657  addCastDescendants__(static_cast< PRMAttribute< GUM_SCALAR >* >(elt));
658 
659  // Update attribute or cast descendant id to respect implemented
660  // interface
661  checkInterfaces__(elt);
662 
664  break;
665  }
666 
668  auto ref = static_cast< PRMReferenceSlot< GUM_SCALAR >* >(elt);
669  referenceSlots__.insert(ref);
670 
671  // Updating ref's id if ref implements an interface
673  break;
674  }
675 
677  slotChains__.insert(static_cast< PRMSlotChain< GUM_SCALAR >* >(elt));
678  break;
679  }
680 
682  parameters__.insert(static_cast< PRMParameter< GUM_SCALAR >* >(elt));
683  break;
684  }
685 
686  default: {
687  GUM_ERROR(FatalError, "unknown ClassElement<GUM_SCALAR> type");
688  }
689  }
690 
691  return elt->id();
692  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
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:977
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:356
static INLINE bool isParameter(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMParameter.
DAG dag__
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:342
void checkInterfaces__(PRMClassElement< GUM_SCALAR > *elt)
Check that a given element respects all the class interfaces.
Definition: PRMClass_tpl.h:529
void checkRefInterfaces__(PRMReferenceSlot< GUM_SCALAR > *elt)
Check that a given element respects all the class interfaces.
Definition: PRMClass_tpl.h:584
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:346
NodeId nextNodeId()
Returns the next value of an unique counter for PRM&#39;s node id.
Definition: utils_prm.cpp:65
void addCastDescendants__(PRMClassElement< GUM_SCALAR > *attr)
Recursively adds cast descendant of attr in this Class<GUM_SCALAR>.
Definition: PRMClass_tpl.h:695
Set< PRMReferenceSlot< GUM_SCALAR > *> referenceSlots__
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:362
Set< PRMAttribute< GUM_SCALAR > *> attributes__
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:359
Set< PRMAggregate< GUM_SCALAR > *> aggregates__
The sequence of aggregate.
Definition: PRMClass.h:365
static INLINE bool isSlotChain(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMSlotChain.
Set< PRMSlotChain< GUM_SCALAR > *> slotChains__
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:368
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
Set< PRMParameter< GUM_SCALAR > *> parameters__
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:371
+ Here is the caller graph for this function:

◆ addArc()

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

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

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

Definition at line 483 of file PRMClass_tpl.h.

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

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

◆ addCastDescendants__() [1/2]

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

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

Definition at line 695 of file PRMClass_tpl.h.

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

◆ addCastDescendants__() [2/2]

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

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

Definition at line 943 of file PRMClass_tpl.h.

944  {
945  PRMAttribute< GUM_SCALAR >* parent = start;
946  PRMAttribute< GUM_SCALAR >* child = 0;
947 
948  while (parent->type().superType() != end->type()) {
949  child = parent->getCastDescendant();
950  child->setId(nextNodeId());
951  nodeIdMap__.insert(child->id(), child);
952  dag__.addNodeWithId(child->id());
953  // Only use child's safe name when adding to the name map!
954  nameMap__.insert(child->safeName(), child);
955  attributes__.insert(child);
956  addIOInterfaceFlags__(child);
957  // Do not use Class<GUM_SCALAR>::insertArc(), child's CPF is already
958  // initialized properly
959  dag__.addArc(parent->id(), child->id());
960  parent = child;
961  }
962 
963  parent->setAsCastDescendant(end);
964  dag__.addArc(parent->id(), end->id());
965  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
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:977
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:356
DAG dag__
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:342
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:346
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: DAG_inl.h:43
NodeId nextNodeId()
Returns the next value of an unique counter for PRM&#39;s node id.
Definition: utils_prm.cpp:65
Set< PRMAttribute< GUM_SCALAR > *> attributes__
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:359

◆ addExtension__()

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

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

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

Definition at line 1261 of file PRMClass_tpl.h.

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

1261  {
1262  extensions__.insert(c);
1263  }
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:398
+ Here is the caller graph for this function:

◆ addIOInterfaceFlags__()

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

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

Definition at line 977 of file PRMClass_tpl.h.

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

◆ aggregates()

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

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

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

Definition at line 1142 of file PRMClass_tpl.h.

1142  {
1143  return aggregates__;
1144  }
Set< PRMAggregate< GUM_SCALAR > *> aggregates__
The sequence of aggregate.
Definition: PRMClass.h:365

◆ attributes()

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

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

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

Definition at line 1074 of file PRMClass_tpl.h.

1074  {
1075  return attributes__;
1076  }
Set< PRMAttribute< GUM_SCALAR > *> attributes__
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:359

◆ belongsTo()

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

Returns true if elt belongs to this PRMClassElementContainer.

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

Definition at line 177 of file PRMClassElementContainer_tpl.h.

178  {
179  try {
180  return &elt == &(get(elt.safeName()));
181  } catch (NotFound&) { return false; }
182  }

◆ checkInterface__()

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

Check that a given element respects a specific interface.

Definition at line 542 of file PRMClass_tpl.h.

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

◆ checkInterfaces__()

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

Check that a given element respects all the class interfaces.

Definition at line 529 of file PRMClass_tpl.h.

530  {
531  try {
532  for (auto i: implements()) {
533  if (i->exists(elt->name())) { checkInterface__(elt, i); }
534  }
535  } catch (NotFound&) {
536  // No interface
537  }
538  }
void checkInterface__(PRMClassElement< GUM_SCALAR > *elt, PRMInterface< GUM_SCALAR > *i)
Check that a given element respects a specific interface.
Definition: PRMClass_tpl.h:542
const Set< PRMInterface< GUM_SCALAR > *> & implements() const
Returns the Set of PRMInterface<GUM_SCALAR> implemented by this Class<GUM_SCALAR>.

◆ checkOverloadLegality__()

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

Return true of overloaded can be overload by overloader.

Definition at line 1211 of file PRMClass_tpl.h.

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

◆ checkRefInterface__()

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

Check that a given element respects a specific interface.

Definition at line 596 of file PRMClass_tpl.h.

597  {
598  auto& i_elt = i->get(ref->name());
599  if (i_elt.elt_type() != ref->elt_type()) {
600  GUM_ERROR(OperationNotAllowed, "Class does not respect it's interface");
601  }
602  auto& i_ref = static_cast< PRMReferenceSlot< GUM_SCALAR >& >(i_elt);
603  if (!ref->slotType().isSubTypeOf(i_ref.slotType())) {
604  GUM_ERROR(OperationNotAllowed,
605  "ReferenceSlot type does not respect class interface");
606  }
607  // Node must be reserved by constructor
608  if (!dag__.exists(i_ref.id())) {
609  GUM_ERROR(FatalError,
610  "class " << this->name() << " does not respect interface "
611  << i->name() << " implementation");
612  }
613  // Removing unused node and changin to propoer node
614  if (ref->id() != i_ref.id()) { dag__.eraseNode(ref->id()); }
615  nodeIdMap__.erase(ref->id());
616  ref->setId(i_ref.id());
617  nodeIdMap__.insert(ref->id(), ref);
618  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
DAG dag__
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:342
bool exists(const NodeId id) const
alias for existsNode
NodeProperty< PRMClassElement< GUM_SCALAR > *> nodeIdMap__
Mapping between node&#39;s id and their name (being an attribute or a slot). Used for fast access to a me...
Definition: PRMClass.h:346
virtual void eraseNode(const NodeId id)
remove a node and its adjacent arcs from the graph
Definition: diGraph_inl.h:69
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ checkRefInterfaces__()

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

Check that a given element respects all the class interfaces.

Definition at line 584 of file PRMClass_tpl.h.

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

◆ completeInheritance()

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

Definition at line 292 of file PRMClass_tpl.h.

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

◆ containerDag()

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

Returns the gum::DAG of this PRMClassElementContainer.

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

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

Returns
the DAG of this PRMClassElementContainer.

Definition at line 186 of file PRMClassElementContainer_tpl.h.

Referenced by gum::prm::ClassDependencyGraph< GUM_SCALAR >::addArcs__(), gum::prm::PRMFactory< GUM_SCALAR >::addAttribute(), gum::prm::PRMClass< double >::inheritClass__(), gum::prm::ClassBayesNet< GUM_SCALAR >::init__(), gum::prm::SVED< GUM_SCALAR >::initLiftedNodes__(), gum::prm::SVE< GUM_SCALAR >::initLiftedNodes__(), operator<<(), and gum::prm::PRMClass< double >::PRMClass().

186  {
187  return dag_();
188  }
virtual const DAG & dag_() const =0
+ Here is the caller graph for this function:

◆ copyIOFlags_()

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

Copy the IO Flags of c in this PRMClassElementContainer.

Parameters
cA PRMClassElementContainer.

Definition at line 37 of file PRMClassElementContainer_tpl.h.

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

◆ dag_() [1/2]

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

returns a constant reference over this interface's dag.

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

Definition at line 1018 of file PRMClass_tpl.h.

1018  {
1019  return dag__;
1020  }
DAG dag__
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:342

◆ dag_() [2/2]

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

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

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

Definition at line 1023 of file PRMClass_tpl.h.

1023  {
1024  return dag__;
1025  }
DAG dag__
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:342

◆ enum2str()

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

Returns the string representation of a PRMObject.

Definition at line 83 of file PRMObject.h.

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<<().

83  {
84  switch (type) {
85  case prm_type::CLASS: return "PRMType::CLASS";
86 
87  case prm_type::CLASS_ELT: return "PRMType::CLASS_ELT";
88 
89  case prm_type::TYPE: return "PRMType::TYPE";
90 
91  case prm_type::SYSTEM: return "PRMType::SYSTEM";
92 
93  case prm_type::INSTANCE: return "PRMType::INSTANCE";
94 
95  case prm_type::PRM_INTERFACE: return "PRMType::PRM_INTERFACE";
96 
97  default: return "unknown";
98  }
99  }
+ Here is the caller graph for this function:

◆ exists() [1/2]

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

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

Definition at line 168 of file PRMClassElementContainer_tpl.h.

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::addNoisyOrCompound(), 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 >::continueAggregator(), gum::prm::PRMFactory< GUM_SCALAR >::continueAttribute(), gum::prm::PRMClassElementContainer< double >::exists(), and gum::prm::PRMFactory< GUM_SCALAR >::startAttribute().

169  {
170  try {
171  get(name);
172  return true;
173  } catch (NotFound&) { return false; }
174  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
+ Here is the caller graph for this function:

◆ exists() [2/2]

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

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

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

Definition at line 163 of file PRMClassElementContainer_tpl.h.

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

◆ extensions()

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

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

Definition at line 1256 of file PRMClass_tpl.h.

1256  {
1257  return extensions__;
1258  }
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:398

◆ findAllSubtypes_()

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

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

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

Definition at line 968 of file PRMClass_tpl.h.

Referenced by gum::prm::PRMClass< double >::findAllSubtypes_().

969  {
970  for (auto ext: extensions__) {
971  set.insert(ext);
972  ext->findAllSubtypes_(set);
973  }
974  }
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:398
+ Here is the caller graph for this function:

◆ get() [1/4]

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

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

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

Definition at line 1028 of file PRMClass_tpl.h.

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::addAttribute(), gum::prm::PRMFactory< GUM_SCALAR >::addNoisyOrCompound(), 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__(), and gum::prm::PRMFactory< GUM_SCALAR >::retrieveInputs__().

1028  {
1029  try {
1030  return *(nodeIdMap__[id]);
1031  } catch (NotFound&) {
1032  GUM_ERROR(NotFound, "no ClassElement<GUM_SCALAR> with the given NodeId");
1033  }
1034  }
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:346
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ get() [2/4]

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

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

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

Definition at line 1038 of file PRMClass_tpl.h.

1038  {
1039  try {
1040  return *(nodeIdMap__[id]);
1041  } catch (NotFound&) {
1042  GUM_ERROR(NotFound,
1043  "no ClassElement<GUM_SCALAR> with the given NodeId (" << id
1044  << ")");
1045  }
1046  }
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:346
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ get() [3/4]

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

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

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

Definition at line 1050 of file PRMClass_tpl.h.

1050  {
1051  try {
1052  return *(nameMap__[name]);
1053  } catch (NotFound&) {
1054  GUM_ERROR(NotFound,
1055  "no ClassElement<GUM_SCALAR> with the given name (" << name
1056  << ")");
1057  }
1058  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
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:356
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ get() [4/4]

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

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

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

Definition at line 1062 of file PRMClass_tpl.h.

1062  {
1063  try {
1064  return *(nameMap__[name]);
1065  } catch (NotFound&) {
1066  GUM_ERROR(NotFound,
1067  "no ClassElement<GUM_SCALAR> with the given name (" << name
1068  << ")");
1069  }
1070  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
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:356
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ getIOFlag_() [1/2]

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

Returns the IO flags of a PRMClassElement<GUM_SCALAR>.

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

Definition at line 131 of file PRMClassElementContainer_tpl.h.

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

◆ getIOFlag_() [2/2]

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

Returns the IO flags of a PRMClassElement<GUM_SCALAR>.

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

Definition at line 143 of file PRMClassElementContainer_tpl.h.

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

◆ implementInterfaces__()

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

Proceed with the implementation of interfaces.

Definition at line 102 of file PRMClass_tpl.h.

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

◆ implements()

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

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

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

Definition at line 1169 of file PRMClass_tpl.h.

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

1169  {
1170  if (implements__) {
1171  return *implements__;
1172  } else {
1173  GUM_ERROR(NotFound,
1174  "this Class does not implement any Interface<GUM_SCALAR>");
1175  }
1176  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
Set< PRMInterface< GUM_SCALAR > *> * implements__
The Set of implemented interface of this.
Definition: PRMClass.h:394
+ Here is the caller graph for this function:

◆ inheritAggregates()

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

Definition at line 226 of file PRMClass_tpl.h.

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

◆ inheritAttributes()

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

Definition at line 197 of file PRMClass_tpl.h.

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

◆ inheritClass__()

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

Proceed with the copy when this inherits c.

Definition at line 315 of file PRMClass_tpl.h.

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

◆ inheritParameters()

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

Definition at line 179 of file PRMClass_tpl.h.

179  {
180  if (superClass__) {
181  // Copying parameters
182  for (const auto c_param: superClass__->parameters__) {
183  auto param = new PRMParameter< GUM_SCALAR >(
184  c_param->name(), c_param->valueType(), c_param->value());
185 
186  parameters__.insert(param);
187 
188  param->setId(c_param->id());
189  dag__.addNodeWithId(param->id());
190  nodeIdMap__.insert(param->id(), param);
191  nameMap__.insert(param->name(), param);
192  }
193  }
194  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
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:356
DAG dag__
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:342
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:346
Set< PRMParameter< GUM_SCALAR > *> parameters__
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:371
PRMClass< GUM_SCALAR > * superClass__
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:391

◆ inheritReferenceSlots()

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

Definition at line 152 of file PRMClass_tpl.h.

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

◆ inheritSlotChains()

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

Definition at line 258 of file PRMClass_tpl.h.

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

◆ initializeInheritance()

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

Definition at line 133 of file PRMClass_tpl.h.

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

◆ isCastDescendant()

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

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

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

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

Definition at line 1266 of file PRMClass_tpl.h.

1267  {
1268  const PRMClassElement< GUM_SCALAR >& elt = get(safe_name);
1269 
1270  try {
1271  return elt.type().name() == get(elt.name()).type().name();
1272  } catch (OperationNotAllowed&) {
1273  GUM_ERROR(NotFound, "no attribute with the given name");
1274  }
1275  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ isClass()

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

Returns true if obj_ptr is of type Class.

Definition at line 102 of file PRMObject.h.

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

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

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

◆ isInnerNode()

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

Returns true if the node is an inner node.

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

By defaut, attributes and aggregates are inner nodes.

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

Definition at line 116 of file PRMClassElementContainer_tpl.h.

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

117  {
118  try {
119  return !(getIOFlag_(elt).first || getIOFlag_(elt).second);
120  } catch (NotFound&) { return true; }
121  }
virtual std::pair< bool, bool > & getIOFlag_(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
+ Here is the caller graph for this function:

◆ isInputNode()

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

Returns true if the node is an input node.

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

By defaut, attributes and aggregates are inner nodes.

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

Definition at line 72 of file PRMClassElementContainer_tpl.h.

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

◆ isInstance()

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 112 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().

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

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 107 of file PRMObject.h.

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

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

◆ isOutputNode()

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

Returns true if elt is an output node.

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

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

Definition at line 1278 of file PRMClass_tpl.h.

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

1279  {
1280  try {
1281  if (!this->getIOFlag_(elt).second) {
1282  if (implements__) {
1283  for (auto i: *implements__) {
1284  if (i->isOutputNode(elt)) { return true; }
1285  }
1286  }
1287 
1288  if (superClass__ && (superClass__->isOutputNode(elt))) { return true; }
1289 
1290  } else {
1291  return true;
1292  }
1293  } catch (NotFound&) {}
1294  return false;
1295  }
virtual std::pair< bool, bool > & getIOFlag_(const PRMClassElement< GUM_SCALAR > &elt)
Returns the IO flags of a PRMClassElement<GUM_SCALAR>.
Set< PRMInterface< GUM_SCALAR > *> * implements__
The Set of implemented interface of this.
Definition: PRMClass.h:394
PRMClass< GUM_SCALAR > * superClass__
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:391
+ Here is the caller graph for this function:

◆ isSubTypeOf()

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

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

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

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

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

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

Definition at line 445 of file PRMClass_tpl.h.

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

◆ isSuperTypeOf()

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

Test if this PRMClassElementContainer is a super type of cec.

This returns cec.isSubTypeOf(*this).

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

Definition at line 124 of file PRMClassElementContainer_tpl.h.

125  {
126  return cec.isSubTypeOf(*this);
127  }

◆ LEFT_CAST()

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

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

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

Definition at line 79 of file PRMObject.h.

Referenced by gum::prm::decomposePath(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute().

79 { return "("; }
+ Here is the caller graph for this function:

◆ name() [1/2]

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

Returns the name of this object.

Definition at line 35 of file PRMObject_inl.h.

References gum::prm::PRMObject::name__.

Referenced by gum::prm::__print_attribute__(), gum::prm::__print_instance__(), gum::prm::PRMSystem< double >::add(), gum::prm::PRMInterface< double >::add(), gum::prm::PRMClass< double >::add(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::SVE< GUM_SCALAR >::addDelayedVariable__(), gum::prm::PRMClass< double >::addIOInterfaceFlags__(), gum::prm::PRMFormAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMFactory< GUM_SCALAR >::addParent__(), gum::prm::PRMInstance< GUM_SCALAR >::addReferingInstance__(), gum::prm::PRMClass< double >::checkInterface__(), gum::prm::PRMFactory< GUM_SCALAR >::checkInterfaceImplementation__(), gum::prm::PRMClass< double >::checkInterfaces__(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkRawCPT__(), gum::prm::PRMClass< double >::checkRefInterface__(), gum::prm::PRMClass< double >::checkRefInterfaces__(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkRuleCPTSumsTo1__(), gum::prm::PRMFormAttribute< GUM_SCALAR >::copy(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), gum::prm::PRMInstance< GUM_SCALAR >::copyAggregates__(), gum::prm::PRMInstance< GUM_SCALAR >::copyAttribute__(), gum::prm::PRMSlotChain< double >::copyLastElt__(), gum::prm::o3prmr::O3prmrInterpreter::findAttributeName(), gum::prm::o3prmr::O3prmrInterpreter::findInstanceName(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMSystem< double >::groundAttr__(), gum::prm::PRMSystem< double >::groundPotential__(), gum::prm::PRMSystem< double >::groundRef__(), gum::prm::PRMClass< double >::inheritAggregates(), gum::prm::PRMClass< double >::inheritClass__(), gum::prm::PRMClass< double >::isCastDescendant(), gum::prm::PRMObject::isInstance(), gum::prm::PRMObject::name(), gum::prm::PRMType::name(), gum::prm::PRMFormAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMType::operator!=(), gum::prm::PRMObject::operator!=(), operator<<(), gum::prm::PRMType::operator==(), gum::prm::PRMObject::operator==(), gum::prm::PRMClass< double >::overload(), gum::prm::PRMInterface< double >::overload(), gum::prm::PRMInterface< double >::overloadAttribute__(), gum::prm::PRMClass< double >::overloadAttribute__(), gum::prm::PRMClass< double >::overloadParameter__(), gum::prm::PRMClass< double >::overloadReference__(), gum::prm::PRMInterface< double >::overloadReferenceSlot__(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMReferenceSlot< double >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), gum::prm::PRMFactory< GUM_SCALAR >::startClass(), gum::prm::PRMFactory< GUM_SCALAR >::startInterface(), gum::prm::PRMFactory< GUM_SCALAR >::startSystem(), gum::prm::PRMAggregate< double >::str2enum(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::str__(), and gum::prm::StructuredInference< GUM_SCALAR >::str__().

35 { return name__; }
std::string name__
Definition: PRMObject.h:200

◆ name() [2/2]

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

Change the name of the PRM Object.

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

Definition at line 39 of file PRMObject_inl.h.

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

39 { name__ = name; }
std::string name__
Definition: PRMObject.h:200
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
+ Here is the call graph for this function:

◆ obj_type()

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

Implementation of pure virtual method of PRMObject.

Implements gum::prm::PRMObject.

Definition at line 1013 of file PRMClass_tpl.h.

◆ operator!=()

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

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

Definition at line 49 of file PRMObject_inl.h.

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

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

49  {
50  return name__ != obj.name();
51  }
std::string name__
Definition: PRMObject.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [1/2]

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

Copy operator. Don't use it.

◆ operator=() [2/2]

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

Move operator. Don't use it.

◆ operator==()

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

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

Definition at line 43 of file PRMObject_inl.h.

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

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

43  {
44  return name__ == obj.name();
45  }
std::string name__
Definition: PRMObject.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator[]() [1/4]

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

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

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

Definition at line 1180 of file PRMClass_tpl.h.

1180  {
1181  return get(id);
1182  }

◆ operator[]() [2/4]

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

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

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

Definition at line 1186 of file PRMClass_tpl.h.

1186  {
1187  return get(id);
1188  }

◆ operator[]() [3/4]

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

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

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

Definition at line 1192 of file PRMClass_tpl.h.

1192  {
1193  return get(name);
1194  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35

◆ operator[]() [4/4]

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

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

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

Definition at line 1198 of file PRMClass_tpl.h.

1198  {
1199  return get(name);
1200  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35

◆ overload()

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

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

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

Definition at line 733 of file PRMClass_tpl.h.

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

734  {
735  try {
736  if (!super().exists(overloader->name())) {
737  GUM_ERROR(OperationNotAllowed,
738  "found no ClassElement<GUM_SCALAR> to overload");
739  }
740  } catch (NotFound&) {
741  GUM_ERROR(OperationNotAllowed,
742  "overload is possible only with subclasses");
743  }
744 
745  PRMClassElement< GUM_SCALAR >* overloaded = nameMap__[overloader->name()];
746  if (overloaded == overloader) {
747  GUM_ERROR(DuplicateElement,
748  "dupplicate ClassElement " << overloader->name());
749  }
750  // Checking overload legality
751  if (!checkOverloadLegality__(overloaded, overloader)) {
752  GUM_ERROR(OperationNotAllowed, "illegal overload");
753  }
754 
755  switch (overloader->elt_type()) {
757  auto overloader_attr =
758  static_cast< PRMAttribute< GUM_SCALAR >* >(overloader);
759  auto overloaded_attr =
760  static_cast< PRMAttribute< GUM_SCALAR >* >(overloaded);
761  overloadAttribute__(overloader_attr, overloaded_attr);
762  addIOInterfaceFlags__(overloader);
763  break;
764  }
765 
768  static_cast< PRMAggregate< GUM_SCALAR >* >(overloader), overloaded);
769  addIOInterfaceFlags__(overloader);
770  break;
771  }
772 
774  // checkOverloadLegality__ guaranties that overloaded is a
775  // PRMReferenceSlot<GUM_SCALAR>
776  auto overloader_ref =
777  static_cast< PRMReferenceSlot< GUM_SCALAR >* >(overloader);
778  auto overloaded_ref =
779  static_cast< PRMReferenceSlot< GUM_SCALAR >* >(overloaded);
780  overloadReference__(overloader_ref, overloaded_ref);
781  break;
782  }
783 
785  GUM_ERROR(OperationNotAllowed,
786  "SlotChain<GUM_SCALAR> can not be overloaded");
787  break;
788  }
789 
791  auto overloaded_param =
792  static_cast< PRMParameter< GUM_SCALAR >* >(overloaded);
793  auto overloader_param =
794  static_cast< PRMParameter< GUM_SCALAR >* >(overloader);
795  overloadParameter__(overloader_param, overloaded_param);
796  break;
797  }
798  default: {
799  GUM_ERROR(OperationNotAllowed, "unknown ClassElement<GUM_SCALAR> type");
800  }
801  }
802 
803  return overloader->id();
804  }
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:977
void overloadParameter__(PRMParameter< GUM_SCALAR > *overloader, PRMParameter< GUM_SCALAR > *overloaded)
Overloads a parameter.
Definition: PRMClass_tpl.h:930
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:356
bool checkOverloadLegality__(const PRMClassElement< GUM_SCALAR > *overloaded, const PRMClassElement< GUM_SCALAR > *overloader)
Return true of overloaded can be overload by overloader.
virtual bool exists(const std::string &name) const
Returns true if a member with the given name exists in this PRMClassElementContainer or in the PRMCla...
void overloadReference__(PRMReferenceSlot< GUM_SCALAR > *overloader, PRMReferenceSlot< GUM_SCALAR > *overloaded)
Overloads a reference slot.
Definition: PRMClass_tpl.h:834
const PRMClass< GUM_SCALAR > & super() const
Returns the super Class<GUM_SCALAR> of this Class<GUM_SCALAR>.
void overloadAggregate__(PRMAggregate< GUM_SCALAR > *overloader, PRMClassElement< GUM_SCALAR > *overloaded)
Overloads an aggregate.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
void overloadAttribute__(PRMAttribute< GUM_SCALAR > *overloader, PRMAttribute< GUM_SCALAR > *overloaded)
Overloads an attribute.
Definition: PRMClass_tpl.h:807
+ Here is the caller graph for this function:

◆ overloadAggregate__()

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

Overloads an aggregate.

Definition at line 1203 of file PRMClass_tpl.h.

1205  {
1206  nameMap__.insert(overloader->safeName(), overloader);
1207  aggregates__.insert(overloader);
1208  }
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:356
Set< PRMAggregate< GUM_SCALAR > *> aggregates__
The sequence of aggregate.
Definition: PRMClass.h:365

◆ overloadAttribute__()

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

Overloads an attribute.

Definition at line 807 of file PRMClass_tpl.h.

809  {
810  dag__.eraseParents(overloaded->id());
811 
812  // Checking if we have to add cast descendant
813  if (overloader->type() != overloaded->type()) {
814  overloader->setId(nextNodeId());
815  dag__.addNodeWithId(overloader->id());
816  nodeIdMap__.insert(overloader->id(), overloader);
817  nameMap__[overloader->name()] = overloader;
818  nameMap__.insert(overloader->safeName(), overloader);
819  attributes__.insert(overloader);
820  addCastDescendants__(overloader, overloaded);
821  } else {
822  overloader->setId(overloaded->id());
823  nodeIdMap__[overloader->id()] = overloader;
824  nameMap__[overloader->name()] = overloader;
825  nameMap__[overloader->safeName()] = overloader;
826  attributes__.erase(overloaded);
827  attributes__.insert(overloader);
828  overloader->overload(overloaded);
829  delete overloaded;
830  }
831  }
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
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:356
DAG dag__
The dag representing dependencies between formal attributes and slots.
Definition: PRMClass.h:342
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:346
NodeId nextNodeId()
Returns the next value of an unique counter for PRM&#39;s node id.
Definition: utils_prm.cpp:65
void addCastDescendants__(PRMClassElement< GUM_SCALAR > *attr)
Recursively adds cast descendant of attr in this Class<GUM_SCALAR>.
Definition: PRMClass_tpl.h:695
Set< PRMAttribute< GUM_SCALAR > *> attributes__
The sequence of PRMAttribute<GUM_SCALAR>s.
Definition: PRMClass.h:359
void eraseParents(const NodeId id)
erase all the parents of a given node

◆ overloadParameter__()

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

Overloads a parameter.

Definition at line 930 of file PRMClass_tpl.h.

932  {
933  overloader->setId(overloaded->id());
934  nodeIdMap__[overloader->id()] = overloader;
935  nameMap__[overloader->name()] = overloader;
936  nameMap__[overloader->safeName()] = overloader;
937  parameters__.erase(overloaded);
938  parameters__.insert(overloader);
939  delete overloaded;
940  }
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:356
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:346
Set< PRMParameter< GUM_SCALAR > *> parameters__
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:371

◆ overloadReference__()

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

Overloads a reference slot.

Definition at line 834 of file PRMClass_tpl.h.

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

◆ parameters()

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

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

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

Definition at line 1080 of file PRMClass_tpl.h.

1080  {
1081  return parameters__;
1082  }
Set< PRMParameter< GUM_SCALAR > *> parameters__
The Set of parameters in this Class<GUM_SCALAR>.
Definition: PRMClass.h:371

◆ referenceSlots()

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

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

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

Definition at line 1148 of file PRMClass_tpl.h.

1148  {
1149  return referenceSlots__;
1150  }
Set< PRMReferenceSlot< GUM_SCALAR > *> referenceSlots__
The sequence of PRMReferenceSlot<GUM_SCALAR>.
Definition: PRMClass.h:362

◆ RIGHT_CAST()

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

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

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

Definition at line 80 of file PRMObject.h.

Referenced by gum::prm::decomposePath(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute().

80 { return ")"; }
+ Here is the caller graph for this function:

◆ scope()

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

Returns all the parameters in the scope of this class.

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

Definition at line 1101 of file PRMClass_tpl.h.

Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkRawCPT__(), and gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkRuleCPT__().

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

◆ setInputNode()

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

Set the input flag value of id at b.

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

By defaut, attributes and aggregates are inner nodes.

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

Definition at line 80 of file PRMClassElementContainer_tpl.h.

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

◆ setIOFlag_()

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

Defines the IO flags of a PRMClassElement<GUM_SCALAR>.

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

Definition at line 154 of file PRMClassElementContainer_tpl.h.

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

◆ setOutputNode()

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

Set the output flag value of id at b.

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

By defaut, attributes and aggregates are inner nodes.

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

Definition at line 97 of file PRMClassElementContainer_tpl.h.

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

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

◆ slotChains()

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

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

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

Definition at line 1154 of file PRMClass_tpl.h.

1154  {
1155  return slotChains__;
1156  }
Set< PRMSlotChain< GUM_SCALAR > *> slotChains__
The set of gum::PRMSlotChain<GUM_SCALAR>s.
Definition: PRMClass.h:368

◆ super()

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

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

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

Definition at line 1159 of file PRMClass_tpl.h.

1159  {
1160  if (superClass__) {
1161  return *superClass__;
1162  } else {
1163  GUM_ERROR(NotFound, "this Class is not a subclass");
1164  }
1165  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
PRMClass< GUM_SCALAR > * superClass__
The alternate PRMClassElementContainer<GUM_SCALAR> searched for elements defined in this...
Definition: PRMClass.h:391

◆ updateDescendants_()

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

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

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

Definition at line 1002 of file PRMClass_tpl.h.

1003  {
1004  // for ( const auto ext : extensions__ ) {
1005  // // We test to prevent unnecessary recursive call from iter
1006  // if ( !ext->isOutputNode( elt ) ) {
1007  // ext->setOutputNode( elt, true );
1008  // }
1009  //}
1010  }

Friends And Related Function Documentation

◆ PRMInterface< GUM_SCALAR >

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

Definition at line 67 of file PRMClass.h.

Member Data Documentation

◆ aggregates__

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

The sequence of aggregate.

Definition at line 365 of file PRMClass.h.

Referenced by gum::prm::PRMClass< double >::inheritClass__().

◆ attributes__

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

The sequence of PRMAttribute<GUM_SCALAR>s.

Definition at line 359 of file PRMClass.h.

Referenced by gum::prm::PRMClass< double >::inheritClass__().

◆ bijection__

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

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

Definition at line 403 of file PRMClass.h.

◆ dag__

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

The dag representing dependencies between formal attributes and slots.

Definition at line 342 of file PRMClass.h.

◆ dummy_hashfunc__

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

a dummy member used to fix a compilation issue in clang4

Definition at line 406 of file PRMClass.h.

◆ extensions__

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

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

Definition at line 398 of file PRMClass.h.

◆ implements__

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

The Set of implemented interface of this.

Definition at line 394 of file PRMClass.h.

Referenced by gum::prm::PRMClass< double >::inheritClass__().

◆ nameMap__

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

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

Definition at line 356 of file PRMClass.h.

Referenced by gum::prm::PRMClass< double >::inheritClass__().

◆ nodeIdMap__

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

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

Definition at line 346 of file PRMClass.h.

◆ parameters__

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

The Set of parameters in this Class<GUM_SCALAR>.

Definition at line 371 of file PRMClass.h.

Referenced by gum::prm::PRMClass< double >::inheritClass__().

◆ referenceSlots__

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

The sequence of PRMReferenceSlot<GUM_SCALAR>.

Definition at line 362 of file PRMClass.h.

Referenced by gum::prm::PRMClass< double >::inheritClass__().

◆ slotChains__

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

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

Definition at line 368 of file PRMClass.h.

Referenced by gum::prm::PRMClass< double >::inheritClass__().

◆ superClass__

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

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

Definition at line 391 of file PRMClass.h.

Referenced by gum::prm::PRMClass< double >::isSubTypeOf().


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