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

A PRMSlotChain represents a sequence of gum::prm::PRMClassElement<GUM_SCALAR> where the n-1 first gum::prm::PRMClassElement<GUM_SCALAR> are gum::prm::PRMReferenceSlot and the last gum::prm::PRMClassElement<GUM_SCALAR> an gum::prm::PRMAttribute or an gum::prm::PRMAggregate. More...

#include <PRMObject.h>

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

Public Member Functions

Constructors & destructor
 PRMSlotChain (const std::string &name, const Sequence< PRMClassElement< GUM_SCALAR > * > &chain)
 Default constructor. More...
 
 PRMSlotChain (Sequence< PRMClassElement< GUM_SCALAR > * > *chain, const std::string &name)
 Tweak constructor. More...
 
 PRMSlotChain (const PRMSlotChain< GUM_SCALAR > &source)
 Copy constructor. More...
 
virtual ~PRMSlotChain ()
 Destructor. More...
 
Getters & setters
virtual PRMClassElement< GUM_SCALAR >::ClassElementType elt_type () const
 See gum::PRMClassElement<GUM_SCALAR>::elt_type(). More...
 
virtual PRMTypetype ()
 This is similar to the following call: this->lastElt().type() More...
 
virtual const PRMTypetype () const
 This is similar to the following call: this->lastElt().type() More...
 
virtual const Potential< GUM_SCALAR > & cpf () const
 This is similar to the following call: this->lastElt().cpf() More...
 
bool isMultiple () const
 Return true if this slot chain contains at least one multiple reference slot. More...
 
PRMClassElementContainer< GUM_SCALAR > & end ()
 Returns the PRMClassElement<GUM_SCALAR>Container over which this slot chain ends. More...
 
const PRMClassElementContainer< GUM_SCALAR > & end () const
 Returns the PRMClassElement<GUM_SCALAR>Container over which this slot chain ends. More...
 
PRMClassElement< GUM_SCALAR > & lastElt ()
 Returns the last element of the slot chain, typically this is an gum::PRMAttribute or a gum::PRMAggregate. More...
 
const PRMClassElement< GUM_SCALAR > & lastElt () const
 Returns the last element of the slot chain, typically this is an gum::PRMAttribute or a gum::PRMAggregate. More...
 
Sequence< PRMClassElement< GUM_SCALAR > *> & chain ()
 Return the sequence representing the chain of elements in this PRMSlotChain. More...
 
const Sequence< PRMClassElement< GUM_SCALAR > *> & chain () const
 Return the sequence representing the chain of elements in this PRMSlotChain. More...
 
virtual void addParent (const PRMClassElement< GUM_SCALAR > &elt)
 See gum::PRMClassElement<GUM_SCALAR>::addParent_(). More...
 
virtual void addChild (const PRMClassElement< GUM_SCALAR > &elt)
 See gum::PRMClassElement<GUM_SCALAR>::addChild_(). More...
 
virtual PRMAttribute< GUM_SCALAR > * getCastDescendant () const
 Raise a gum::OperationNotAllowed exception See gum::PRMClassElement<GUM_SCALAR>::getCastDescendant() More...
 
Getters & setters
NodeId id () const
 Returns the NodeId of this element in it's class DAG. More...
 
virtual void setId (NodeId id)
 Used to assign the id of this element. More...
 
virtual PRMObject::prm_type obj_type () const
 
Fast access to random variable's properties
const std::string & safeName () const
 Returns the safe name of this PRMClassElement, if any. More...
 
virtual std::string cast (const PRMType &t) const
 Returns the name of the cast descendant with PRMType t of this PRMClassElement. 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 Attributes

std::string safeName_
 The safe name of this PRMClassElement. More...
 

Built-in type

enum  ClassElementType {
  prm_attribute, prm_aggregate, prm_refslot, prm_slotchain,
  prm_parameter
}
 Returns true if obj_ptr is of type PRMReferenceSlot. More...
 
static std::string enum2str (ClassElementType type)
 Returns true if obj_ptr is of type PRMReferenceSlot. More...
 
static INLINE bool isReferenceSlot (const PRMClassElement< GUM_SCALAR > &elt)
 Returns true if obj_ptr is of type PRMReferenceSlot. More...
 
static INLINE bool isAttribute (const PRMClassElement< GUM_SCALAR > &elt)
 Returns true if obj_ptr is of type PRMAttribute. More...
 
static INLINE bool isAggregate (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMAggregate. More...
 
static INLINE bool isSlotChain (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMSlotChain. More...
 
static INLINE bool isParameter (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMParameter. 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 enum2str (prm_type type)
 Returns the string representation of a PRMObject. 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 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...
 

Private members of PRMSlotChain.

Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
 The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain. More...
 
bool _isMultiple_
 Flag indicating if this slot chain is multiple or not. More...
 
void _copyLastElt_ ()
 Copy the last element, this prevents unwanted DuplicateElement exceptions. More...
 

Detailed Description

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

A PRMSlotChain represents a sequence of gum::prm::PRMClassElement<GUM_SCALAR> where the n-1 first gum::prm::PRMClassElement<GUM_SCALAR> are gum::prm::PRMReferenceSlot and the last gum::prm::PRMClassElement<GUM_SCALAR> an gum::prm::PRMAttribute or an gum::prm::PRMAggregate.

A PRMSlotChain behaves as an gum::prm::PRMAttribute or an gum::prm::PRMAggregate (depending the gum::prm::PRMClassElement<GUM_SCALAR> type of it's last element) regarding the following methods: gum::prm::PRMClassElement<GUM_SCALAR>::type() and gum::prm::PRMClassElement<GUM_SCALAR>::cpf().

Definition at line 226 of file PRMObject.h.

Member Enumeration Documentation

◆ ClassElementType

template<typename GUM_SCALAR>
enum gum::prm::PRMClassElement::ClassElementType
inherited

Returns true if obj_ptr is of type PRMReferenceSlot.

Enumerator
prm_attribute 
prm_aggregate 
prm_refslot 
prm_slotchain 
prm_parameter 

Definition at line 94 of file PRMClassElement.h.

◆ 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

◆ PRMSlotChain() [1/3]

template<typename GUM_SCALAR>
gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain ( const std::string &  name,
const Sequence< PRMClassElement< GUM_SCALAR > * > &  chain 
)

Default constructor.

Chain's n-1 first elements must be PRMReferenceSlot and the last element must either be an PRMAttribute or an PRMAggregate.

Warning: the last element in chain is copied !

Parameters
nameThe name of this PRMSlotChain.
chainThe chain of gum::prm::PRMClassElement<GUM_SCALAR> in this PRMSlotChain.
Exceptions
OperationNotAllowedRaised if the chain contains less than two PRMClassElement<GUM_SCALAR>.
WrongClassElement<GUM_SCALAR>Raised contains invalid PRMClassElement<GUM_SCALAR>.

Definition at line 34 of file PRMSlotChain_tpl.h.

36  :
37  PRMClassElement< GUM_SCALAR >(name),
38  _chain_(new Sequence< PRMClassElement< GUM_SCALAR >* >(chain)), _isMultiple_(false) {
39  GUM_CONSTRUCTOR(PRMSlotChain);
40 
41  if (_chain_->size() < 2) {
42  GUM_ERROR(OperationNotAllowed, "chain must contain at least two ClassElement")
43  }
44 
45  for (Size i = 0; i < _chain_->size() - 1; ++i) {
46  if (_chain_->atPos(i)->elt_type() != PRMClassElement< GUM_SCALAR >::prm_refslot) {
47  GUM_ERROR(WrongClassElement, "illegal ClassElement in chain")
48  } else {
50  = _isMultiple_
51  || static_cast< PRMReferenceSlot< GUM_SCALAR >* >(_chain_->atPos(i))->isArray();
52  }
53  }
54 
55  _copyLastElt_();
56 
57  this->safeName_
58  = PRMObject::LEFT_CAST() + lastElt().type().name() + PRMObject::RIGHT_CAST() + name;
59  this->lastElt().type().variable().setName(name);
60  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207
bool _isMultiple_
Flag indicating if this slot chain is multiple or not.
Definition: PRMSlotChain.h:210
std::string safeName_
The safe name of this PRMClassElement.
void _copyLastElt_()
Copy the last element, this prevents unwanted DuplicateElement exceptions.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:79
PRMSlotChain(const std::string &name, const Sequence< PRMClassElement< GUM_SCALAR > * > &chain)
Default constructor.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
PRMClassElement< GUM_SCALAR > & lastElt()
Returns the last element of the slot chain, typically this is an gum::PRMAttribute or a gum::PRMAggre...
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:80
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
Sequence< PRMClassElement< GUM_SCALAR > *> & chain()
Return the sequence representing the chain of elements in this PRMSlotChain.

◆ PRMSlotChain() [2/3]

template<typename GUM_SCALAR>
gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain ( Sequence< PRMClassElement< GUM_SCALAR > * > *  chain,
const std::string &  name 
)

Tweak constructor.

Chain's n-1 first elements must be PRMReferenceSlot and the last element must either be an PRMAttribute or an PRMAggregate.

Warning: the last element in chain is copied !

Parameters
nameThe name of this PRMSlotChain.
chainThe chain given to this PRMSlotChain, it is deleted when PRMSlotChain::~PRMSlotChain() is called.
Exceptions
OperationNotAllowedRaised if the chain contains less than two PRMClassElement<GUM_SCALAR>.
WrongClassElement<GUM_SCALAR>Raised contains invalid PRMClassElement<GUM_SCALAR>.

Definition at line 65 of file PRMSlotChain_tpl.h.

66  :
68  // No need to
69  // GUM_CONSTRUCTOR(PRMSlotChain);
70 
71  // if ( _chain_->size() < 2) {
72  // GUM_ERROR(OperationNotAllowed,
73  // "chain must containt at least two PRMClassElement")
74  //}
75 
76  // for (Size i = 0; i < _chain_->size() - 1; ++i) {
77  // if (not( _chain_->atPos(i)->elt_type() !=
78  // PRMClassElement<GUM_SCALAR>::prm_refslot)) {
79  // GUM_ERROR(WrongClassElement, "illegal PRMClassElement in chain")
80  // } else {
81  // _isMultiple_ =
82  // _isMultiple_ or
83  // static_cast<PRMReferenceSlot<GUM_SCALAR>
84  // *>( _chain_->atPos(i))->isArray();
85  // }
86  //}
87 
88  // __copyLastElt();
89  // this->safeName_ = PRMObject::LEFT_CAST() + lastElt().type().name() +
90  // PRMObject::RIGHT_CAST() + name;
91  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
PRMSlotChain(const std::string &name, const Sequence< PRMClassElement< GUM_SCALAR > * > &chain)
Default constructor.
Sequence< PRMClassElement< GUM_SCALAR > *> & chain()
Return the sequence representing the chain of elements in this PRMSlotChain.

◆ PRMSlotChain() [3/3]

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

Copy constructor.

This creates a copy of the slot chain.

Definition at line 138 of file PRMSlotChain_tpl.h.

138  :
139  PRMClassElement< GUM_SCALAR >(source.name()),
140  _chain_(new Sequence< PRMClassElement< GUM_SCALAR >* >(source.chain())),
141  _isMultiple_(source.isMultiple()) {
142  GUM_CONS_CPY(PRMSlotChain);
143  _copyLastElt_();
144  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207
bool _isMultiple_
Flag indicating if this slot chain is multiple or not.
Definition: PRMSlotChain.h:210
void _copyLastElt_()
Copy the last element, this prevents unwanted DuplicateElement exceptions.
PRMSlotChain(const std::string &name, const Sequence< PRMClassElement< GUM_SCALAR > * > &chain)
Default constructor.

◆ ~PRMSlotChain()

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

Destructor.

Definition at line 131 of file PRMSlotChain_tpl.h.

131  {
132  GUM_DESTRUCTOR(PRMSlotChain);
133  delete _chain_->back();
134  delete _chain_;
135  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207
PRMSlotChain(const std::string &name, const Sequence< PRMClassElement< GUM_SCALAR > * > &chain)
Default constructor.

Member Function Documentation

◆ _copyLastElt_()

template<typename GUM_SCALAR >
void gum::prm::PRMSlotChain< GUM_SCALAR >::_copyLastElt_ ( )
private

Copy the last element, this prevents unwanted DuplicateElement exceptions.

Definition at line 94 of file PRMSlotChain_tpl.h.

94  {
95  PRMClassElement< GUM_SCALAR >* new_elt = nullptr;
96 
97  switch (_chain_->back()->elt_type()) {
99  auto old_attr = static_cast< const PRMAttribute< GUM_SCALAR >* >(_chain_->back());
100 
101  Bijection< const DiscreteVariable*, const DiscreteVariable* > bij;
102  for (auto var: old_attr->cpf().variablesSequence()) {
103  if (var != &(old_attr->type().variable())) { bij.insert(var, var); }
104  }
105 
106  new_elt = old_attr->copy(bij);
107  break;
108  }
109 
111  const PRMAggregate< GUM_SCALAR >* c_agg
112  = static_cast< const PRMAggregate< GUM_SCALAR >* >(_chain_->back());
113  PRMAggregate< GUM_SCALAR >* agg = new PRMAggregate< GUM_SCALAR >(c_agg->name(),
114  c_agg->agg_type(),
115  c_agg->type(),
116  c_agg->id());
117  new_elt = agg;
118  break;
119  }
120 
121  default: {
122  GUM_ERROR(WrongClassElement, "last element of chain is not valid")
123  }
124  }
125 
126  new_elt->setId(_chain_->back()->id());
127  _chain_->setAtPos(_chain_->size() - 1, new_elt);
128  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ addChild()

template<typename GUM_SCALAR>
INLINE void gum::prm::PRMSlotChain< GUM_SCALAR >::addChild ( const PRMClassElement< GUM_SCALAR > &  elt)
virtual

See gum::PRMClassElement<GUM_SCALAR>::addChild_().

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

Definition at line 210 of file PRMSlotChain_tpl.h.

210 {}

◆ addParent()

template<typename GUM_SCALAR>
INLINE void gum::prm::PRMSlotChain< GUM_SCALAR >::addParent ( const PRMClassElement< GUM_SCALAR > &  elt)
virtual

See gum::PRMClassElement<GUM_SCALAR>::addParent_().

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

Definition at line 207 of file PRMSlotChain_tpl.h.

207 {}

◆ cast()

template<typename GUM_SCALAR >
INLINE std::string gum::prm::PRMClassElement< GUM_SCALAR >::cast ( const PRMType t) const
virtualinherited

Returns the name of the cast descendant with PRMType t of this PRMClassElement.

Parameters
tThe type in which we want to cast this PRMClassElement.
Exceptions
OperationNotAllowedIf the cast is impossible.

Definition at line 71 of file PRMClassElement_tpl.h.

71  {
72  if (type().isSubTypeOf(t)) {
73  return PRMObject::LEFT_CAST() + t.name() + PRMObject::RIGHT_CAST() + name();
74  } else {
75  GUM_ERROR(OperationNotAllowed, "illegal cast")
76  }
77  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:79
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:80
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ chain() [1/2]

template<typename GUM_SCALAR >
INLINE Sequence< PRMClassElement< GUM_SCALAR > *> & gum::prm::PRMSlotChain< GUM_SCALAR >::chain ( )

Return the sequence representing the chain of elements in this PRMSlotChain.

Definition at line 196 of file PRMSlotChain_tpl.h.

196  {
197  return *_chain_;
198  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207

◆ chain() [2/2]

template<typename GUM_SCALAR >
INLINE const Sequence< PRMClassElement< GUM_SCALAR > *> & gum::prm::PRMSlotChain< GUM_SCALAR >::chain ( ) const

Return the sequence representing the chain of elements in this PRMSlotChain.

Definition at line 202 of file PRMSlotChain_tpl.h.

202  {
203  return *_chain_;
204  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207

◆ cpf()

template<typename GUM_SCALAR >
INLINE const Potential< GUM_SCALAR > & gum::prm::PRMSlotChain< GUM_SCALAR >::cpf ( ) const
virtual

This is similar to the following call: this->lastElt().cpf()

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

Definition at line 169 of file PRMSlotChain_tpl.h.

169  {
170  return _chain_->back()->cpf();
171  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207

◆ elt_type()

template<typename GUM_SCALAR >
INLINE PRMClassElement< GUM_SCALAR >::ClassElementType gum::prm::PRMSlotChain< GUM_SCALAR >::elt_type ( ) const
virtual

See gum::PRMClassElement<GUM_SCALAR>::elt_type().

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

Definition at line 154 of file PRMSlotChain_tpl.h.

154  {
155  return this->prm_slotchain;
156  }

◆ end() [1/2]

template<typename GUM_SCALAR >
INLINE PRMClassElementContainer< GUM_SCALAR > & gum::prm::PRMSlotChain< GUM_SCALAR >::end ( )

Returns the PRMClassElement<GUM_SCALAR>Container over which this slot chain ends.

Definition at line 174 of file PRMSlotChain_tpl.h.

174  {
175  return static_cast< PRMReferenceSlot< GUM_SCALAR >* >(_chain_->atPos(_chain_->size() - 2))
176  ->slotType();
177  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207

◆ end() [2/2]

template<typename GUM_SCALAR >
INLINE const PRMClassElementContainer< GUM_SCALAR > & gum::prm::PRMSlotChain< GUM_SCALAR >::end ( ) const

Returns the PRMClassElement<GUM_SCALAR>Container over which this slot chain ends.

Definition at line 180 of file PRMSlotChain_tpl.h.

180  {
181  return static_cast< PRMReferenceSlot< GUM_SCALAR >* >(_chain_->atPos(_chain_->size() - 2))
182  ->slotType();
183  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207

◆ enum2str() [1/2]

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  }

◆ enum2str() [2/2]

template<typename GUM_SCALAR>
static std::string gum::prm::PRMClassElement< GUM_SCALAR >::enum2str ( ClassElementType  type)
inlinestaticinherited

Returns true if obj_ptr is of type PRMReferenceSlot.

Definition at line 103 of file PRMClassElement.h.

103  {
104  switch (type) {
105  case prm_attribute:
106  return "prm_attribute";
107 
108  case prm_aggregate:
109  return "prm_aggregate";
110 
111  case prm_refslot:
112  return "prm_refslot";
113 
114  case prm_slotchain:
115  return "prm_slotchain";
116 
117  case prm_parameter:
118  return "prm_parameter";
119 
120  default:
121  return "unknown";
122  }
123  }
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.

◆ getCastDescendant()

template<typename GUM_SCALAR >
INLINE PRMAttribute< GUM_SCALAR > * gum::prm::PRMSlotChain< GUM_SCALAR >::getCastDescendant ( ) const
virtual

Raise a gum::OperationNotAllowed exception See gum::PRMClassElement<GUM_SCALAR>::getCastDescendant()

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

Definition at line 218 of file PRMSlotChain_tpl.h.

218  {
219  GUM_ERROR(OperationNotAllowed, "This is a slotchain")
220  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ id()

template<typename GUM_SCALAR >
INLINE NodeId gum::prm::PRMClassElement< GUM_SCALAR >::id ( ) const
inherited

Returns the NodeId of this element in it's class DAG.

Definition at line 51 of file PRMClassElement_tpl.h.

51  {
52  return _id_;
53  }
NodeId _id_
The node&#39;s id of this element.

◆ isAggregate()

template<typename GUM_SCALAR>
static INLINE bool gum::prm::PRMClassElement< GUM_SCALAR >::isAggregate ( const PRMClassElement< GUM_SCALAR > &  elt)
inlinestaticinherited

Return true if obj is of type PRMAggregate.

Definition at line 136 of file PRMClassElement.h.

136  {
137  return elt.elt_type() == prm_aggregate;
138  }

◆ isAttribute()

template<typename GUM_SCALAR>
static INLINE bool gum::prm::PRMClassElement< GUM_SCALAR >::isAttribute ( const PRMClassElement< GUM_SCALAR > &  elt)
inlinestaticinherited

Returns true if obj_ptr is of type PRMAttribute.

Definition at line 131 of file PRMClassElement.h.

131  {
132  return elt.elt_type() == prm_attribute;
133  }

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

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

◆ isMultiple()

template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMSlotChain< GUM_SCALAR >::isMultiple ( ) const

Return true if this slot chain contains at least one multiple reference slot.

Definition at line 213 of file PRMSlotChain_tpl.h.

213  {
214  return _isMultiple_;
215  }
bool _isMultiple_
Flag indicating if this slot chain is multiple or not.
Definition: PRMSlotChain.h:210

◆ isParameter()

template<typename GUM_SCALAR>
static INLINE bool gum::prm::PRMClassElement< GUM_SCALAR >::isParameter ( const PRMClassElement< GUM_SCALAR > &  elt)
inlinestaticinherited

Return true if obj is of type PRMParameter.

Definition at line 146 of file PRMClassElement.h.

146  {
147  return elt.elt_type() == prm_parameter;
148  }

◆ isReferenceSlot()

template<typename GUM_SCALAR>
static INLINE bool gum::prm::PRMClassElement< GUM_SCALAR >::isReferenceSlot ( const PRMClassElement< GUM_SCALAR > &  elt)
inlinestaticinherited

Returns true if obj_ptr is of type PRMReferenceSlot.

Definition at line 126 of file PRMClassElement.h.

126  {
127  return elt.elt_type() == prm_refslot;
128  }

◆ isSlotChain()

template<typename GUM_SCALAR>
static INLINE bool gum::prm::PRMClassElement< GUM_SCALAR >::isSlotChain ( const PRMClassElement< GUM_SCALAR > &  elt)
inlinestaticinherited

Return true if obj is of type PRMSlotChain.

Definition at line 141 of file PRMClassElement.h.

141  {
142  return elt.elt_type() == prm_slotchain;
143  }

◆ lastElt() [1/2]

template<typename GUM_SCALAR >
INLINE PRMClassElement< GUM_SCALAR > & gum::prm::PRMSlotChain< GUM_SCALAR >::lastElt ( )

Returns the last element of the slot chain, typically this is an gum::PRMAttribute or a gum::PRMAggregate.

Definition at line 186 of file PRMSlotChain_tpl.h.

186  {
187  return *(_chain_->back());
188  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207

◆ lastElt() [2/2]

template<typename GUM_SCALAR >
INLINE const PRMClassElement< GUM_SCALAR > & gum::prm::PRMSlotChain< GUM_SCALAR >::lastElt ( ) const

Returns the last element of the slot chain, typically this is an gum::PRMAttribute or a gum::PRMAggregate.

Definition at line 191 of file PRMSlotChain_tpl.h.

191  {
192  return *(_chain_->back());
193  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207

◆ LEFT_CAST()

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

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

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

Definition at line 79 of file PRMObject.h.

79 { return "("; }

◆ name() [1/2]

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

Returns the name of this object.

Definition at line 34 of file PRMObject_inl.h.

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

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

◆ name() [2/2]

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

Change the name of the PRM Object.

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

Definition at line 38 of file PRMObject_inl.h.

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

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

◆ obj_type()

template<typename GUM_SCALAR >
INLINE PRMObject::prm_type gum::prm::PRMClassElement< GUM_SCALAR >::obj_type ( ) const
virtualinherited
See also
gum::PRMObject::obj_type().

Implements gum::prm::PRMObject.

Definition at line 56 of file PRMClassElement_tpl.h.

◆ operator!=()

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

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

Definition at line 46 of file PRMObject_inl.h.

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

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

◆ operator=()

template<typename GUM_SCALAR >
PRMSlotChain< GUM_SCALAR > & gum::prm::PRMSlotChain< GUM_SCALAR >::operator= ( const PRMSlotChain< GUM_SCALAR > &  source)
private

Copy operator. Don't use it.

Definition at line 148 of file PRMSlotChain_tpl.h.

148  {
149  GUM_ERROR(FatalError, "Illegal call to gum::SlotChain<GUM_SCALAR> copy constructor.")
150  }
#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:

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

◆ safeName()

template<typename GUM_SCALAR >
INLINE const std::string & gum::prm::PRMClassElement< GUM_SCALAR >::safeName ( ) const
inherited

Returns the safe name of this PRMClassElement, if any.

This will only work if this PRMClassElement is an PRMAttribute or an PRMAggregate.

Returns
Returns the safe name of this PRMClassElement.
Exceptions
NotFound&Raised if this PRMClassElement does not have any safe name.

Definition at line 66 of file PRMClassElement_tpl.h.

66  {
67  return safeName_;
68  }
std::string safeName_
The safe name of this PRMClassElement.

◆ setId()

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMClassElement< GUM_SCALAR >::setId ( NodeId  id)
virtualinherited

Used to assign the id of this element.

Definition at line 61 of file PRMClassElement_tpl.h.

61  {
62  _id_ = id;
63  }
NodeId _id_
The node&#39;s id of this element.
NodeId id() const
Returns the NodeId of this element in it&#39;s class DAG.

◆ type() [1/2]

template<typename GUM_SCALAR >
INLINE PRMType & gum::prm::PRMSlotChain< GUM_SCALAR >::type ( )
virtual

This is similar to the following call: this->lastElt().type()

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

Definition at line 159 of file PRMSlotChain_tpl.h.

159  {
160  return _chain_->back()->type();
161  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207

◆ type() [2/2]

template<typename GUM_SCALAR >
INLINE const PRMType & gum::prm::PRMSlotChain< GUM_SCALAR >::type ( ) const
virtual

This is similar to the following call: this->lastElt().type()

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

Definition at line 164 of file PRMSlotChain_tpl.h.

164  {
165  return _chain_->back()->type();
166  }
Sequence< PRMClassElement< GUM_SCALAR > *> * _chain_
The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.
Definition: PRMSlotChain.h:207

Member Data Documentation

◆ _chain_

template<typename GUM_SCALAR>
Sequence< PRMClassElement< GUM_SCALAR >* >* gum::prm::PRMSlotChain< GUM_SCALAR >::_chain_
private

The sequence of PRMClassElement<GUM_SCALAR> composing the slot chain.

Definition at line 207 of file PRMSlotChain.h.

◆ _isMultiple_

template<typename GUM_SCALAR>
bool gum::prm::PRMSlotChain< GUM_SCALAR >::_isMultiple_
private

Flag indicating if this slot chain is multiple or not.

Definition at line 210 of file PRMSlotChain.h.

◆ safeName_

template<typename GUM_SCALAR>
std::string gum::prm::PRMClassElement< GUM_SCALAR >::safeName_
protectedinherited

The safe name of this PRMClassElement.

Definition at line 265 of file PRMClassElement.h.


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