aGrUM  0.18.2
a C++ library for (probabilistic) graphical models
gum::prm::PRMType Class Reference

This is a decoration of the DiscreteVariable class. More...

#include <PRMType.h>

+ Inheritance diagram for gum::prm::PRMType:
+ Collaboration diagram for gum::prm::PRMType:

Public Member Functions

Constructors & destructor
 PRMType (const DiscreteVariable &var)
 Default Constructor. More...
 
 PRMType (PRMType &super_type, const std::vector< Idx > &label_map, const DiscreteVariable &var)
 Sub type constructor. More...
 
 PRMType (const PRMType &from)
 Copy constructor. More...
 
virtual ~PRMType ()
 Destructor. More...
 
Getters & setters
DiscreteVariablevariable ()
 Return a reference on the DiscreteVariable contained in this. More...
 
const DiscreteVariablevariable () const
 Return a reference on the DiscreteVariable contained in this. More...
 
virtual prm_type obj_type () const
 Implementation of the pure virtual method of PRMObject. More...
 
const std::string & name () const
 Returns the name of this object. More...
 
bool isSubType () const
 Returns true if this type is a sub-type. More...
 
bool isSubTypeOf (const PRMType &super) const
 Returns true if this is a subtype of super. More...
 
bool isSuperTypeOf (const PRMType &t) const
 Returns true if this is a super type of t. More...
 
PRMTypesuperType ()
 Returns the super type of this type. More...
 
const PRMTypesuperType () const
 Returns the super type of this type. More...
 
void setSuper (PRMType &t)
 Changes the PRMType of this PRMType super. More...
 
const std::vector< Idx > & label_map () const
 Returns the vector in which the i-th element is the Idx of the super type's label for the i-th label of this. More...
 
Operators
DiscreteVariableoperator* ()
 Indirection on the DiscreteVariable contained in this. More...
 
const DiscreteVariableoperator* () const
 Constant indirection on the DiscreteVariable contained in this. More...
 
DiscreteVariableoperator-> ()
 Dereference the DiscreteVariable contained in this. More...
 
DiscreteVariable const * operator-> () const
 Constant dereference the DiscreteVariable contained in this. More...
 
bool operator== (const PRMObject &from) const
 Equality operator. More...
 
bool operator!= (const PRMObject &from) const
 Difference operator. More...
 
Getters & setters.
void name (const std::string &name)
 Change the name of the PRM Object. More...
 

Static Public Member Functions

Static methods for primitive types
static PRMTypeboolean ()
 Returns a pointer on type boolean. More...
 

Friends

Friends of PRMType
template<typename GUM_SCALAR >
class PRMFactory
 

Built-in types.

static std::string LEFT_CAST ()
 Enumeration of the different types of objects handled by a PRM. More...
 
static std::string RIGHT_CAST ()
 Enumeration of the different types of objects handled by a PRM. More...
 
static std::string enum2str (prm_type type)
 Returns the string representation of a PRMObject. More...
 
static INLINE bool isClass (const PRMObject &obj)
 Returns true if obj_ptr is of type Class. More...
 
static INLINE bool isInterface (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInterface. More...
 
static INLINE bool isInstance (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInstance. More...
 
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...
 

Private members.

DiscreteVariablevar__
 The discrete variable. More...
 
PRMTypesuperType__
 The super type of this, if any. More...
 
std::vector< Idx > * label_map__
 A vector in which the i-th element is the Idx of the super type's label for the i-th label of this. More...
 
bool isValid__ () const
 Returns true if this is a valid type or subtype. More...
 
void updateName__ ()
 Used at construction to set a unique name to this class underlying DiscreteVariable. More...
 

Detailed Description

This is a decoration of the DiscreteVariable class.

The name of the DiscreteVariable will be the name of the type (i.e. of the PRMObject). As for all PRMObject, a type's name is unique in a given PRM, so equality tests will be based on the types names.

Since MultiDim use pointers to handle DiscreteVariables, it is necessary to create a new instance of a type for each PRMAttribute.

Definition at line 63 of file PRMType.h.

Member Enumeration Documentation

◆ prm_type

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

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

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

Enumerator
ALL 
CLASS 
PRM_INTERFACE 
CLASS_ELT 
TYPE 
SYSTEM 
INSTANCE 

Definition at line 69 of file PRMObject.h.

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

Constructor & Destructor Documentation

◆ PRMType() [1/4]

gum::prm::PRMType::PRMType ( const DiscreteVariable var)
explicit

Default Constructor.

A copy is made of var.

Definition at line 50 of file PRMType.cpp.

References updateName__().

Referenced by boolean().

50  :
51  PRMObject(var.name()), var__(var.clone()), superType__(0), label_map__(0) {
52  GUM_CONSTRUCTOR(PRMType);
53  this->updateName__();
54  }
PRMType(const DiscreteVariable &var)
Default Constructor.
Definition: PRMType.cpp:50
DiscreteVariable * var__
The discrete variable.
Definition: PRMType.h:276
void updateName__()
Used at construction to set a unique name to this class underlying DiscreteVariable.
Definition: PRMType.cpp:42
std::vector< Idx > * label_map__
A vector in which the i-th element is the Idx of the super type&#39;s label for the i-th label of this...
Definition: PRMType.h:283
PRMType * superType__
The super type of this, if any.
Definition: PRMType.h:279
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PRMType() [2/4]

gum::prm::PRMType::PRMType ( PRMType super_type,
const std::vector< Idx > &  label_map,
const DiscreteVariable var 
)

Sub type constructor.

A copy is made of var.

Exceptions
OperationNotAllowedRaised if label_map is invalid.

Definition at line 57 of file PRMType.cpp.

References GUM_ERROR, isValid__(), label_map__, and updateName__().

59  :
60  PRMObject(var.name()),
61  var__(var.clone()), superType__(&super_type),
62  label_map__(new std::vector< Idx >(label_map)) {
63  GUM_CONSTRUCTOR(PRMType);
64  this->updateName__();
65 
66  if (!isValid__()) {
67  delete label_map__;
68  label_map__ = 0;
69  GUM_ERROR(OperationNotAllowed, "Invalid label map.");
70  }
71  }
PRMType(const DiscreteVariable &var)
Default Constructor.
Definition: PRMType.cpp:50
DiscreteVariable * var__
The discrete variable.
Definition: PRMType.h:276
void updateName__()
Used at construction to set a unique name to this class underlying DiscreteVariable.
Definition: PRMType.cpp:42
std::vector< Idx > * label_map__
A vector in which the i-th element is the Idx of the super type&#39;s label for the i-th label of this...
Definition: PRMType.h:283
bool isValid__() const
Returns true if this is a valid type or subtype.
Definition: PRMType.cpp:118
PRMType * superType__
The super type of this, if any.
Definition: PRMType.h:279
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:43
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:

◆ PRMType() [3/4]

gum::prm::PRMType::PRMType ( const PRMType from)

Copy constructor.

The DiscreteVariable is copied.

Definition at line 74 of file PRMType.cpp.

References label_map(), label_map__, superType__, and updateName__().

74  :
75  PRMObject(from), var__(from.var__->clone()), superType__(from.superType__),
76  label_map__(0) {
77  GUM_CONS_CPY(PRMType);
78  this->updateName__();
79 
80  if (superType__) { label_map__ = new std::vector< Idx >(from.label_map()); }
81  }
PRMType(const DiscreteVariable &var)
Default Constructor.
Definition: PRMType.cpp:50
DiscreteVariable * var__
The discrete variable.
Definition: PRMType.h:276
void updateName__()
Used at construction to set a unique name to this class underlying DiscreteVariable.
Definition: PRMType.cpp:42
std::vector< Idx > * label_map__
A vector in which the i-th element is the Idx of the super type&#39;s label for the i-th label of this...
Definition: PRMType.h:283
PRMType * superType__
The super type of this, if any.
Definition: PRMType.h:279
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:43
+ Here is the call graph for this function:

◆ ~PRMType()

gum::prm::PRMType::~PRMType ( )
virtual

Destructor.

Definition at line 90 of file PRMType.cpp.

References label_map__, and var__.

Referenced by boolean().

90  {
91  GUM_DESTRUCTOR(PRMType);
92  delete var__;
93  if (label_map__) { delete label_map__; }
94  }
PRMType(const DiscreteVariable &var)
Default Constructor.
Definition: PRMType.cpp:50
DiscreteVariable * var__
The discrete variable.
Definition: PRMType.h:276
std::vector< Idx > * label_map__
A vector in which the i-th element is the Idx of the super type&#39;s label for the i-th label of this...
Definition: PRMType.h:283
+ Here is the caller graph for this function:

◆ PRMType() [4/4]

gum::prm::PRMType::PRMType ( PRMType &&  from)
private

Move constructor.

Not implemented, will raise an exception.

Definition at line 84 of file PRMType.cpp.

References GUM_ERROR.

84  : PRMObject(from) {
85  GUM_CONS_MOV(PRMType);
86  GUM_ERROR(FatalError, "Move constructor must not be used");
87  }
PRMType(const DiscreteVariable &var)
Default Constructor.
Definition: PRMType.cpp:50
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:43
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

Member Function Documentation

◆ boolean()

static PRMType* gum::prm::PRMType::boolean ( )
inlinestatic

Returns a pointer on type boolean.

Definition at line 80 of file PRMType.h.

References gum::LabelizedVariable::addLabel(), isSubType(), isSubTypeOf(), isSuperTypeOf(), isValid__(), label_map(), name(), obj_type(), operator!=(), operator*(), operator->(), operator=(), operator==(), PRMType(), setSuper(), superType(), updateName__(), variable(), and ~PRMType().

80  {
81  LabelizedVariable var("boolean", "Boolean variable", 0);
82  var.addLabel("false");
83  var.addLabel("true");
84  return new PRMType(var);
85  }
PRMType(const DiscreteVariable &var)
Default Constructor.
Definition: PRMType.cpp:50
+ Here is the call graph for this function:

◆ enum2str()

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

Returns the string representation of a PRMObject.

Definition at line 83 of file PRMObject.h.

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

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

◆ isClass()

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

Returns true if obj_ptr is of type Class.

Definition at line 102 of file PRMObject.h.

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

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

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

◆ isInstance()

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

Returns true if obj_ptr is of type PRMInstance.

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

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

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 107 of file PRMObject.h.

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

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

◆ isSubType()

INLINE bool gum::prm::PRMType::isSubType ( ) const

Returns true if this type is a sub-type.

Definition at line 103 of file PRMType_inl.h.

References superType__.

Referenced by boolean().

103 { return superType__ != nullptr; }
PRMType * superType__
The super type of this, if any.
Definition: PRMType.h:279
+ Here is the caller graph for this function:

◆ isSubTypeOf()

bool gum::prm::PRMType::isSubTypeOf ( const PRMType super) const

Returns true if this is a subtype of super.

Note that two types that are equal are also subtypes, if a == b then a.isSubTypeOf(b) == b.isSubTypeOf(a) == true.

Definition at line 107 of file PRMType.cpp.

References superType__.

Referenced by boolean(), and isSuperTypeOf().

107  {
108  if ((*this) == super) {
109  return true;
110  } else if (superType__) {
111  return superType__->isSubTypeOf(super);
112  } else {
113  return false;
114  }
115  }
PRMType * superType__
The super type of this, if any.
Definition: PRMType.h:279
+ Here is the caller graph for this function:

◆ isSuperTypeOf()

INLINE bool gum::prm::PRMType::isSuperTypeOf ( const PRMType t) const

Returns true if this is a super type of t.

Definition at line 106 of file PRMType_inl.h.

References isSubTypeOf().

Referenced by boolean().

106  {
107  return t.isSubTypeOf(*this);
108  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValid__()

bool gum::prm::PRMType::isValid__ ( ) const
private

Returns true if this is a valid type or subtype.

Definition at line 118 of file PRMType.cpp.

References gum::DiscreteVariable::domainSize(), label_map__, superType__, and var__.

Referenced by boolean(), and PRMType().

118  {
119  if (!superType__) { return var__->domainSize() > 1; }
120 
121  if (label_map__->size() == var__->domainSize()) {
122  for (size_t i = 0; i < label_map__->size(); ++i) {
123  if (label_map__->at(i) >= (**superType__).domainSize()) { return false; }
124  }
125 
126  return true;
127  }
128 
129  return false;
130  }
DiscreteVariable * var__
The discrete variable.
Definition: PRMType.h:276
std::vector< Idx > * label_map__
A vector in which the i-th element is the Idx of the super type&#39;s label for the i-th label of this...
Definition: PRMType.h:283
virtual Size domainSize() const =0
PRMType * superType__
The super type of this, if any.
Definition: PRMType.h:279
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ label_map()

INLINE const std::vector< Idx > & gum::prm::PRMType::label_map ( ) const

Returns the vector in which the i-th element is the Idx of the super type's label for the i-th label of this.

Exceptions
NotFoundRaised if this type has no super type.

Definition at line 94 of file PRMType_inl.h.

References GUM_ERROR, and label_map__.

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

94  {
95  if (label_map__) {
96  return *label_map__;
97  } else {
98  GUM_ERROR(NotFound, "No super type for this type.");
99  }
100  }
std::vector< Idx > * label_map__
A vector in which the i-th element is the Idx of the super type&#39;s label for the i-th label of this...
Definition: PRMType.h:283
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ LEFT_CAST()

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

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

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

Definition at line 79 of file PRMObject.h.

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

79 { return "("; }
+ Here is the caller graph for this function:

◆ name() [1/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 39 of file PRMObject_inl.h.

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

39 { name__ = name; }
std::string name__
Definition: PRMObject.h:200
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
+ Here is the call graph for this function:

◆ name() [2/2]

INLINE const std::string & gum::prm::PRMType::name ( ) const

Returns the name of this object.

Definition at line 68 of file PRMType_inl.h.

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

Referenced by boolean(), gum::prm::PRMClassElement< double >::cast(), operator!=(), operator==(), gum::prm::PRMFuncAttribute< GUM_SCALAR >::PRMFuncAttribute(), gum::prm::PRMFormAttribute< GUM_SCALAR >::setAsCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::setAsCastDescendant(), gum::prm::PRMFormAttribute< GUM_SCALAR >::swap(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::swap(), and updateName__().

68 { return PRMObject::name(); }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ obj_type()

INLINE PRMObject::prm_type gum::prm::PRMType::obj_type ( ) const
virtual

Implementation of the pure virtual method of PRMObject.

Implements gum::prm::PRMObject.

Definition at line 63 of file PRMType_inl.h.

References gum::prm::PRMObject::TYPE.

Referenced by boolean().

+ Here is the caller graph for this function:

◆ operator!=()

INLINE bool gum::prm::PRMType::operator!= ( const PRMObject from) const

Difference operator.

Definition at line 116 of file PRMType_inl.h.

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

Referenced by boolean().

116  {
117  return name() != obj.name();
118  }
const std::string & name() const
Returns the name of this object.
Definition: PRMType_inl.h:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator*() [1/2]

INLINE DiscreteVariable & gum::prm::PRMType::operator* ( )

Indirection on the DiscreteVariable contained in this.

Definition at line 51 of file PRMType_inl.h.

References var__.

Referenced by boolean().

51 { return *var__; }
DiscreteVariable * var__
The discrete variable.
Definition: PRMType.h:276
+ Here is the caller graph for this function:

◆ operator*() [2/2]

INLINE const DiscreteVariable & gum::prm::PRMType::operator* ( ) const

Constant indirection on the DiscreteVariable contained in this.

Definition at line 54 of file PRMType_inl.h.

References var__.

54 { return *var__; }
DiscreteVariable * var__
The discrete variable.
Definition: PRMType.h:276

◆ operator->() [1/2]

INLINE DiscreteVariable * gum::prm::PRMType::operator-> ( )

Dereference the DiscreteVariable contained in this.

Definition at line 57 of file PRMType_inl.h.

References var__.

Referenced by boolean().

57 { return var__; }
DiscreteVariable * var__
The discrete variable.
Definition: PRMType.h:276
+ Here is the caller graph for this function:

◆ operator->() [2/2]

INLINE DiscreteVariable const * gum::prm::PRMType::operator-> ( ) const

Constant dereference the DiscreteVariable contained in this.

Definition at line 60 of file PRMType_inl.h.

References var__.

60 { return var__; }
DiscreteVariable * var__
The discrete variable.
Definition: PRMType.h:276

◆ operator=() [1/2]

PRMType & gum::prm::PRMType::operator= ( const PRMType from)
private

Copy operator.

Not implemented.

Definition at line 97 of file PRMType.cpp.

References GUM_ERROR.

Referenced by boolean().

97  {
98  GUM_ERROR(FatalError, "Copy operator must not be used");
99  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ operator=() [2/2]

PRMType & gum::prm::PRMType::operator= ( PRMType &&  from)
private

Move operator.

Not implemented.

Definition at line 102 of file PRMType.cpp.

References GUM_ERROR.

102  {
103  GUM_ERROR(FatalError, "Move operator must not be used");
104  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ operator==()

INLINE bool gum::prm::PRMType::operator== ( const PRMObject from) const

Equality operator.

Definition at line 111 of file PRMType_inl.h.

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

Referenced by boolean().

111  {
112  return name() == obj.name();
113  }
const std::string & name() const
Returns the name of this object.
Definition: PRMType_inl.h:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RIGHT_CAST()

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

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

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

Definition at line 80 of file PRMObject.h.

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

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

◆ setSuper()

INLINE void gum::prm::PRMType::setSuper ( PRMType t)

Changes the PRMType of this PRMType super.

You can only change this PRMType super only if t and this->superType() are equal. Thus you should use this method only if you want to change the DiscreteVariable pointer of this PRMType super.

This is useful to maintain consistence between PRMAttribute's PRMType and their CPF.

Parameters
tThe PRMType to replace this PRMType super.
Exceptions
OperationNotAllowedIf this PRMType has no super.
TypeErrorIf t is not equal to this PRMType super.

Definition at line 80 of file PRMType_inl.h.

References GUM_ERROR, superType(), and superType__.

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

80  {
81  try {
82  if (t != superType()) {
83  GUM_ERROR(WrongType,
84  "The given type is not a valid super type for this Type");
85  }
86  } catch (NotFound&) {
87  GUM_ERROR(OperationNotAllowed, "This Type has no super Type");
88  }
89 
90  superType__ = &t;
91  }
PRMType & superType()
Returns the super type of this type.
Definition: PRMType_inl.h:36
PRMType * superType__
The super type of this, if any.
Definition: PRMType.h:279
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ superType() [1/2]

INLINE PRMType & gum::prm::PRMType::superType ( )

Returns the super type of this type.

Exceptions
NotFoundRaised if this type has no super type.

Definition at line 36 of file PRMType_inl.h.

References GUM_ERROR, and superType__.

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

36  {
37  if (superType__) {
38  return *superType__;
39  } else {
40  GUM_ERROR(NotFound, "No super type for this type.");
41  }
42  }
PRMType * superType__
The super type of this, if any.
Definition: PRMType.h:279
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ superType() [2/2]

INLINE const PRMType & gum::prm::PRMType::superType ( ) const

Returns the super type of this type.

Exceptions
NotFoundRaised if this type has no super type.

Definition at line 71 of file PRMType_inl.h.

References GUM_ERROR, and superType__.

71  {
72  if (superType__) {
73  return *superType__;
74  } else {
75  GUM_ERROR(NotFound, "No super type for this type.");
76  }
77  }
PRMType * superType__
The super type of this, if any.
Definition: PRMType.h:279
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ updateName__()

void gum::prm::PRMType::updateName__ ( )
private

Used at construction to set a unique name to this class underlying DiscreteVariable.

Definition at line 42 of file PRMType.cpp.

References name(), gum::Variable::setName(), and var__.

Referenced by boolean(), and PRMType().

42  {
43  const void* address = static_cast< const void* >(this);
44  std::stringstream ss;
45  ss << this->name() << "-" << address;
46  this->var__->setName(ss.str());
47  }
void setName(const std::string &theValue)
sets the name of the variable
const std::string & name() const
Returns the name of this object.
Definition: PRMType_inl.h:68
DiscreteVariable * var__
The discrete variable.
Definition: PRMType.h:276
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ variable() [1/2]

◆ variable() [2/2]

INLINE const DiscreteVariable & gum::prm::PRMType::variable ( ) const

Return a reference on the DiscreteVariable contained in this.

Definition at line 48 of file PRMType_inl.h.

References var__.

48 { return *var__; }
DiscreteVariable * var__
The discrete variable.
Definition: PRMType.h:276

Friends And Related Function Documentation

◆ PRMFactory

template<typename GUM_SCALAR >
friend class PRMFactory
friend

Definition at line 71 of file PRMType.h.

Member Data Documentation

◆ label_map__

std::vector< Idx >* gum::prm::PRMType::label_map__
private

A vector in which the i-th element is the Idx of the super type's label for the i-th label of this.

Definition at line 283 of file PRMType.h.

Referenced by isValid__(), label_map(), PRMType(), and ~PRMType().

◆ superType__

PRMType* gum::prm::PRMType::superType__
private

The super type of this, if any.

Definition at line 279 of file PRMType.h.

Referenced by isSubType(), isSubTypeOf(), isValid__(), PRMType(), setSuper(), and superType().

◆ var__

DiscreteVariable* gum::prm::PRMType::var__
private

The discrete variable.

Definition at line 276 of file PRMType.h.

Referenced by isValid__(), operator*(), operator->(), updateName__(), variable(), and ~PRMType().


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