aGrUM  0.13.2
gum::prm::PRMScalarAttribute< GUM_SCALAR > Class Template Reference

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

#include <PRMScalarAttribute.h>

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

Public Member Functions

Constructor & destructor.
 PRMScalarAttribute (const std::string &name, const PRMType< GUM_SCALAR > &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
 Constructor used by gum::Class. More...
 
virtual ~PRMScalarAttribute ()
 Destructor. 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 PRMType< GUM_SCALAR > & type ()
 See gum::PRMClassElement::type(). More...
 
virtual const PRMType< GUM_SCALAR > & type () const
 See gum::PRMClassElement::type(). More...
 
virtual const Potential< GUM_SCALAR > & cpf () const
 See gum::PRMClassElement::cpf(). 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...
 
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< GUM_SCALAR > &subtype)
 See gum::PRMClassElement::elt_type(). More...
 
virtual void swap (const PRMType< GUM_SCALAR > &old_type, const PRMType< GUM_SCALAR > &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< GUM_SCALAR > &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

 PRMScalarAttribute (const PRMScalarAttribute &source)
 Copy constructor. Don't use it. More...
 
PRMScalarAttributeoperator= (const PRMScalarAttribute &from)
 Copy operator. Don't use it. More...
 
virtual PRMType< GUM_SCALAR > * _type ()
 
virtual void _type (PRMType< GUM_SCALAR > *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 &elt)
 Returns true if obj_ptr is of type PRMReferenceSlot. More...
 
static INLINE bool isAttribute (const PRMClassElement &elt)
 Returns true if obj_ptr is of type PRMAttribute. More...
 
static INLINE bool isAggregate (const PRMClassElement &elt)
 Return true if obj is of type PRMAggregate. More...
 
static INLINE bool isSlotChain (const PRMClassElement &elt)
 Return true if obj is of type PRMSlotChain. More...
 
static INLINE bool isParameter (const PRMClassElement &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::PRMScalarAttribute< GUM_SCALAR >

<agrum/PRM/elements/scalarAttribute.h>

PRMScalarAttribute is a member of a Class in a PRM.

A PRMScalarAttribute is defined by its name, its containing class, its type and by a Conditional Probability Function (aka CPF but represented by a Potential).

An attribute in a PRM is the equivalent of a random variable in a bayesian network.

This class is constructed by a gum::PRMFactory and is deleted by its gum::Class.

Built-in copies (copy constructor and copy operator) are illegal due to various problems raised by redondant information.

See also
PRM PRMFactory Class PRMClassElement PRMType<GUM_SCALAR> Potential

Definition at line 60 of file PRMScalarAttribute.h.

Member Enumeration Documentation

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

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

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

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

Enumerator
ALL 
CLASS 
PRM_INTERFACE 
CLASS_ELT 
TYPE 
SYSTEM 
INSTANCE 

Definition at line 66 of file PRMObject.h.

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

Constructor & Destructor Documentation

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

Constructor used by gum::Class.

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

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

Definition at line 38 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::__cpf, gum::prm::PRMScalarAttribute< GUM_SCALAR >::__type, gum::prm::PRMClassElement< GUM_SCALAR >::_safeName, gum::prm::PRMObject::LEFT_CAST(), gum::prm::PRMObject::name(), and gum::prm::PRMObject::RIGHT_CAST().

41  :
42  PRMAttribute< GUM_SCALAR >(name),
43  __type(new PRMType< GUM_SCALAR >(type)),
44  __cpf(new Potential< GUM_SCALAR >(impl)) {
45  GUM_CONSTRUCTOR(PRMScalarAttribute);
46  __cpf->add(__type->variable());
47 
48  this->_safeName =
50  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
PRMType< GUM_SCALAR > * __type
The random variable type of this attribute.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:76
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
PRMScalarAttribute(const std::string &name, const PRMType< GUM_SCALAR > &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
Constructor used by gum::Class.
virtual PRMType< GUM_SCALAR > & type()
See gum::PRMClassElement::type().
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:77
std::string _safeName
The safe name of this PRMClassElement.

+ Here is the call graph for this function:

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

Destructor.

Definition at line 63 of file PRMScalarAttribute_tpl.h.

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::__cpf, and gum::prm::PRMScalarAttribute< GUM_SCALAR >::__type.

63  {
64  GUM_DESTRUCTOR(PRMScalarAttribute);
65  delete __cpf;
66  delete __type;
67  }
PRMType< GUM_SCALAR > * __type
The random variable type of this attribute.
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
PRMScalarAttribute(const std::string &name, const PRMType< GUM_SCALAR > &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
Constructor used by gum::Class.
template<typename GUM_SCALAR >
gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute ( const PRMScalarAttribute< GUM_SCALAR > &  source)
protected

Copy constructor. Don't use it.

Definition at line 53 of file PRMScalarAttribute_tpl.h.

References GUM_ERROR.

54  :
55  PRMAttribute< GUM_SCALAR >(source),
56  __type(0), __cpf(0) {
57  GUM_CONS_CPY(PRMScalarAttribute);
58  GUM_ERROR(FatalError,
59  "Illegal call to the copy constructor of gum::ScalarAttribute");
60  }
PRMType< GUM_SCALAR > * __type
The random variable type of this attribute.
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
PRMScalarAttribute(const std::string &name, const PRMType< GUM_SCALAR > &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
Constructor used by gum::Class.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

Member Function Documentation

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

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

Definition at line 276 of file PRMScalarAttribute_tpl.h.

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

276  {
277  return __type;
278  }
PRMType< GUM_SCALAR > * __type
The random variable type of this attribute.
template<typename GUM_SCALAR >
void gum::prm::PRMScalarAttribute< GUM_SCALAR >::_type ( PRMType< GUM_SCALAR > *  t)
protectedvirtual

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

Definition at line 281 of file PRMScalarAttribute_tpl.h.

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

281  {
282  if (__type->variable().domainSize() != t->variable().domainSize()) {
283  GUM_ERROR(OperationNotAllowed,
284  "Cannot replace types with difference domain size");
285  }
286  auto old = __cpf;
287 
288  __cpf = new Potential< GUM_SCALAR >();
289 
290  for (auto var : old->variablesSequence()) {
291  if (var != &(__type->variable())) {
292  __cpf->add(*var);
293  } else {
294  __cpf->add(t->variable());
295  }
296  }
297 
298  Instantiation inst(__cpf), jnst(old);
299 
300  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
301  inst.inc(), jnst.inc()) {
302  __cpf->set(inst, old->get(jnst));
303  }
304 
305  delete old;
306 
307  __type = t;
308 
309  GUM_ASSERT(__cpf->contains(__type->variable()));
310  GUM_ASSERT(inst.end() && jnst.end());
311  }
PRMType< GUM_SCALAR > * __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:66

+ Here is the call graph for this function:

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

See gum::PRMClassElement::_addChild().

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

Reimplemented in gum::prm::PRMFuncAttribute< GUM_SCALAR >.

Definition at line 165 of file PRMScalarAttribute_tpl.h.

166  {}
template<typename GUM_SCALAR >
INLINE void gum::prm::PRMScalarAttribute< GUM_SCALAR >::addParent ( const PRMClassElement< GUM_SCALAR > &  elt)
virtual

See gum::PRMClassElement::_addParent().

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

Reimplemented in gum::prm::PRMFuncAttribute< GUM_SCALAR >.

Definition at line 147 of file PRMScalarAttribute_tpl.h.

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

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

148  {
149  try {
150  __cpf->add(elt.type().variable());
151  } catch (DuplicateElement&) {
152  std::stringstream msg;
153  msg << ": " << elt.name() << " as parent of " << this->name();
154  GUM_ERROR(DuplicateElement, msg.str());
155  } catch (OperationNotAllowed&) {
156  std::stringstream msg;
157  msg << ": " << elt.name() << " of wrong type as parent of "
158  << this->name();
159  GUM_ERROR(OperationNotAllowed, msg.str());
160  }
161  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

See gum::PRMClassElement::elt_type().

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

Definition at line 214 of file PRMScalarAttribute_tpl.h.

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

215  {
216  delete __cpf;
217  __cpf = new Potential< GUM_SCALAR >();
218  __cpf->add(type().variable());
219  __cpf->add(subtype.variable());
220 
221  Instantiation inst(*__cpf);
222 
223  for (inst.setFirst(); !inst.end(); inst.inc()) {
224  auto my_pos = inst.pos(subtype.variable());
225  if (subtype.label_map()[my_pos] == inst.pos(type().variable())) {
226  __cpf->set(inst, 1);
227  } else {
228  __cpf->set(inst, 0);
229  }
230  }
231  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
virtual PRMType< GUM_SCALAR > & type()
See gum::PRMClassElement::type().

+ Here is the call graph for this function:

template<typename GUM_SCALAR>
INLINE std::string gum::prm::PRMClassElement< GUM_SCALAR >::cast ( const PRMType< GUM_SCALAR > &  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.

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

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

71  {
72  if (type().isSubTypeOf(t)) {
73  return PRMObject::LEFT_CAST() + t.name() + PRMObject::RIGHT_CAST()
74  + name();
75  } else {
76  GUM_ERROR(OperationNotAllowed, "illegal cast");
77  }
78  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
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
virtual PRMType< GUM_SCALAR > & type()=0
Return a reference over the gum::PRMType of this class element.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

See gum::PRMClassElement::elt_type().

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

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

80  {
81  auto copy = new PRMScalarAttribute< GUM_SCALAR >(this->name(), this->type());
82 
83  if (!bij.existsFirst(&(type().variable()))) {
84  bij.insert(&(type().variable()), &(copy->type().variable()));
85  }
86 
87  delete copy->__cpf;
88  copy->__cpf = copyPotential(bij, cpf());
89 
90  return copy;
91  }
virtual PRMAttribute< GUM_SCALAR > * copy(Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const
See gum::PRMClassElement::elt_type().
virtual const Potential< GUM_SCALAR > & cpf() const
See gum::PRMClassElement::cpf().
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
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 PRMType< GUM_SCALAR > & type()
See gum::PRMClassElement::type().

+ Here is the call graph for this function:

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

See gum::PRMClassElement::elt_type().

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

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

96  {
97  delete __cpf;
98  __cpf = new Potential< GUM_SCALAR >();
99 
100  for (auto var : source.cpf().variablesSequence()) {
101  __cpf->add(*(bij.second(var)));
102  }
103 
104  Instantiation inst(*__cpf), jnst(source.cpf());
105 
106  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
107  inst.inc(), jnst.inc()) {
108  __cpf->set(inst, source.cpf().get(jnst));
109  }
110 
111  GUM_ASSERT(inst.end() && jnst.end());
112  GUM_ASSERT(__cpf->contains(__type->variable()));
113  GUM_ASSERT(!__cpf->contains(source.type().variable()));
114  }
PRMType< GUM_SCALAR > * __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:

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

See gum::PRMClassElement::cpf().

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

Definition at line 142 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< GUM_SCALAR >::getCastDescendant(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::newFactory().

142  {
143  return *__cpf;
144  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.

+ Here is the caller graph for this function:

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

See gum::PRMClassElement::elt_type().

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

Definition at line 125 of file PRMScalarAttribute_tpl.h.

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

125  {
126  return this->prm_attribute;
127  }
static std::string gum::prm::PRMObject::enum2str ( prm_type  type)
inlinestaticinherited

Returns the string representation of a PRMObject.

Definition at line 80 of file PRMObject.h.

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

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

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

+ Here is the caller graph for this function:

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

Returns true if obj_ptr is of type PRMReferenceSlot.

Definition at line 98 of file PRMClassElement.h.

98  {
99  switch (type) {
100  case prm_attribute: return "prm_attribute";
101 
102  case prm_aggregate: return "prm_aggregate";
103 
104  case prm_refslot: return "prm_refslot";
105 
106  case prm_slotchain: return "prm_slotchain";
107 
108  case prm_parameter: return "prm_parameter";
109 
110  default: return "unknown";
111  }
112  }
virtual PRMType< GUM_SCALAR > & type()=0
Return a reference over the gum::PRMType of this class element.
template<typename GUM_SCALAR >
PRMAttribute< GUM_SCALAR > * gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant ( ) const
virtual

See gum::PRMClassElement::elt_type().

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

Definition at line 170 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::PRMObject::name(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::type().

170  {
171  PRMScalarAttribute< GUM_SCALAR >* cast = 0;
172 
173  try {
174  cast =
175  new PRMScalarAttribute< GUM_SCALAR >(this->name(), type().superType());
176  } catch (NotFound&) {
177  GUM_ERROR(OperationNotAllowed,
178  "this ScalarAttribute can not have cast descendant");
179  }
180 
181  cast->addParent(*this);
182  const DiscreteVariable& my_var = type().variable();
183  DiscreteVariable& cast_var = cast->type().variable();
184  Instantiation inst(cast->cpf());
185 
186  for (inst.setFirst(); !inst.end(); inst.inc()) {
187  if (type().label_map()[inst.val(my_var)] == inst.val(cast_var)) {
188  cast->cpf().set(inst, 1);
189  } else {
190  cast->cpf().set(inst, 0);
191  }
192  }
193 
194  return cast;
195  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
virtual std::string cast(const PRMType< GUM_SCALAR > &t) const
Returns the name of the cast descendant with PRMType t of this PRMClassElement.
virtual PRMType< GUM_SCALAR > & type()
See gum::PRMClassElement::type().
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

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

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

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__addCastDescendants(), gum::prm::PRMInterface< GUM_SCALAR >::__addCastDescendants(), gum::prm::PRMClass< GUM_SCALAR >::__checkInterface(), gum::prm::PRMClass< GUM_SCALAR >::__checkRefInterface(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAggregates(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttribute(), gum::prm::PRMSlotChain< GUM_SCALAR >::__copyLastElt(), gum::prm::SVE< GUM_SCALAR >::__getAggPotential(), gum::prm::PRMSystem< GUM_SCALAR >::__groundPotential(), gum::prm::PRMClass< GUM_SCALAR >::__inheritClass(), gum::prm::InstanceBayesNet< GUM_SCALAR >::__init(), gum::prm::ClassBayesNet< GUM_SCALAR >::__init(), gum::prm::PRMInstance< GUM_SCALAR >::__instantiateSlotChain(), gum::prm::PRMInterface< GUM_SCALAR >::__overloadAttribute(), gum::prm::PRMClass< GUM_SCALAR >::__overloadAttribute(), gum::prm::PRMClass< GUM_SCALAR >::__overloadParameter(), gum::prm::PRMClass< GUM_SCALAR >::__overloadReference(), gum::prm::PRMInterface< GUM_SCALAR >::__overloadReferenceSlot(), gum::prm::SVED< GUM_SCALAR >::_marginal(), gum::prm::SVE< GUM_SCALAR >::_marginal(), gum::prm::PRMInterface< GUM_SCALAR >::add(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMClass< GUM_SCALAR >::addArc(), gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates(), gum::prm::PRMClassElement< double >::isParameter(), gum::prm::PRMClass< GUM_SCALAR >::overload(), gum::prm::PRMInterface< GUM_SCALAR >::overload(), gum::prm::PRMClassElement< GUM_SCALAR >::setId(), and gum::prm::PRMFactory< GUM_SCALAR >::startAttribute().

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

+ Here is the caller graph for this function:

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

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

125  {
126  return elt.elt_type() == prm_aggregate;
127  }

+ Here is the caller graph for this function:

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

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

120  {
121  return elt.elt_type() == prm_attribute;
122  }

+ Here is the caller graph for this function:

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

Returns true if obj_ptr is of type Class.

Definition at line 99 of file PRMObject.h.

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

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 109 of file PRMObject.h.

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

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

+ Here is the call graph for this function:

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 104 of file PRMObject.h.

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

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

+ Here is the call graph for this function:

template<typename GUM_SCALAR>
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 135 of file PRMClassElement.h.

135  {
136  return elt.elt_type() == prm_parameter;
137  }
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 115 of file PRMClassElement.h.

115  {
116  return elt.elt_type() == prm_refslot;
117  }
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 130 of file PRMClassElement.h.

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

130  {
131  return elt.elt_type() == prm_slotchain;
132  }

+ Here is the caller graph for this function:

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

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

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

Definition at line 76 of file PRMObject.h.

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

76 { return "("; }

+ Here is the caller graph for this function:

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

Returns the name of this object.

Definition at line 32 of file PRMObject_inl.h.

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

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

32 { return __name; }
std::string __name
Definition: PRMObject.h:197
INLINE void gum::prm::PRMObject::name ( const std::string &  name)
inherited

Change the name of the PRM Object.

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

Definition at line 36 of file PRMObject_inl.h.

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

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

+ Here is the call graph for this function:

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

See gum::PRMClassElement::elt_type().

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

Definition at line 70 of file PRMScalarAttribute_tpl.h.

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

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

+ Here is the call graph for this function:

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

References gum::prm::PRMObject::CLASS_ELT.

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

+ Here is the caller graph for this function:

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

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

Definition at line 46 of file PRMObject_inl.h.

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

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Copy operator. Don't use it.

Definition at line 118 of file PRMScalarAttribute_tpl.h.

References GUM_ERROR.

Referenced by gum::prm::PRMScalarAttribute< GUM_SCALAR >::copyCpf().

118  {
119  GUM_ERROR(FatalError,
120  "Illegal call to the copy operator of gum::ScalarAttribute");
121  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the caller graph for this function:

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

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

Definition at line 40 of file PRMObject_inl.h.

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

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename GUM_SCALAR>
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 49 of file PRMAttribute_tpl.h.

References gum::prm::PRMAttribute< GUM_SCALAR >::_type().

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

49  {
50  auto old_type = this->_type();
51  this->_type(source->_type());
52  source->_type(old_type);
53  }
virtual PRMType< GUM_SCALAR > * _type()=0

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

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

Definition at line 77 of file PRMObject.h.

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

77 { return ")"; }

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
INLINE 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 65 of file PRMClassElement_tpl.h.

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

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

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

+ Here is the caller graph for this function:

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

See gum::PRMClassElement::elt_type().

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

Definition at line 198 of file PRMScalarAttribute_tpl.h.

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

199  {
200  try {
201  type().setSuper(cast->type());
202  } catch (OperationNotAllowed&) {
203  GUM_ERROR(OperationNotAllowed,
204  "this ScalarAttribute can not have cast descendant");
205  } catch (WrongType&) {
206  std::stringstream msg;
207  msg << type().name() << " is not a subtype of " << cast->type().name();
208  GUM_ERROR(WrongType, msg.str());
209  }
210  cast->becomeCastDescendant(type());
211  }
virtual std::string cast(const PRMType< GUM_SCALAR > &t) const
Returns the name of the cast descendant with PRMType t of this PRMClassElement.
virtual PRMType< GUM_SCALAR > & type()
See gum::PRMClassElement::type().
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

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

Used to assign the id of this element.

Definition at line 60 of file PRMClassElement_tpl.h.

References gum::prm::PRMClassElement< GUM_SCALAR >::__id, and gum::prm::PRMClassElement< GUM_SCALAR >::id().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::__addCastDescendants(), gum::prm::PRMInterface< GUM_SCALAR >::__addCastDescendants(), gum::prm::PRMClass< GUM_SCALAR >::__checkInterface(), gum::prm::PRMClass< GUM_SCALAR >::__checkRefInterface(), gum::prm::PRMSlotChain< GUM_SCALAR >::__copyLastElt(), gum::prm::PRMClass< GUM_SCALAR >::__inheritClass(), gum::prm::PRMInterface< GUM_SCALAR >::__inheritInterface(), gum::prm::PRMInterface< GUM_SCALAR >::__overloadAttribute(), gum::prm::PRMClass< GUM_SCALAR >::__overloadAttribute(), gum::prm::PRMClass< GUM_SCALAR >::__overloadParameter(), gum::prm::PRMClass< GUM_SCALAR >::__overloadReference(), gum::prm::PRMInterface< GUM_SCALAR >::__overloadReferenceSlot(), gum::prm::PRMInterface< GUM_SCALAR >::add(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates(), gum::prm::PRMClass< GUM_SCALAR >::inheritReferenceSlots(), and gum::prm::PRMClassElement< double >::isParameter().

60  {
61  __id = id;
62  }
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.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Swap old_type with new_type in the PRMClassElement cpt.

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

Definition at line 234 of file PRMScalarAttribute_tpl.h.

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

236  {
237  if (&(old_type) == __type) {
238  GUM_ERROR(OperationNotAllowed, "Cannot replace attribute own type");
239  }
240  if (old_type->domainSize() != new_type->domainSize()) {
241  GUM_ERROR(OperationNotAllowed,
242  "Cannot replace types with difference domain size");
243  }
244  if (!__cpf->contains(old_type.variable())) {
245  GUM_ERROR(NotFound, "could not find variable " + old_type.name());
246  }
247 
248  auto old = __cpf;
249 
250  __cpf = new Potential< GUM_SCALAR >();
251 
252  for (auto var : old->variablesSequence()) {
253  if (var != &(old_type.variable())) {
254  __cpf->add(*var);
255  } else {
256  __cpf->add(new_type.variable());
257  }
258  }
259 
260  Instantiation inst(__cpf), jnst(old);
261 
262  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
263  inst.inc(), jnst.inc()) {
264  __cpf->set(inst, old->get(jnst));
265  }
266 
267  delete old;
268 
269  GUM_ASSERT(inst.end() && jnst.end());
270  GUM_ASSERT(__cpf->contains(__type->variable()));
271  GUM_ASSERT(__cpf->contains(new_type.variable()));
272  GUM_ASSERT(!__cpf->contains(old_type.variable()));
273  }
PRMType< GUM_SCALAR > * __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:66

+ Here is the call graph for this function:

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

See gum::PRMClassElement::type().

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

Definition at line 136 of file PRMScalarAttribute_tpl.h.

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

136  {
137  return *__type;
138  }
PRMType< GUM_SCALAR > * __type
The random variable type of this attribute.

Member Data Documentation


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