aGrUM  0.14.2
gum::prm::PRMFuncAttribute< GUM_SCALAR > Class Template Reference

<agrum/PRM/elements/funcAttribute.h> More...

#include <PRMFuncAttribute.h>

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

Public Member Functions

 PRMFuncAttribute (const std::string &name, const PRMType &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
 Constructor used by gum::Class. More...
 
virtual ~PRMFuncAttribute ()
 Destructor. More...
 
virtual void addParent (const PRMClassElement< GUM_SCALAR > &elt)
 See gum::PRMClassElement::_addParent(). More...
 
virtual void addChild (const PRMClassElement< GUM_SCALAR > &elt)
 See gum::PRMClassElement::_addChild(). More...
 
Getters & setters
virtual PRMAttribute< GUM_SCALAR > * newFactory (const PRMClass< GUM_SCALAR > &c) const
 See gum::PRMClassElement::elt_type(). More...
 
virtual PRMAttribute< GUM_SCALAR > * copy (Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const
 See gum::PRMClassElement::elt_type(). More...
 
virtual void copyCpf (const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bif, const PRMAttribute< GUM_SCALAR > &source)
 See gum::PRMClassElement::elt_type(). More...
 
virtual PRMClassElement< GUM_SCALAR >::ClassElementType elt_type () const
 See gum::PRMClassElement::elt_type(). More...
 
virtual PRMTypetype ()
 See gum::PRMClassElement::type(). More...
 
virtual const PRMTypetype () const
 See gum::PRMClassElement::type(). More...
 
virtual const Potential< GUM_SCALAR > & cpf () const
 See gum::PRMClassElement::cpf(). More...
 
virtual PRMAttribute< GUM_SCALAR > * getCastDescendant () const
 See gum::PRMClassElement::elt_type(). More...
 
virtual void setAsCastDescendant (PRMAttribute< GUM_SCALAR > *attr)
 See gum::PRMClassElement::elt_type(). More...
 
virtual void becomeCastDescendant (PRMType &subtype)
 See gum::PRMClassElement::elt_type(). More...
 
virtual void swap (const PRMType &old_type, const PRMType &new_type)
 Swap old_type with new_type in the PRMClassElement cpt. More...
 
Getters & setters
virtual void overload (PRMAttribute< GUM_SCALAR > *source)
 Set this as overload of source (necessayr to preserver internal pointers for MultiDims). 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...
 

Protected Member Functions

 PRMFuncAttribute (const PRMFuncAttribute< GUM_SCALAR > &source)
 Copy constructor. Don't use it. More...
 
PRMFuncAttribute< GUM_SCALAR > & operator= (const PRMFuncAttribute< GUM_SCALAR > &from)
 Copy operator. Don't use it. More...
 
virtual void _setCpf (Potential< GUM_SCALAR > *cpf)
 
virtual PRMType_type ()
 
virtual void _type (PRMType *t)
 

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

Detailed Description

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

<agrum/PRM/elements/funcAttribute.h>

This class overload gum::prm::PRMClassElement::_addParent() and gum::prm::PRMClassElement::_addChild with empty methods.

This class should be used when dealing with functions such as Noisy-Or which require special method calls to add parents. When dealing with such attributes, you should create the MultiDim yourself and populate it with the attribute's parents.

See gum::prm::PRMFactory::addAttribute(PRMAttribute*) for more details.

Definition at line 55 of file PRMFuncAttribute.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 92 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 66 of file PRMObject.h.

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

Constructor & Destructor Documentation

◆ PRMFuncAttribute() [1/2]

template<typename GUM_SCALAR >
INLINE gum::prm::PRMFuncAttribute< GUM_SCALAR >::PRMFuncAttribute ( const std::string &  name,
const PRMType type,
MultiDimImplementation< GUM_SCALAR > *  impl = new MultiDimArray< GUM_SCALAR >() 
)

Constructor used by gum::Class.

This will create an PRMFuncAttribute with only one variable: type and with the given implementation.

Parameters
nameThe name of this PRMFuncAttribute.
typeThe type of this PRMFuncAttribute, it is copied.
implThe MultiDimImplementation used by the internal Potential of this PRMFuncAttribute. it will be deleted after the call of ~PRMFuncAttribute.

Definition at line 32 of file PRMFuncAttribute_tpl.h.

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

35  :
36  PRMScalarAttribute< GUM_SCALAR >(name, type, impl) {
37  std::stringstream str;
38  str << "In FuncAttribute(" << name << ", " << type.name() << ", " << impl
39  << ")";
40  GUM_CONSTRUCTOR(PRMFuncAttribute);
41  }
const std::string & name() const
Returns the name of this object.
Definition: PRMType_inl.h:65
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
virtual PRMType & type()
See gum::PRMClassElement::type().
PRMFuncAttribute(const std::string &name, const PRMType &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
Constructor used by gum::Class.
+ Here is the call graph for this function:

◆ ~PRMFuncAttribute()

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

Destructor.

Definition at line 44 of file PRMFuncAttribute_tpl.h.

44  {
45  GUM_DESTRUCTOR(PRMFuncAttribute);
46  }
PRMFuncAttribute(const std::string &name, const PRMType &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
Constructor used by gum::Class.

◆ PRMFuncAttribute() [2/2]

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

Copy constructor. Don't use it.

Definition at line 57 of file PRMFuncAttribute_tpl.h.

References GUM_ERROR, and gum::prm::PRMFuncAttribute< GUM_SCALAR >::operator=().

58  :
59  PRMScalarAttribute< GUM_SCALAR >(source) {
60  GUM_CONS_CPY(PRMFuncAttribute);
61  GUM_ERROR(FatalError, "illegal call to copy constructor");
62  }
PRMFuncAttribute(const std::string &name, const PRMType &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
Constructor used by gum::Class.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ Here is the call graph for this function:

Member Function Documentation

◆ _setCpf()

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMFuncAttribute< GUM_SCALAR >::_setCpf ( Potential< GUM_SCALAR > *  cpf)
protectedvirtual

Definition at line 72 of file PRMFuncAttribute_tpl.h.

References GUM_ERROR.

72  {
73  GUM_ERROR(OperationNotAllowed,
74  "Cannot change CPF of a functional attribute");
75  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52

◆ _type() [1/2]

template<typename GUM_SCALAR >
PRMType * gum::prm::PRMScalarAttribute< GUM_SCALAR >::_type ( )
protectedvirtualinherited

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

Definition at line 269 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::__type.

269  {
270  return __type;
271  }
PRMType * __type
The random variable type of this attribute.

◆ _type() [2/2]

template<typename GUM_SCALAR >
void gum::prm::PRMScalarAttribute< GUM_SCALAR >::_type ( PRMType t)
protectedvirtualinherited

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

Definition at line 274 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::__cpf, gum::prm::PRMScalarAttribute< GUM_SCALAR >::__type, gum::DiscreteVariable::domainSize(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), and gum::Instantiation::setFirst().

274  {
275  if (__type->variable().domainSize() != t->variable().domainSize()) {
276  GUM_ERROR(OperationNotAllowed,
277  "Cannot replace types with difference domain size");
278  }
279  auto old = __cpf;
280 
281  __cpf = new Potential< GUM_SCALAR >();
282 
283  for (auto var : old->variablesSequence()) {
284  if (var != &(__type->variable())) {
285  __cpf->add(*var);
286  } else {
287  __cpf->add(t->variable());
288  }
289  }
290 
291  Instantiation inst(__cpf), jnst(old);
292 
293  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
294  inst.inc(), jnst.inc()) {
295  __cpf->set(inst, old->get(jnst));
296  }
297 
298  delete old;
299 
300  __type = t;
301 
302  GUM_ASSERT(__cpf->contains(__type->variable()));
303  GUM_ASSERT(inst.end() && jnst.end());
304  }
virtual Size domainSize() const =0
PRMType * __type
The random variable type of this attribute.
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ Here is the call graph for this function:

◆ addChild()

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

See gum::PRMClassElement::_addChild().

Reimplemented from gum::prm::PRMScalarAttribute< GUM_SCALAR >.

Definition at line 53 of file PRMFuncAttribute_tpl.h.

54  {}

◆ addParent()

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

See gum::PRMClassElement::_addParent().

Reimplemented from gum::prm::PRMScalarAttribute< GUM_SCALAR >.

Definition at line 49 of file PRMFuncAttribute_tpl.h.

50  {}

◆ becomeCastDescendant()

template<typename GUM_SCALAR >
void gum::prm::PRMScalarAttribute< GUM_SCALAR >::becomeCastDescendant ( PRMType subtype)
virtualinherited

See gum::PRMClassElement::elt_type().

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

Definition at line 209 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::__cpf, gum::Instantiation::end(), gum::Instantiation::inc(), gum::prm::PRMType::label_map(), gum::Instantiation::pos(), gum::Instantiation::setFirst(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::type(), and gum::prm::PRMType::variable().

209  {
210  delete __cpf;
211  __cpf = new Potential< GUM_SCALAR >();
212  __cpf->add(type().variable());
213  __cpf->add(subtype.variable());
214 
215  Instantiation inst(*__cpf);
216 
217  for (inst.setFirst(); !inst.end(); inst.inc()) {
218  auto my_pos = inst.pos(subtype.variable());
219  if (subtype.label_map()[my_pos] == inst.pos(type().variable())) {
220  __cpf->set(inst, 1);
221  } else {
222  __cpf->set(inst, 0);
223  }
224  }
225  }
virtual PRMType & type()
See gum::PRMClassElement::type().
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
+ Here is the call graph for this function:

◆ 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 73 of file PRMClassElement_tpl.h.

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::addNoisyOrCompound(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), and gum::prm::PRMClassElement< double >::isParameter().

73  {
74  if (type().isSubTypeOf(t)) {
75  return PRMObject::LEFT_CAST() + t.name() + PRMObject::RIGHT_CAST()
76  + name();
77  } else {
78  GUM_ERROR(OperationNotAllowed, "illegal cast");
79  }
80  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
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:76
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:77
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ Here is the caller graph for this function:

◆ copy()

template<typename GUM_SCALAR >
PRMAttribute< GUM_SCALAR > * gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy ( Bijection< const DiscreteVariable *, const DiscreteVariable * >  bij) const
virtualinherited

See gum::PRMClassElement::elt_type().

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

Definition at line 78 of file PRMScalarAttribute_tpl.h.

References gum::prm::copyPotential(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::cpf(), gum::BijectionImplementation< T1, T2, Alloc, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::existsFirst(), gum::BijectionImplementation< T1, T2, Alloc, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::insert(), gum::prm::PRMObject::name(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::type().

79  {
80  auto copy = new PRMScalarAttribute< GUM_SCALAR >(this->name(), this->type());
81 
82  if (!bij.existsFirst(&(type().variable()))) {
83  bij.insert(&(type().variable()), &(copy->type().variable()));
84  }
85 
86  delete copy->__cpf;
87  copy->__cpf = copyPotential(bij, cpf());
88 
89  return copy;
90  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
virtual PRMType & type()
See gum::PRMClassElement::type().
virtual const Potential< GUM_SCALAR > & cpf() const
See gum::PRMClassElement::cpf().
Potential< GUM_SCALAR > * copyPotential(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bij, const Potential< GUM_SCALAR > &source)
Returns a copy of a Potential after applying a bijection over the variables in source.
Definition: utils_prm_tpl.h:27
virtual PRMAttribute< GUM_SCALAR > * copy(Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const
See gum::PRMClassElement::elt_type().
+ Here is the call graph for this function:

◆ copyCpf()

template<typename GUM_SCALAR >
void gum::prm::PRMScalarAttribute< GUM_SCALAR >::copyCpf ( const Bijection< const DiscreteVariable *, const DiscreteVariable * > &  bif,
const PRMAttribute< GUM_SCALAR > &  source 
)
virtualinherited

See gum::PRMClassElement::elt_type().

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

Definition at line 93 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::__cpf, gum::prm::PRMScalarAttribute< GUM_SCALAR >::__type, gum::prm::PRMAttribute< GUM_SCALAR >::cpf(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::operator=(), gum::BijectionImplementation< T1, T2, Alloc, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::second(), and gum::prm::PRMAttribute< GUM_SCALAR >::type().

95  {
96  delete __cpf;
97  __cpf = new Potential< GUM_SCALAR >();
98 
99  for (auto var : source.cpf().variablesSequence()) {
100  __cpf->add(*(bij.second(var)));
101  }
102 
103  Instantiation inst(*__cpf), jnst(source.cpf());
104 
105  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
106  inst.inc(), jnst.inc()) {
107  __cpf->set(inst, source.cpf().get(jnst));
108  }
109 
110  GUM_ASSERT(inst.end() && jnst.end());
111  GUM_ASSERT(__cpf->contains(__type->variable()));
112  GUM_ASSERT(!__cpf->contains(source.type().variable()));
113  }
PRMType * __type
The random variable type of this attribute.
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
+ Here is the call graph for this function:

◆ cpf()

template<typename GUM_SCALAR >
INLINE const Potential< GUM_SCALAR > & gum::prm::PRMScalarAttribute< GUM_SCALAR >::cpf ( ) const
virtualinherited

See gum::PRMClassElement::cpf().

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

Definition at line 140 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::__cpf.

Referenced by gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMAggregate< double >::getCastDescendant(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::newFactory().

140  {
141  return *__cpf;
142  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
+ Here is the caller graph for this function:

◆ elt_type()

template<typename GUM_SCALAR >
INLINE PRMClassElement< GUM_SCALAR >::ClassElementType gum::prm::PRMScalarAttribute< GUM_SCALAR >::elt_type ( ) const
virtualinherited

See gum::PRMClassElement::elt_type().

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

Definition at line 124 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute.

124  {
125  return this->prm_attribute;
126  }

◆ enum2str() [1/2]

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

Returns the string representation of a PRMObject.

Definition at line 80 of file PRMObject.h.

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

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

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

◆ 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 100 of file PRMClassElement.h.

100  {
101  switch (type) {
102  case prm_attribute: return "prm_attribute";
103 
104  case prm_aggregate: return "prm_aggregate";
105 
106  case prm_refslot: return "prm_refslot";
107 
108  case prm_slotchain: return "prm_slotchain";
109 
110  case prm_parameter: return "prm_parameter";
111 
112  default: return "unknown";
113  }
114  }
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.

◆ getCastDescendant()

template<typename GUM_SCALAR >
PRMAttribute< GUM_SCALAR > * gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant ( ) const
virtualinherited

See gum::PRMClassElement::elt_type().

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

Definition at line 165 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMClassElement< GUM_SCALAR >::cast(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::cpf(), GUM_ERROR, gum::prm::PRMType::label_map(), gum::prm::PRMObject::name(), gum::prm::PRMType::superType(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::type(), and gum::prm::PRMType::variable().

165  {
166  PRMScalarAttribute< GUM_SCALAR >* cast = 0;
167 
168  try {
169  cast =
170  new PRMScalarAttribute< GUM_SCALAR >(this->name(), type().superType());
171  } catch (NotFound&) {
172  GUM_ERROR(OperationNotAllowed,
173  "this ScalarAttribute can not have cast descendant");
174  }
175 
176  cast->addParent(*this);
177  const DiscreteVariable& my_var = type().variable();
178  DiscreteVariable& cast_var = cast->type().variable();
179  Instantiation inst(cast->cpf());
180 
181  for (inst.setFirst(); !inst.end(); inst.inc()) {
182  if (type().label_map()[inst.val(my_var)] == inst.val(cast_var)) {
183  cast->cpf().set(inst, 1);
184  } else {
185  cast->cpf().set(inst, 0);
186  }
187  }
188 
189  return cast;
190  }
PRMType & superType()
Returns the super type of this type.
Definition: PRMType_inl.h:33
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
Definition: PRMType_inl.h:42
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
virtual PRMType & type()
See gum::PRMClassElement::type().
virtual std::string cast(const PRMType &t) const
Returns the name of the cast descendant with PRMType t of this PRMClassElement.
const std::vector< Idx > & label_map() const
Returns the vector in which the i-th element is the Idx of the super type&#39;s label for the i-th label ...
Definition: PRMType_inl.h:91
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ Here is the call graph for this function:

◆ 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 52 of file PRMClassElement_tpl.h.

Referenced by gum::prm::PRMClass< double >::__addCastDescendants(), gum::prm::PRMInterface< double >::__addCastDescendants(), gum::prm::PRMClass< double >::__checkInterface(), gum::prm::PRMClass< double >::__checkRefInterface(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAggregates(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttribute(), gum::prm::PRMSlotChain< double >::__copyLastElt(), gum::prm::SVE< GUM_SCALAR >::__getAggPotential(), gum::prm::PRMSystem< double >::__groundPotential(), gum::prm::PRMClass< double >::__inheritClass(), gum::prm::InstanceBayesNet< GUM_SCALAR >::__init(), gum::prm::ClassBayesNet< GUM_SCALAR >::__init(), gum::prm::PRMInstance< GUM_SCALAR >::__instantiateSlotChain(), 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::SVED< GUM_SCALAR >::_marginal(), gum::prm::SVE< GUM_SCALAR >::_marginal(), gum::prm::PRMInterface< double >::add(), gum::prm::PRMClass< double >::add(), gum::prm::PRMClass< double >::addArc(), gum::prm::PRMClass< double >::inheritAggregates(), gum::prm::PRMClassElement< double >::isParameter(), gum::prm::PRMClass< double >::overload(), gum::prm::PRMInterface< double >::overload(), and gum::prm::PRMFactory< GUM_SCALAR >::startAttribute().

52  {
53  return __id;
54  }
NodeId __id
The node&#39;s id of this element.
+ Here is the caller graph for this function:

◆ 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 128 of file PRMClassElement.h.

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::CData::CData().

128  {
129  return elt.elt_type() == prm_aggregate;
130  }
+ Here is the caller graph for this function:

◆ 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 123 of file PRMClassElement.h.

123  {
124  return elt.elt_type() == prm_attribute;
125  }

◆ isClass()

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

Returns true if obj_ptr is of type Class.

Definition at line 99 of file PRMObject.h.

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

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

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

◆ isInstance()

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 109 of file PRMObject.h.

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

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

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 104 of file PRMObject.h.

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

104  {
105  return obj.obj_type() == prm_type::PRM_INTERFACE;
106  }
+ Here is the call graph for this function:

◆ 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 138 of file PRMClassElement.h.

138  {
139  return elt.elt_type() == prm_parameter;
140  }

◆ 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 118 of file PRMClassElement.h.

118  {
119  return elt.elt_type() == prm_refslot;
120  }

◆ 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 133 of file PRMClassElement.h.

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

133  {
134  return elt.elt_type() == prm_slotchain;
135  }
+ Here is the caller graph for this function:

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

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

76 { 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 32 of file PRMObject_inl.h.

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

Referenced by gum::prm::SVE< GUM_SCALAR >::__addDelayedVariable(), gum::prm::PRMClass< double >::__addIOInterfaceFlags(), 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::PRMInstance< GUM_SCALAR >::__copyAggregates(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttribute(), gum::prm::PRMSlotChain< double >::__copyLastElt(), gum::prm::PRMSystem< double >::__groundAttr(), gum::prm::PRMSystem< double >::__groundPotential(), gum::prm::PRMSystem< double >::__groundRef(), gum::prm::PRMClass< double >::__inheritClass(), 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::__print_attribute__(), gum::prm::__print_instance__(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::__str(), gum::prm::StructuredInference< GUM_SCALAR >::__str(), gum::prm::PRMInterface< double >::add(), gum::prm::PRMSystem< double >::add(), gum::prm::PRMClass< double >::add(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::PRMFormAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMFormAttribute< GUM_SCALAR >::copy(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), gum::prm::o3prmr::O3prmrInterpreter::findAttributeName(), gum::prm::o3prmr::O3prmrInterpreter::findInstanceName(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMClass< double >::inheritAggregates(), 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::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(), and gum::prm::PRMAggregate< double >::str2enum().

32 { return __name; }
std::string __name
Definition: PRMObject.h:197

◆ 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 wath you are doing !

Definition at line 36 of file PRMObject_inl.h.

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

36 { __name = name; }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
std::string __name
Definition: PRMObject.h:197
+ Here is the call graph for this function:

◆ newFactory()

template<typename GUM_SCALAR >
PRMAttribute< GUM_SCALAR > * gum::prm::PRMScalarAttribute< GUM_SCALAR >::newFactory ( const PRMClass< GUM_SCALAR > &  c) const
virtualinherited

See gum::PRMClassElement::elt_type().

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

Definition at line 69 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::cpf(), gum::prm::PRMObject::name(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::type().

70  {
71  auto impl = static_cast< MultiDimImplementation< GUM_SCALAR >* >(
72  this->cpf().content()->newFactory());
73  return new PRMScalarAttribute< GUM_SCALAR >(
74  this->name(), this->type(), impl);
75  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
virtual PRMType & type()
See gum::PRMClassElement::type().
virtual const Potential< GUM_SCALAR > & cpf() const
See gum::PRMClassElement::cpf().
+ 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 57 of file PRMClassElement_tpl.h.

Referenced by gum::prm::PRMClassElement< double >::isParameter().

+ Here is the caller graph for this function:

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

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

46  {
47  return __name != obj.name();
48  }
std::string __name
Definition: PRMObject.h:197
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

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

Copy operator. Don't use it.

Definition at line 66 of file PRMFuncAttribute_tpl.h.

References GUM_ERROR.

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

66  {
67  GUM_ERROR(FatalError, "illegal call to copy operator");
68  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ Here is the caller graph for this function:

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

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

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

40  {
41  return __name == obj.name();
42  }
std::string __name
Definition: PRMObject.h:197
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ overload()

template<typename GUM_SCALAR>
void gum::prm::PRMAttribute< GUM_SCALAR >::overload ( PRMAttribute< GUM_SCALAR > *  source)
virtualinherited

Set this as overload of source (necessayr to preserver internal pointers for MultiDims).

Definition at line 50 of file PRMAttribute_tpl.h.

Referenced by gum::prm::PRMInterface< double >::__overloadAttribute(), and gum::prm::PRMClass< double >::__overloadAttribute().

50  {
51  auto old_type = this->_type();
52  this->_type(source->_type());
53  source->_type(old_type);
54  }
virtual PRMType * _type()=0
+ Here is the caller 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 77 of file PRMObject.h.

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

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

◆ 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 67 of file PRMClassElement_tpl.h.

Referenced by gum::prm::PRMClass< double >::__addCastDescendants(), gum::prm::PRMInterface< double >::__addCastDescendants(), gum::prm::PRMFactory< GUM_SCALAR >::__addParent(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttributeCPF(), gum::prm::SVED< GUM_SCALAR >::__getAggPotential(), gum::prm::PRMSystem< double >::__groundPotential(), gum::prm::PRMSystem< double >::__groundRef(), gum::prm::PRMClass< double >::__inheritClass(), gum::prm::PRMClass< double >::__overloadAggregate(), 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::__print_attribute__(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::__str(), gum::prm::StructuredInference< GUM_SCALAR >::__str(), gum::prm::PRMClassElementContainer< double >::_getIOFlag(), gum::prm::PRMClassElementContainer< double >::_setIOFlag(), gum::prm::PRMInterface< double >::add(), gum::prm::PRMClass< double >::add(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::PRMFactory< GUM_SCALAR >::addAttribute(), gum::prm::PRMClassElementContainer< double >::belongsTo(), gum::prm::PRMClass< double >::inheritAggregates(), gum::prm::PRMClassElement< double >::isParameter(), gum::prm::PRMClassElementContainer< double >::setInputNode(), and gum::prm::PRMClassElementContainer< double >::setOutputNode().

67  {
68  return _safeName;
69  }
std::string _safeName
The safe name of this PRMClassElement.
+ Here is the caller graph for this function:

◆ setAsCastDescendant()

template<typename GUM_SCALAR >
void gum::prm::PRMScalarAttribute< GUM_SCALAR >::setAsCastDescendant ( PRMAttribute< GUM_SCALAR > *  attr)
virtualinherited

See gum::PRMClassElement::elt_type().

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

Definition at line 193 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMAttribute< GUM_SCALAR >::becomeCastDescendant(), GUM_ERROR, gum::prm::PRMType::name(), gum::prm::PRMType::setSuper(), gum::prm::PRMAttribute< GUM_SCALAR >::type(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::type().

194  {
195  try {
196  type().setSuper(cast->type());
197  } catch (OperationNotAllowed&) {
198  GUM_ERROR(OperationNotAllowed,
199  "this ScalarAttribute can not have cast descendant");
200  } catch (WrongType&) {
201  std::stringstream msg;
202  msg << type().name() << " is not a subtype of " << cast->type().name();
203  GUM_ERROR(WrongType, msg.str());
204  }
205  cast->becomeCastDescendant(type());
206  }
const std::string & name() const
Returns the name of this object.
Definition: PRMType_inl.h:65
void setSuper(PRMType &t)
Changes the PRMType of this PRMType super.
Definition: PRMType_inl.h:77
virtual PRMType & type()
See gum::PRMClassElement::type().
virtual std::string cast(const PRMType &t) const
Returns the name of the cast descendant with PRMType t of this PRMClassElement.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ Here is the call graph for this function:

◆ 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 62 of file PRMClassElement_tpl.h.

Referenced by gum::prm::PRMClass< double >::__addCastDescendants(), gum::prm::PRMInterface< double >::__addCastDescendants(), gum::prm::PRMClass< double >::__checkInterface(), gum::prm::PRMClass< double >::__checkRefInterface(), gum::prm::PRMSlotChain< double >::__copyLastElt(), gum::prm::PRMClass< double >::__inheritClass(), gum::prm::PRMInterface< double >::__inheritInterface(), 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::PRMInterface< double >::add(), gum::prm::PRMClass< double >::add(), gum::prm::PRMClass< double >::inheritAggregates(), gum::prm::PRMClass< double >::inheritParameters(), gum::prm::PRMClass< double >::inheritReferenceSlots(), gum::prm::PRMClass< double >::inheritSlotChains(), and gum::prm::PRMClassElement< double >::isParameter().

62  {
63  __id = id;
64  }
NodeId id() const
Returns the NodeId of this element in it&#39;s class DAG.
NodeId __id
The node&#39;s id of this element.
+ Here is the caller graph for this function:

◆ swap()

template<typename GUM_SCALAR >
void gum::prm::PRMScalarAttribute< GUM_SCALAR >::swap ( const PRMType old_type,
const PRMType new_type 
)
virtualinherited

Swap old_type with new_type in the PRMClassElement cpt.

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

Definition at line 228 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::__cpf, gum::prm::PRMScalarAttribute< GUM_SCALAR >::__type, gum::DiscreteVariable::domainSize(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::prm::PRMType::name(), gum::Instantiation::setFirst(), and gum::prm::PRMType::variable().

229  {
230  if (&(old_type) == __type) {
231  GUM_ERROR(OperationNotAllowed, "Cannot replace attribute own type");
232  }
233  if (old_type->domainSize() != new_type->domainSize()) {
234  GUM_ERROR(OperationNotAllowed,
235  "Cannot replace types with difference domain size");
236  }
237  if (!__cpf->contains(old_type.variable())) {
238  GUM_ERROR(NotFound, "could not find variable " + old_type.name());
239  }
240 
241  auto old = __cpf;
242 
243  __cpf = new Potential< GUM_SCALAR >();
244 
245  for (auto var : old->variablesSequence()) {
246  if (var != &(old_type.variable())) {
247  __cpf->add(*var);
248  } else {
249  __cpf->add(new_type.variable());
250  }
251  }
252 
253  Instantiation inst(__cpf), jnst(old);
254 
255  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
256  inst.inc(), jnst.inc()) {
257  __cpf->set(inst, old->get(jnst));
258  }
259 
260  delete old;
261 
262  GUM_ASSERT(inst.end() && jnst.end());
263  GUM_ASSERT(__cpf->contains(__type->variable()));
264  GUM_ASSERT(__cpf->contains(new_type.variable()));
265  GUM_ASSERT(!__cpf->contains(old_type.variable()));
266  }
PRMType * __type
The random variable type of this attribute.
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ Here is the call graph for this function:

◆ type() [1/2]

template<typename GUM_SCALAR >
INLINE PRMType & gum::prm::PRMScalarAttribute< GUM_SCALAR >::type ( )
virtualinherited

◆ type() [2/2]

template<typename GUM_SCALAR >
INLINE const PRMType & gum::prm::PRMScalarAttribute< GUM_SCALAR >::type ( ) const
virtualinherited

See gum::PRMClassElement::type().

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

Definition at line 134 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::__type.

134  {
135  return *__type;
136  }
PRMType * __type
The random variable type of this attribute.

Member Data Documentation

◆ _safeName

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

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