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

<agrum/PRM/classElementContainer.h> More...

#include <PRMClassElementContainer.h>

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

Public Member Functions

Protected constructors & destructor.
 PRMClassElementContainer (const std::string &name)
 Default constructor. More...
 
virtual ~PRMClassElementContainer ()
 Destructor. More...
 
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 PRMClassElement< GUM_SCALAR > & get (const std::string &name)=0
 Getter on a member of this PRMClassElementContainer. More...
 
virtual const PRMClassElement< GUM_SCALAR > & get (const std::string &name) const =0
 Constant getter on a member of this PRMClassElementContainer. More...
 
virtual NodeId add (PRMClassElement< GUM_SCALAR > *elt)=0
 Add a PRMClassElement<GUM_SCALAR> to this PRMClassElementContainer. More...
 
virtual NodeId overload (PRMClassElement< GUM_SCALAR > *elt)=0
 Add a PRMClassElement<GUM_SCALAR> which overload an inherited PRMClassElement<GUM_SCALAR>. More...
 
virtual void addArc (const std::string &tail, const std::string &head)=0
 Add an arc between two PRMClassElement<GUM_SCALAR>. 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 bool isOutputNode (const PRMClassElement< GUM_SCALAR > &elt) const =0
 Returns true if the node is an output node. 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 const DAGcontainerDag () const
 Returns the gum::DAG of this PRMClassElementContainer. More...
 
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 PRMClassElement< GUM_SCALAR > & get (NodeId id)=0
 Getter on a member of this PRMClassElementContainer. More...
 
virtual const PRMClassElement< GUM_SCALAR > & get (NodeId id) const =0
 Constant getter on a member of this PRMClassElementContainer. More...
 
Getters & setters operators
virtual PRMClassElement< GUM_SCALAR > & operator[] (NodeId id)=0
 Getter on a member of this PRMClassElementContainer. More...
 
virtual const PRMClassElement< GUM_SCALAR > & operator[] (NodeId id) const =0
 Constant getter on a member of this PRMClassElementContainer. More...
 
virtual PRMClassElement< GUM_SCALAR > & operator[] (const std::string &name)=0
 Getter on a member of this PRMClassElementContainer. More...
 
virtual const PRMClassElement< GUM_SCALAR > & operator[] (const std::string &name) const =0
 Constant getter on a member of this PRMClassElementContainer. More...
 
Inheritance getters and setters
virtual bool isSubTypeOf (const PRMClassElementContainer< GUM_SCALAR > &cec) const =0
 Test if this PRMClassElementContainer is a subtype of cec. More...
 
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...
 
virtual prm_type obj_type () const =0
 Returns the type of this 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

PRMClassElementContainer< GUM_SCALAR > & operator= (const PRMClassElementContainer< GUM_SCALAR > &source)
 Copy operator. Don't use it. More...
 
 PRMClassElementContainer (const PRMClassElementContainer< GUM_SCALAR > &source)
 Copy constructor. Don't use it. More...
 
virtual const DAGdag_ () const =0
 
virtual DAGdag_ ()=0
 Returns a non constant reference over this PRMClassElementContainer's DAG. More...
 
virtual void findAllSubtypes_ (Set< PRMClassElementContainer< GUM_SCALAR > * > &set)=0
 Fills set with all the subtypes of this PRMInterface, this includes extensions and implementations. 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...
 
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 descendant of this PRMClassElementContainer. Note that after its declaration, input flags can not be changed and output flags can only become true. More...
 

Friends

class PRMClassElementContainterIterator
 
class PRMClassElementContainterConstIterator
 

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::PRMClassElementContainer< GUM_SCALAR >

<agrum/PRM/classElementContainer.h>

Abstract class for classes containing gum::PRMClassElement<GUM_SCALAR>.

To print a PRMClassElementContainer you can use the following operator: gum::operator<<(std::ostream&, const PRMClassElementContainer&) which print the PRMClassElementContainer in the graphviz-dot format.

Definition at line 66 of file PRMClassElementContainer.h.

Member Enumeration Documentation

◆ prm_type

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

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

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

Enumerator
ALL 
CLASS 
PRM_INTERFACE 
CLASS_ELT 
TYPE 
SYSTEM 
INSTANCE 

Definition at line 68 of file PRMObject.h.

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

Constructor & Destructor Documentation

◆ PRMClassElementContainer() [1/2]

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

Default constructor.

Definition at line 44 of file PRMClassElementContainer_tpl.h.

44  :
45  PRMObject(name) {
46  GUM_CONSTRUCTOR(PRMClassElementContainer);
47  }
PRMClassElementContainer(const std::string &name)
Default constructor.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:42

◆ ~PRMClassElementContainer()

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

Destructor.

Definition at line 50 of file PRMClassElementContainer_tpl.h.

50  {
51  GUM_DESTRUCTOR(PRMClassElementContainer);
52  }
PRMClassElementContainer(const std::string &name)
Default constructor.

◆ PRMClassElementContainer() [2/2]

template<typename GUM_SCALAR>
INLINE gum::prm::PRMClassElementContainer< GUM_SCALAR >::PRMClassElementContainer ( const PRMClassElementContainer< GUM_SCALAR > &  source)
protected

Copy constructor. Don't use it.

Definition at line 62 of file PRMClassElementContainer_tpl.h.

63  :
64  PRMObject(source) {
65  GUM_CONS_CPY(PRMClassElementContainer);
66  GUM_ERROR(FatalError, "illegal call to ClassElementContainer copy constructor")
67  }
PRMClassElementContainer(const std::string &name)
Default constructor.
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:42
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

Member Function Documentation

◆ add()

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

Add a PRMClassElement<GUM_SCALAR> to this PRMClassElementContainer.

The pointer is "given" to this class, which will delete it when ~Class() is called.

The NodeId of elt is defined when it is added to this, discarding any previous value.

If you want to overload an inherited PRMClassElement<GUM_SCALAR> call Class::overload().

When adding an PRMAttribute or an PRMAggregate its type safe name is automatically added, the syntax is <type>name. So you can either use its type safe name or its real name. See the ref prm_typ_inh "type inheritance section" for further details.

Parameters
eltThe PRMClassElement<GUM_SCALAR> added to this Class.
Returns
Returns the NodeId assigned to elt.
Exceptions
DuplicateElementRaised if elt's name is already used in this class.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ addArc()

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

◆ belongsTo()

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

Returns true if elt belongs to this PRMClassElementContainer.

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

Definition at line 170 of file PRMClassElementContainer_tpl.h.

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

◆ containerDag()

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

Returns the gum::DAG of this PRMClassElementContainer.

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

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

Returns
the DAG of this PRMClassElementContainer.

Definition at line 178 of file PRMClassElementContainer_tpl.h.

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

◆ copyIOFlags_()

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

Copy the IO Flags of c in this PRMClassElementContainer.

Parameters
cA PRMClassElementContainer.

Definition at line 36 of file PRMClassElementContainer_tpl.h.

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

◆ dag_() [1/2]

template<typename GUM_SCALAR>
virtual const DAG& gum::prm::PRMClassElementContainer< GUM_SCALAR >::dag_ ( ) const
protectedpure virtual

◆ dag_() [2/2]

template<typename GUM_SCALAR>
virtual DAG& gum::prm::PRMClassElementContainer< GUM_SCALAR >::dag_ ( )
protectedpure virtual

◆ enum2str()

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

Returns the string representation of a PRMObject.

Definition at line 83 of file PRMObject.h.

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

◆ exists() [1/2]

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

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

Definition at line 162 of file PRMClassElementContainer_tpl.h.

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

◆ exists() [2/2]

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

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

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

Definition at line 157 of file PRMClassElementContainer_tpl.h.

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

◆ findAllSubtypes_()

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

Fills set with all the subtypes of this PRMInterface, this includes extensions and implementations.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ get() [1/4]

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

Getter on a member of this PRMClassElementContainer.

Parameters
nameThe member's name.
Returns
Returns a constant reference on the member.
Exceptions
NotFoundRaised if no attribute matches name.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ get() [2/4]

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

Constant getter on a member of this PRMClassElementContainer.

Parameters
nameThe member's name.
Returns
Returns a constant reference on the member.
Exceptions
NotFoundRaised if no attribute matches name.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ get() [3/4]

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

Getter on a member of this PRMClassElementContainer.

Parameters
idThe member's id.
Returns
Returns a constant reference on the member.
Exceptions
NotFoundRaised if no attribute matches name.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ get() [4/4]

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

Constant getter on a member of this PRMClassElementContainer.

Parameters
idThe member's id.
Returns
Returns a constant reference on the member.
Exceptions
NotFoundRaised if no attribute matches name.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ getIOFlag_() [1/2]

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

Returns the IO flags of a PRMClassElement<GUM_SCALAR>.

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

Definition at line 128 of file PRMClassElementContainer_tpl.h.

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

◆ getIOFlag_() [2/2]

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

Returns the IO flags of a PRMClassElement<GUM_SCALAR>.

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

Definition at line 138 of file PRMClassElementContainer_tpl.h.

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

◆ isClass()

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

Returns true if obj_ptr is of type Class.

Definition at line 109 of file PRMObject.h.

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

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

◆ isInnerNode()

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

Returns true if the node is an inner node.

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

By defaut, attributes and aggregates are inner nodes.

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

Definition at line 114 of file PRMClassElementContainer_tpl.h.

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

◆ isInputNode()

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

Returns true if the node is an input node.

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

By defaut, attributes and aggregates are inner nodes.

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

Definition at line 70 of file PRMClassElementContainer_tpl.h.

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

◆ isInstance()

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 117 of file PRMObject.h.

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

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

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 112 of file PRMObject.h.

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

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

◆ isOutputNode()

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

Returns true if the node is an output 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.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ isSubTypeOf()

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

Test if this PRMClassElementContainer is a subtype of cec.

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

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ isSuperTypeOf()

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

Test if this PRMClassElementContainer is a super type of cec.

This returns cec.isSubTypeOf(*this).

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

Definition at line 122 of file PRMClassElementContainer_tpl.h.

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

◆ LEFT_CAST()

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

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

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

Definition at line 79 of file PRMObject.h.

79 { return "("; }

◆ name() [1/2]

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

Returns the name of this object.

Definition at line 34 of file PRMObject_inl.h.

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

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

◆ name() [2/2]

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

Change the name of the PRM Object.

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

Definition at line 38 of file PRMObject_inl.h.

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

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

◆ obj_type()

◆ operator!=()

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

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

Definition at line 46 of file PRMObject_inl.h.

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

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

◆ operator=()

template<typename GUM_SCALAR>
INLINE PRMClassElementContainer< GUM_SCALAR > & gum::prm::PRMClassElementContainer< GUM_SCALAR >::operator= ( const PRMClassElementContainer< GUM_SCALAR > &  source)
protected

Copy operator. Don't use it.

Definition at line 56 of file PRMClassElementContainer_tpl.h.

57  {
58  GUM_ERROR(FatalError, "illegal call to ClassElementContainer copy operator")
59  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ operator==()

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

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

Definition at line 42 of file PRMObject_inl.h.

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

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

◆ operator[]() [1/4]

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

Getter on a member of this PRMClassElementContainer.

Parameters
idThe member's id.
Returns
Returns a constant reference on the member.
Exceptions
NotFoundRaised if no attribute matches name.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ operator[]() [2/4]

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

Constant getter on a member of this PRMClassElementContainer.

Parameters
idThe member's id.
Returns
Returns a constant reference on the member.
Exceptions
NotFoundRaised if no attribute matches name.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ operator[]() [3/4]

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

Getter on a member of this PRMClassElementContainer.

Parameters
nameThe member's name.
Returns
Returns a constant reference on the member.
Exceptions
NotFoundRaised if no attribute matches name.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ operator[]() [4/4]

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

Constant getter on a member of this PRMClassElementContainer.

Parameters
nameThe member's name.
Returns
Returns a constant reference on the member.
Exceptions
NotFoundRaised if no attribute matches name.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

◆ overload()

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

Add a PRMClassElement<GUM_SCALAR> which overload an inherited PRMClassElement<GUM_SCALAR>.

The pointer is "given" to this class, which will delete it when ~PRMClassElementContainer() is called.

The NodeId of elt is defined when it is added to this, discarding any previous value. There is no guaranty that elt will have the same NodeId than the PRMClassElement<GUM_SCALAR> it overloaded.

You can only overload inherited PRMClassElement<GUM_SCALAR> and only if elt is a subtype of the inherited PRMClassElement<GUM_SCALAR>. Thus you can only overload PRMReferenceSlot and PRMAttribute. In the case of PRMAttribute you can overload an inherited PRMAttribute even if they are of the same type: this is useful when you want to redefine the dependencies of an PRMAttribute or its CPF. You can also overload an PRMAttribute with an PRMAggregate, as long as their respective PRMType allow it.

Parameters
eltThe PRMClassElement<GUM_SCALAR> overloading an inherited PRMClassElement<GUM_SCALAR> in this PRMClassElementContainer.
Returns
the NodeId assigned to elt.
Exceptions
OperationNotAllowedRaised if overloading is illegal.

Implemented in gum::prm::PRMInterface< GUM_SCALAR >, gum::prm::PRMInterface< double >, gum::prm::PRMClass< GUM_SCALAR >, and gum::prm::PRMClass< double >.

◆ RIGHT_CAST()

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

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

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

Definition at line 80 of file PRMObject.h.

80 { return ")"; }

◆ setInputNode()

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

Set the input flag value of id at b.

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

By defaut, attributes and aggregates are inner nodes.

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

Definition at line 78 of file PRMClassElementContainer_tpl.h.

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

◆ setIOFlag_()

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

Defines the IO flags of a PRMClassElement<GUM_SCALAR>.

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

Definition at line 149 of file PRMClassElementContainer_tpl.h.

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

◆ setOutputNode()

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

Set the output flag value of id at b.

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

By defaut, attributes and aggregates are inner nodes.

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

Definition at line 94 of file PRMClassElementContainer_tpl.h.

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

◆ updateDescendants_()

template<typename GUM_SCALAR>
virtual void gum::prm::PRMClassElementContainer< GUM_SCALAR >::updateDescendants_ ( const PRMClassElement< GUM_SCALAR > &  elt)
protectedpure virtual

When a PRMClassElement<GUM_SCALAR> becomes an Output node we must update any the IO flags of every descendant of this PRMClassElementContainer. Note that after its declaration, input flags can not be changed and output flags can only become true.

Parameters
eltA PRMClassElement<GUM_SCALAR>.

Implemented in gum::prm::PRMClass< GUM_SCALAR >, gum::prm::PRMClass< double >, gum::prm::PRMInterface< GUM_SCALAR >, and gum::prm::PRMInterface< double >.

Friends And Related Function Documentation

◆ PRMClassElementContainterConstIterator

template<typename GUM_SCALAR>
friend class PRMClassElementContainterConstIterator
friend

Definition at line 68 of file PRMClassElementContainer.h.

◆ PRMClassElementContainterIterator

template<typename GUM_SCALAR>
friend class PRMClassElementContainterIterator
friend

Definition at line 67 of file PRMClassElementContainer.h.

Member Data Documentation

◆ _IOFlags_

template<typename GUM_SCALAR>
HashTable< std::string, std::pair< bool, bool > > gum::prm::PRMClassElementContainer< GUM_SCALAR >::_IOFlags_
private

input / output flags, useful when inheriting or copying.

Definition at line 438 of file PRMClassElementContainer.h.


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