aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::DiscreteVariable Class Referenceabstract

Base class for discrete random variable. More...

#include <discreteVariable.h>

+ Inheritance diagram for gum::DiscreteVariable:
+ Collaboration diagram for gum::DiscreteVariable:

Public Member Functions

Idx operator[] (const std::string &label) const
 from the label to its index in var. More...
 
virtual Idx index (const std::string &label) const =0
 
virtual std::string label (Idx i) const =0
 get the indice-th label. This method is pure virtual. More...
 
std::string toString () const
 string version of *this More...
 
std::string toStringWithDescription () const
 string version of *this using description attribute instead of name. More...
 
virtual const std::string domain () const =0
 string represent the domain of the variable More...
 
Constructors / Destructors
 DiscreteVariable (const std::string &aName, const std::string &aDesc)
 Default constructor. More...
 
 DiscreteVariable (const DiscreteVariable &aDRV)
 Copy constructor. More...
 
virtual ~DiscreteVariable ()
 destructor More...
 
virtual DiscreteVariableclone () const =0
 Copy Factory. More...
 
Accessors / Modifiers
bool empty () const
 
virtual Size domainSize () const =0
 
std::vector< std::string > labels () const
 vector of labels More...
 
virtual double numerical (Idx indice) const =0
 get a numerical representation of the indice-th value. More...
 
virtual VarType varType () const =0
 returns the varType of variable More...
 
Operators
DiscreteVariableoperator= (const DiscreteVariable &aRV)
 Copy operator. More...
 
virtual bool operator== (const DiscreteVariable &aRV) const
 equality operator More...
 
virtual bool operator!= (const DiscreteVariable &aRV) const
 inequality operator More...
 
Operators
virtual bool operator== (const Variable &aRV) const
 equality operator More...
 
virtual bool operator!= (const Variable &aRV) const
 inequality operator More...
 
Accessors / Modifiers
void setName (const std::string &theValue)
 sets the name of the variable More...
 
const std::string & name () const
 returns the name of the variable More...
 
void setDescription (const std::string &theValue) const
 sets the description of the variable More...
 
const std::string & description () const
 returns the description of the variable More...
 

Protected Member Functions

 DiscreteVariable ()
 (protected) Default constructor More...
 
void copy_ (const Variable &aRV)
 protected copy More...
 

Detailed Description

Base class for discrete random variable.

This class is used as an interface.

Definition at line 59 of file discreteVariable.h.

Constructor & Destructor Documentation

◆ DiscreteVariable() [1/3]

gum::DiscreteVariable::DiscreteVariable ( const std::string &  aName,
const std::string &  aDesc 
)

Default constructor.

◆ DiscreteVariable() [2/3]

gum::DiscreteVariable::DiscreteVariable ( const DiscreteVariable aDRV)

Copy constructor.

Copy Constructor.

If aDRV haves any listener, it will not be copied.

Parameters
aDRVthe variable we copy

◆ ~DiscreteVariable()

virtual gum::DiscreteVariable::~DiscreteVariable ( )
virtual

destructor

◆ DiscreteVariable() [3/3]

gum::DiscreteVariable::DiscreteVariable ( )
inlineprotected

(protected) Default constructor

Definition at line 159 of file discreteVariable.h.

159  {
160  GUM_CONSTRUCTOR(DiscreteVariable);
161  ;
162  }
DiscreteVariable()
(protected) Default constructor

Member Function Documentation

◆ clone()

virtual DiscreteVariable* gum::DiscreteVariable::clone ( ) const
pure virtual

Copy Factory.

Returns
Returns a pointer on a new copy of this.

Implements gum::Variable.

Implemented in gum::DiscretizedVariable< T_TICKS >, gum::LabelizedVariable, gum::RangeVariable, and gum::IDiscretizedVariable.

◆ copy_()

void gum::Variable::copy_ ( const Variable aRV)
protectedinherited

protected copy

Parameters
aRVto be copied

◆ description()

const std::string& gum::Variable::description ( ) const
inherited

returns the description of the variable

◆ domain()

virtual const std::string gum::DiscreteVariable::domain ( ) const
pure virtual

string represent the domain of the variable

Implements gum::Variable.

Implemented in gum::DiscretizedVariable< T_TICKS >, gum::LabelizedVariable, and gum::RangeVariable.

◆ domainSize()

virtual Size gum::DiscreteVariable::domainSize ( ) const
pure virtual
Returns
the number of modalities of the random discrete

Implemented in gum::DiscretizedVariable< T_TICKS >, gum::LabelizedVariable, and gum::RangeVariable.

◆ empty()

bool gum::DiscreteVariable::empty ( ) const
Returns
true if the domainSize() < 2;

◆ index()

virtual Idx gum::DiscreteVariable::index ( const std::string &  label) const
pure virtual

◆ label()

virtual std::string gum::DiscreteVariable::label ( Idx  i) const
pure virtual

get the indice-th label. This method is pure virtual.

Parameters
indicethe index of the label we wish to return
Exceptions
OutOfBound

Implemented in gum::DiscretizedVariable< T_TICKS >, gum::LabelizedVariable, and gum::RangeVariable.

◆ labels()

std::vector< std::string > gum::DiscreteVariable::labels ( ) const

vector of labels

◆ name()

const std::string& gum::Variable::name ( ) const
inherited

returns the name of the variable

◆ numerical()

virtual double gum::DiscreteVariable::numerical ( Idx  indice) const
pure virtual

get a numerical representation of the indice-th value.

Implemented in gum::DiscretizedVariable< T_TICKS >, gum::LabelizedVariable, and gum::RangeVariable.

◆ operator!=() [1/2]

virtual bool gum::Variable::operator!= ( const Variable aRV) const
virtualinherited

inequality operator

◆ operator!=() [2/2]

virtual bool gum::DiscreteVariable::operator!= ( const DiscreteVariable aRV) const
virtual

inequality operator

◆ operator=()

DiscreteVariable& gum::DiscreteVariable::operator= ( const DiscreteVariable aRV)

Copy operator.

Parameters
aRVto be copied
Returns
a ref to *this

◆ operator==() [1/2]

virtual bool gum::Variable::operator== ( const Variable aRV) const
virtualinherited

equality operator

◆ operator==() [2/2]

virtual bool gum::DiscreteVariable::operator== ( const DiscreteVariable aRV) const
virtual

equality operator

◆ operator[]()

Idx gum::DiscreteVariable::operator[] ( const std::string &  label) const
inline

from the label to its index in var.

Warning
This operation may have different complexity in different subclasses.
Exceptions
NotFound

Definition at line 139 of file discreteVariable.h.

139 { return index(label); };
virtual std::string label(Idx i) const =0
get the indice-th label. This method is pure virtual.
virtual Idx index(const std::string &label) const =0

◆ setDescription()

void gum::Variable::setDescription ( const std::string &  theValue) const
inherited

sets the description of the variable

Warning
since description is mutable, setDescription() is const
Parameters
theValue

◆ setName()

void gum::Variable::setName ( const std::string &  theValue)
inherited

sets the name of the variable

Parameters
theValue

◆ toString()

std::string gum::DiscreteVariable::toString ( ) const

string version of *this

◆ toStringWithDescription()

std::string gum::DiscreteVariable::toStringWithDescription ( ) const

string version of *this using description attribute instead of name.

◆ varType()

virtual VarType gum::DiscreteVariable::varType ( ) const
pure virtual

returns the varType of variable

Implements gum::Variable.

Implemented in gum::LabelizedVariable, gum::DiscretizedVariable< T_TICKS >, and gum::RangeVariable.


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