aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
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.
virtual ~PRMFuncAttribute ()
 Destructor.
virtual void addParent (const PRMClassElement< GUM_SCALAR > &elt)
 See gum::PRMClassElement::addParent_().
virtual void addChild (const PRMClassElement< GUM_SCALAR > &elt)
 See gum::PRMClassElement::addChild_().
Getters & setters
virtual PRMAttribute< GUM_SCALAR > * newFactory (const PRMClass< GUM_SCALAR > &c) const
 See gum::PRMClassElement::elt_type().
virtual PRMAttribute< GUM_SCALAR > * copy (Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const
 See gum::PRMClassElement::elt_type().
virtual void copyCpf (const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bif, const PRMAttribute< GUM_SCALAR > &source)
 See gum::PRMClassElement::elt_type().
virtual PRMClassElement< GUM_SCALAR >::ClassElementType elt_type () const
 See gum::PRMClassElement::elt_type().
virtual PRMTypetype ()
 See gum::PRMClassElement::type().
virtual const PRMTypetype () const
 See gum::PRMClassElement::type().
virtual const Tensor< GUM_SCALAR > & cpf () const
 See gum::PRMClassElement::cpf().
virtual PRMAttribute< GUM_SCALAR > * getCastDescendant () const
 See gum::PRMClassElement::elt_type().
virtual void setAsCastDescendant (PRMAttribute< GUM_SCALAR > *attr)
 See gum::PRMClassElement::elt_type().
virtual void becomeCastDescendant (PRMType &subtype)
 See gum::PRMClassElement::elt_type().
virtual void swap (const PRMType &old_type, const PRMType &new_type)
 Swap old_type with new_type in the PRMClassElement cpt.
Getters & setters
virtual void overload (PRMAttribute< GUM_SCALAR > *source)
 Set this as overload of source (necessayr to preserver internal pointers for MultiDims).
Getters & setters
NodeId id () const
 Returns the NodeId of this element in it's class DAG.
virtual void setId (NodeId id)
 Used to assign the id of this element.
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.
virtual std::string cast (const PRMType &t) const
 Returns the name of the cast descendant with PRMType t of this PRMClassElement.
Getters & setters.
const std::string & name () const
 Returns the name of this object.
void name (const std::string &name)
 Change the name of the PRM Object.
Operators
bool operator== (const PRMObject &obj) const
 To PRMObject are equal if they have the same name (which is unique).
bool operator!= (const PRMObject &obj) const
 To PRMObject are equal if they have the same name (which is unique).

Protected Member Functions

 PRMFuncAttribute (const PRMFuncAttribute< GUM_SCALAR > &source)
 Copy constructor. Don't use it.
PRMFuncAttribute< GUM_SCALAR > & operator= (const PRMFuncAttribute< GUM_SCALAR > &from)
 Copy operator. Don't use it.
virtual void setCpf_ (Tensor< GUM_SCALAR > *cpf)
virtual PRMTypetype_ ()
virtual void type_ (PRMType *t)

Protected Attributes

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

Private Attributes

NodeId _id_
 The node's id of this element.
Private members
PRMType_type_
 The random variable type of this attribute.
Tensor< GUM_SCALAR > * _cpf_
 A pointer on the Tensor of this attribute.
Private members.
std::string _name_

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.
static INLINE bool isReferenceSlot (const PRMClassElement< GUM_SCALAR > &elt)
 Returns true if obj_ptr is of type PRMReferenceSlot.
static INLINE bool isAttribute (const PRMClassElement< GUM_SCALAR > &elt)
 Returns true if obj_ptr is of type PRMAttribute.
static INLINE bool isAggregate (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMAggregate.
static INLINE bool isSlotChain (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMSlotChain.
static INLINE bool isParameter (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMParameter.

Built-in types.

enum class  prm_type : char {
  ALL , CLASS , PRM_INTERFACE , CLASS_ELT ,
  TYPE , SYSTEM , 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.
static std::string LEFT_CAST ()
 Enumeration of the different types of objects handled by a PRM.
static std::string RIGHT_CAST ()
 Enumeration of the different types of objects handled by a PRM.
static INLINE bool isClass (const PRMObject &obj)
 Returns true if obj_ptr is of type Class.
static INLINE bool isInterface (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInterface.
static INLINE bool isInstance (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInstance.

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

◆ prm_type

enum class 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 88 of file PRMObject.h.

88: char { ALL, CLASS, PRM_INTERFACE, CLASS_ELT, TYPE, SYSTEM, INSTANCE };

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 Tensor of this PRMFuncAttribute. it will be deleted after the call of ~PRMFuncAttribute.

Definition at line 54 of file PRMFuncAttribute_tpl.h.

57 :
60 str << "In FuncAttribute(" << name << ", " << type.name() << ", " << impl << ")";
62 }
virtual PRMType & type()=0
See gum::PRMClassElement::type().
<agrum/PRM/elements/funcAttribute.h>
PRMFuncAttribute(const std::string &name, const PRMType &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
Constructor used by gum::Class.
const std::string & name() const
Returns the name of this object.
PRMScalarAttribute(const std::string &name, const PRMType &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
Constructor used by gum::Class.

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

Referenced by PRMFuncAttribute(), PRMFuncAttribute(), ~PRMFuncAttribute(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~PRMFuncAttribute()

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

Destructor.

Definition at line 65 of file PRMFuncAttribute_tpl.h.

References PRMFuncAttribute().

Here is the call graph for this function:

◆ 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 78 of file PRMFuncAttribute_tpl.h.

81 GUM_ERROR(FatalError, "illegal call to copy constructor")
82 }
#define GUM_ERROR(type, msg)
Definition exceptions.h:72

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

Here is the call graph for this function:

Member Function Documentation

◆ 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 74 of file PRMFuncAttribute_tpl.h.

74 {
75 }

◆ 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 71 of file PRMFuncAttribute_tpl.h.

71{}

◆ 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 218 of file PRMScalarAttribute_tpl.h.

218 {
219 delete _cpf_;
221 _cpf_->add(type().variable());
222 _cpf_->add(subtype.variable());
223
225
226 for (inst.setFirst(); !inst.end(); inst.inc()) {
227 auto my_pos = inst.pos(subtype.variable());
228 if (subtype.label_map()[my_pos] == inst.pos(type().variable())) {
229 _cpf_->set(inst, 1);
230 } else {
231 _cpf_->set(inst, 0);
232 }
233 }
234 }
<agrum/PRM/elements/scalarAttribute.h>
Tensor< GUM_SCALAR > * _cpf_
A pointer on the Tensor of this attribute.
virtual PRMType & type()
See gum::PRMClassElement::type().

References _cpf_, gum::Instantiation::end(), gum::Instantiation::inc(), gum::prm::PRMType::label_map(), gum::Instantiation::pos(), gum::Instantiation::setFirst(), type(), and gum::prm::PRMType::variable().

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

92 {
93 if (type().isSubTypeOf(t)) {
95 } else {
96 GUM_ERROR(OperationNotAllowed, "illegal cast")
97 }
98 }
Abstract class representing an element of PRM class.
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:90
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition PRMObject.h:92

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

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

Here is the call graph for this function:
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 97 of file PRMScalarAttribute_tpl.h.

98 {
99 auto copy = new PRMScalarAttribute< GUM_SCALAR >(this->name(), this->type());
100
101 if (!bij.existsFirst(&(type().variable()))) {
102 bij.insert(&(type().variable()), &(copy->type().variable()));
103 }
104
105 delete copy->_cpf_;
106 copy->_cpf_ = copyTensor(bij, cpf());
107
108 return copy;
109 }
virtual const Tensor< GUM_SCALAR > & cpf() const
See gum::PRMClassElement::cpf().
virtual PRMAttribute< GUM_SCALAR > * copy(Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const
See gum::PRMClassElement::elt_type().
Tensor< GUM_SCALAR > * copyTensor(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bij, const Tensor< GUM_SCALAR > &source)
Returns a copy of a Tensor after applying a bijection over the variables in source.

References gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), PRMScalarAttribute(), copy(), gum::prm::copyTensor(), cpf(), gum::BijectionImplementation< T1, T2, Gen >::existsFirst(), gum::BijectionImplementation< T1, T2, Gen >::insert(), gum::prm::PRMObject::name(), and type().

Referenced by copy().

Here is the call graph for this function:
Here is the caller 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 112 of file PRMScalarAttribute_tpl.h.

114 {
115 delete _cpf_;
117
118 for (auto var: source.cpf().variablesSequence()) {
119 _cpf_->add(*(bij.second(var)));
120 }
121
123
124 for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end()); inst.inc(), jnst.inc()) {
125 _cpf_->set(inst, source.cpf().get(jnst));
126 }
127
128 GUM_ASSERT(inst.end() && jnst.end());
129 GUM_ASSERT(_cpf_->contains(_type_->variable()));
130 GUM_ASSERT(!_cpf_->contains(source.type().variable()));
131 }
PRMType * _type_
The random variable type of this attribute.
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
Definition PRMType_inl.h:64

References gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), _cpf_, _type_, gum::prm::PRMAttribute< GUM_SCALAR >::cpf(), gum::Instantiation::end(), gum::Instantiation::inc(), gum::BijectionImplementation< T1, T2, Gen >::second(), gum::Instantiation::setFirst(), gum::prm::PRMAttribute< GUM_SCALAR >::type(), and gum::prm::PRMType::variable().

Here is the call graph for this function:

◆ cpf()

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

See gum::PRMClassElement::cpf().

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

Definition at line 156 of file PRMScalarAttribute_tpl.h.

156 {
157 return *_cpf_;
158 }

References _cpf_.

Referenced by copy(), newFactory(), and gum::prm::PRMFuncAttribute< GUM_SCALAR >::setCpf_().

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 141 of file PRMScalarAttribute_tpl.h.

141 {
142 return this->prm_attribute;
143 }

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

◆ enum2str() [1/2]

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

Returns true if obj_ptr is of type PRMReferenceSlot.

Definition at line 117 of file PRMClassElement.h.

117 {
118 switch (type) {
119 case prm_attribute : return "prm_attribute";
120
121 case prm_aggregate : return "prm_aggregate";
122
123 case prm_refslot : return "prm_refslot";
124
125 case prm_slotchain : return "prm_slotchain";
126
127 case prm_parameter : return "prm_parameter";
128
129 default : return "unknown";
130 }
131 }

References prm_aggregate, prm_attribute, prm_parameter, prm_refslot, prm_slotchain, and type().

Here is the call graph for this function:

◆ enum2str() [2/2]

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

Returns the string representation of a PRMObject.

Definition at line 95 of file PRMObject.h.

95 {
96 switch (type) {
97 case prm_type::CLASS : return "PRMType::CLASS";
98
99 case prm_type::CLASS_ELT : return "PRMType::CLASS_ELT";
100
101 case prm_type::TYPE : return "PRMType::TYPE";
102
103 case prm_type::SYSTEM : return "PRMType::SYSTEM";
104
105 case prm_type::INSTANCE : return "PRMType::INSTANCE";
106
107 case prm_type::PRM_INTERFACE : return "PRMType::PRM_INTERFACE";
108
109 default : return "unknown";
110 }
111 }

References CLASS, CLASS_ELT, INSTANCE, PRM_INTERFACE, SYSTEM, and TYPE.

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

Here is the caller graph for this function:

◆ 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 178 of file PRMScalarAttribute_tpl.h.

178 {
180
181 try {
183 } catch (NotFound const&) {
184 GUM_ERROR(OperationNotAllowed, "this ScalarAttribute can not have cast descendant")
185 }
186
187 cast->addParent(*this);
189 DiscreteVariable& cast_var = cast->type().variable();
190 Instantiation inst(cast->cpf());
191
192 for (inst.setFirst(); !inst.end(); inst.inc()) {
193 if (type().label_map()[inst.val(my_var)] == inst.val(cast_var)) {
194 cast->cpf().set(inst, 1);
195 } else {
196 cast->cpf().set(inst, 0);
197 }
198 }
199
200 return cast;
201 }
virtual std::string cast(const PRMType &t) const
Returns the name of the cast descendant with PRMType t of this PRMClassElement.

References gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), PRMScalarAttribute(), gum::prm::PRMClassElement< GUM_SCALAR >::cast(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::prm::PRMObject::name(), gum::Instantiation::setFirst(), type(), and gum::Instantiation::val().

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

72 {
73 return _id_;
74 }
NodeId _id_
The node's id of this element.

References _id_.

Referenced by PRMClassElement(), gum::prm::PRMSlotChain< double >::PRMSlotChain(), gum::prm::PRMClass< GUM_SCALAR >::_addCastDescendants_(), gum::prm::PRMClass< 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::SVE< GUM_SCALAR >::_getAggTensor_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_(), gum::prm::PRMSystem< double >::_groundTensor_(), gum::prm::ClassBayesNet< GUM_SCALAR >::_init_(), gum::prm::InstanceBayesNet< GUM_SCALAR >::_init_(), gum::prm::PRMInstance< GUM_SCALAR >::_instantiateSlotChain_(), 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::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMClass< GUM_SCALAR >::addArc(), gum::prm::PRMInterface< double >::addArc(), gum::prm::PRMInterface< double >::implementations(), gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates(), gum::prm::PRMClass< GUM_SCALAR >::overload(), gum::prm::SVE< GUM_SCALAR >::posterior_(), gum::prm::SVED< GUM_SCALAR >::posterior_(), setId(), and gum::prm::PRMFactory< GUM_SCALAR >::startAttribute().

Here is the caller graph for this function:

◆ isAggregate()

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

144 {
145 return elt.elt_type() == prm_aggregate;
146 }
virtual ClassElementType elt_type() const =0
Return the type of class element this object is.

References PRMClassElement(), elt_type(), and prm_aggregate.

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::CData::CData(), gum::prm::PRMClass< GUM_SCALAR >::_checkInterface_(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkLocalParent_(), gum::prm::ClassBayesNet< GUM_SCALAR >::_init_(), gum::prm::SVE< GUM_SCALAR >::_initLiftedNodes_(), gum::prm::SVED< GUM_SCALAR >::_initLiftedNodes_(), gum::prm::PRMClass< GUM_SCALAR >::completeInheritance(), gum::prm::PRMFactory< GUM_SCALAR >::continueAggregator(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode(), and gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAttribute()

◆ isClass()

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

Returns true if obj_ptr is of type Class.

Definition at line 114 of file PRMObject.h.

114{ return obj.obj_type() == prm_type::CLASS; }

References PRMObject(), CLASS, and obj_type().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInstance()

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 122 of file PRMObject.h.

122 {
123 return obj.obj_type() == prm_type::INSTANCE;
124 }

References PRMObject(), INSTANCE, and obj_type().

Here is the call graph for this function:

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 117 of file PRMObject.h.

117 {
118 return obj.obj_type() == prm_type::PRM_INTERFACE;
119 }

References PRMObject(), obj_type(), and PRM_INTERFACE.

Here is the call graph for this function:

◆ isParameter()

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

154 {
155 return elt.elt_type() == prm_parameter;
156 }

References PRMClassElement(), elt_type(), and prm_parameter.

Referenced by gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::_checkParameters_(), and gum::prm::PRMClass< GUM_SCALAR >::add().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isReferenceSlot()

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

134 {
135 return elt.elt_type() == prm_refslot;
136 }

References PRMClassElement(), elt_type(), and prm_refslot.

Referenced by gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::_checkAssignments_(), gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::_checkIncrements_(), gum::prm::o3prm::O3InterfaceFactory< GUM_SCALAR >::_checkOverloadLegality_(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkReferenceSlot_(), and gum::prm::PRMFactory< GUM_SCALAR >::setReferenceSlot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSlotChain()

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

149 {
150 return elt.elt_type() == prm_slotchain;
151 }

References PRMClassElement(), elt_type(), and prm_slotchain.

Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkLocalParent_(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveInputs_(), gum::prm::PRMClass< GUM_SCALAR >::add(), and gum::prm::PRMFactory< GUM_SCALAR >::addNoisyOrCompound().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LEFT_CAST()

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

90{ return "("; }

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

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

54{ return _name_; }
std::string _name_
Definition PRMObject.h:211

References _name_.

Referenced by gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), gum::prm::PRMClass< GUM_SCALAR >::PRMClass(), gum::prm::PRMClass< GUM_SCALAR >::PRMClass(), gum::prm::PRMClass< GUM_SCALAR >::PRMClass(), gum::prm::PRMClass< GUM_SCALAR >::PRMClass(), gum::prm::PRMClassElement< GUM_SCALAR >::PRMClassElement(), gum::prm::PRMClassElement< GUM_SCALAR >::PRMClassElement(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::PRMClassElementContainer(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMFuncAttribute< GUM_SCALAR >::PRMFuncAttribute(), gum::prm::PRMInstance< GUM_SCALAR >::PRMInstance(), gum::prm::PRMInterface< GUM_SCALAR >::PRMInterface(), gum::prm::PRMInterface< GUM_SCALAR >::PRMInterface(), gum::prm::PRMInterface< GUM_SCALAR >::PRMInterface(), PRMObject(), gum::prm::PRMParameter< GUM_SCALAR >::PRMParameter(), 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::PRMSlotChain< GUM_SCALAR >::PRMSlotChain(), gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain(), gum::prm::PRMSlotChain< double >::PRMSlotChain(), gum::prm::PRMSystem< GUM_SCALAR >::PRMSystem(), gum::prm::__print_attribute__(), gum::prm::__print_instance__(), 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::PRMSystem< GUM_SCALAR >::_groundAgg_(), gum::prm::PRMSystem< double >::_groundAgg_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_(), gum::prm::PRMSystem< double >::_groundTensor_(), 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::gspan::StrictSearch< GUM_SCALAR >::_str_(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::_str_(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::_str_(), gum::prm::StructuredInference< GUM_SCALAR >::_str_(), gum::prm::StructuredInference< GUM_SCALAR >::_str_(), gum::prm::StructuredInference< GUM_SCALAR >::_str_(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMInterface< GUM_SCALAR >::add(), gum::prm::PRMSystem< 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::PRMInstance< GUM_SCALAR >::exists(), gum::prm::PRMSystem< GUM_SCALAR >::exists(), gum::prm::o3prmr::O3prmrInterpreter::findAttributeName(), gum::prm::o3prmr::O3prmrInterpreter::findInstanceName(), gum::prm::PRMClass< GUM_SCALAR >::get(), gum::prm::PRMClass< GUM_SCALAR >::get(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::get(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::get(), gum::prm::PRMInstance< GUM_SCALAR >::get(), gum::prm::PRMInstance< GUM_SCALAR >::get(), gum::prm::PRMInterface< GUM_SCALAR >::get(), gum::prm::PRMInterface< GUM_SCALAR >::get(), gum::prm::PRMSystem< GUM_SCALAR >::get(), gum::prm::PRMSystem< GUM_SCALAR >::get(), gum::prm::PRMSystem< GUM_SCALAR >::getArray(), gum::prm::PRMSystem< GUM_SCALAR >::getArrayType(), gum::prm::PRMSystem< GUM_SCALAR >::getArrayType(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMSystem< GUM_SCALAR >::groundedBN(), gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates(), gum::prm::PRMSystem< double >::instantiate(), gum::prm::PRMSystem< GUM_SCALAR >::isArray(), gum::prm::PRMClass< GUM_SCALAR >::isCastDescendant(), gum::prm::PRMSystem< GUM_SCALAR >::isInstance(), name(), gum::prm::PRMType::name(), gum::prm::PRMFormAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::newFactory(), operator!=(), gum::prm::PRMClass< GUM_SCALAR >::operator=(), operator==(), gum::prm::PRMType::operator==(), gum::prm::PRMClass< GUM_SCALAR >::operator[](), gum::prm::PRMClass< GUM_SCALAR >::operator[](), gum::prm::PRMClassElementContainer< GUM_SCALAR >::operator[](), gum::prm::PRMClassElementContainer< GUM_SCALAR >::operator[](), gum::prm::PRMInterface< GUM_SCALAR >::operator[](), gum::prm::PRMClass< GUM_SCALAR >::overload(), gum::prm::PRMInterface< GUM_SCALAR >::overload(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::PRMClassElementContainterConstIterator, gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode(), gum::prm::PRMFactory< GUM_SCALAR >::startClass(), gum::prm::PRMFactory< GUM_SCALAR >::startInterface(), and gum::prm::PRMFactory< GUM_SCALAR >::startSystem().

◆ name() [2/2]

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

Change the name of the PRM Object.

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

Definition at line 58 of file PRMObject_inl.h.

58{ _name_ = name; }

References _name_, and name().

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

90 {
91 auto impl = static_cast< MultiDimImplementation< GUM_SCALAR >* >(
92 this->cpf().content()->newFactory());
93 return new PRMScalarAttribute< GUM_SCALAR >(this->name(), this->type(), impl);
94 }

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

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

77 {
79 }

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

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

66{ return _name_ != obj.name(); }

References PRMObject(), _name_, and name().

Here is the call 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 86 of file PRMFuncAttribute_tpl.h.

86 {
87 GUM_ERROR(FatalError, "illegal call to copy operator")
88 }

References PRMFuncAttribute(), and GUM_ERROR.

Here is the call 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 62 of file PRMObject_inl.h.

62{ return _name_ == obj.name(); }

References PRMObject(), _name_, and name().

Here is the call 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 71 of file PRMAttribute_tpl.h.

71 {
72 auto old_type = this->type_();
73 this->type_(source->type_());
75 }
PRMAttribute is a member of a Class in a PRM.
virtual PRMType * type_()=0

References PRMAttribute(), and type_().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RIGHT_CAST()

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

92{ return ")"; }

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

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

87 {
88 return safeName_;
89 }
std::string safeName_
The safe name of this PRMClassElement.

References safeName_.

Referenced by gum::prm::__print_attribute__(), gum::prm::PRMClass< GUM_SCALAR >::_addCastDescendants_(), gum::prm::PRMClass< GUM_SCALAR >::_addCastDescendants_(), gum::prm::PRMFactory< GUM_SCALAR >::_addParent_(), gum::prm::PRMInstance< GUM_SCALAR >::_copyAttributeCPF_(), gum::prm::SVED< GUM_SCALAR >::_getAggTensor_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_(), gum::prm::PRMSystem< double >::_groundTensor_(), gum::prm::PRMClass< GUM_SCALAR >::_overloadAggregate_(), gum::prm::PRMClass< GUM_SCALAR >::_overloadAttribute_(), gum::prm::PRMClass< GUM_SCALAR >::_overloadParameter_(), gum::prm::PRMClass< GUM_SCALAR >::_overloadReference_(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::_str_(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::_str_(), gum::prm::StructuredInference< GUM_SCALAR >::_str_(), gum::prm::StructuredInference< GUM_SCALAR >::_str_(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::PRMInterface< double >::addArc(), gum::prm::PRMFactory< GUM_SCALAR >::addAttribute(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::belongsTo(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::getIOFlag_(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::getIOFlag_(), gum::prm::PRMInterface< double >::implementations(), gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setIOFlag_(), and gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode().

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 204 of file PRMScalarAttribute_tpl.h.

204 {
205 try {
206 type().setSuper(cast->type());
207 } catch (OperationNotAllowed const&) {
208 GUM_ERROR(OperationNotAllowed, "this ScalarAttribute can not have cast descendant")
209 } catch (TypeError const&) {
211 msg << type().name() << " is not a subtype of " << cast->type().name();
212 GUM_ERROR(TypeError, msg.str())
213 }
214 cast->becomeCastDescendant(type());
215 }
void setSuper(PRMType &t)
Changes the PRMType of this PRMType super.
Definition PRMType_inl.h:88
const std::string & name() const
Returns the name of this object.
Definition PRMType_inl.h:78

References gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), gum::prm::PRMClassElement< GUM_SCALAR >::cast(), GUM_ERROR, and type().

Here is the call graph for this function:

◆ setCpf_()

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

Definition at line 91 of file PRMFuncAttribute_tpl.h.

91 {
92 GUM_ERROR(OperationNotAllowed, "Cannot change CPF of a functional attribute")
93 }

References gum::prm::PRMScalarAttribute< GUM_SCALAR >::cpf(), and GUM_ERROR.

Here is the call graph for this function:

◆ setId()

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

◆ 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 237 of file PRMScalarAttribute_tpl.h.

237 {
238 if (&(old_type) == _type_) {
239 GUM_ERROR(OperationNotAllowed, "Cannot replace attribute own type")
240 }
241 if (old_type->domainSize() != new_type->domainSize()) {
242 GUM_ERROR(OperationNotAllowed, "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
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
261
262 for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end()); inst.inc(), jnst.inc()) {
263 _cpf_->set(inst, old->get(jnst));
264 }
265
266 delete old;
267
268 GUM_ASSERT(inst.end() && jnst.end());
269 GUM_ASSERT(_cpf_->contains(_type_->variable()));
270 GUM_ASSERT(_cpf_->contains(new_type.variable()));
271 GUM_ASSERT(!_cpf_->contains(old_type.variable()));
272 }

References _cpf_, _type_, gum::DiscreteVariable::domainSize(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::prm::PRMType::name(), gum::Instantiation::setFirst(), and gum::prm::PRMType::variable().

Here is the call graph for this function:

◆ type() [1/2]

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

See gum::PRMClassElement::type().

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

Definition at line 146 of file PRMScalarAttribute_tpl.h.

146 {
147 return *_type_;
148 }

References _type_.

Referenced by gum::prm::PRMFuncAttribute< GUM_SCALAR >::PRMFuncAttribute(), PRMScalarAttribute(), becomeCastDescendant(), copy(), getCastDescendant(), newFactory(), and setAsCastDescendant().

Here is the caller graph for this function:

◆ 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 151 of file PRMScalarAttribute_tpl.h.

151 {
152 return *_type_;
153 }

References _type_.

◆ type_() [1/2]

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

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

Definition at line 275 of file PRMScalarAttribute_tpl.h.

275 {
276 return _type_;
277 }

References _type_.

◆ 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 280 of file PRMScalarAttribute_tpl.h.

280 {
281 if (_type_->variable().domainSize() != t->variable().domainSize()) {
282 GUM_ERROR(OperationNotAllowed, "Cannot replace types with difference domain size")
283 }
284 auto old = _cpf_;
285
287
288 for (auto var: old->variablesSequence()) {
289 if (var != &(_type_->variable())) {
290 _cpf_->add(*var);
291 } else {
292 _cpf_->add(t->variable());
293 }
294 }
295
297
298 for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end()); inst.inc(), jnst.inc()) {
299 _cpf_->set(inst, old->get(jnst));
300 }
301
302 delete old;
303
304 _type_ = t;
305
306 GUM_ASSERT(_cpf_->contains(_type_->variable()));
307 GUM_ASSERT(inst.end() && jnst.end());
308 }

References _cpf_, _type_, gum::DiscreteVariable::domainSize(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), and gum::Instantiation::setFirst().

Here is the call graph for this function:

Member Data Documentation

◆ _cpf_

template<typename GUM_SCALAR>
Tensor< GUM_SCALAR >* gum::prm::PRMScalarAttribute< GUM_SCALAR >::_cpf_
privateinherited

A pointer on the Tensor of this attribute.

Definition at line 171 of file PRMScalarAttribute.h.

Referenced by PRMScalarAttribute(), PRMScalarAttribute(), ~PRMScalarAttribute(), addParent(), becomeCastDescendant(), copyCpf(), cpf(), swap(), and type_().

◆ _id_

template<typename GUM_SCALAR>
NodeId gum::prm::PRMClassElement< GUM_SCALAR >::_id_
privateinherited

The node's id of this element.

Definition at line 278 of file PRMClassElement.h.

Referenced by PRMClassElement(), id(), and setId().

◆ _name_

std::string gum::prm::PRMObject::_name_
privateinherited

◆ _type_

template<typename GUM_SCALAR>
PRMType* gum::prm::PRMScalarAttribute< GUM_SCALAR >::_type_
privateinherited

The random variable type of this attribute.

Definition at line 168 of file PRMScalarAttribute.h.

Referenced by PRMScalarAttribute(), PRMScalarAttribute(), ~PRMScalarAttribute(), copyCpf(), swap(), type(), type(), type_(), and type_().

◆ safeName_


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