aGrUM  0.16.0
discreteVariable_inl.h
Go to the documentation of this file.
1 
23 #ifndef DOXYGEN_SHOULD_SKIP_THIS
24 
25 // to ease parsers in IDE
27 
28 namespace gum {
29  /* =========================================================================*/
30  /* =========================================================================*/
31  /* === GUM_DISCRETE_VARIABLE === */
32  /* =========================================================================*/
33  /* =========================================================================*/
34 
35  // Default constructor
36  INLINE DiscreteVariable::DiscreteVariable(const std::string& aName,
37  const std::string& aDesc) :
38  Variable(aName, aDesc) {
39  GUM_CONSTRUCTOR(DiscreteVariable);
40  }
41 
42  // Copy constructor
44  Variable(aDRV) {
45  GUM_CONSTRUCTOR(DiscreteVariable);
46  }
47 
48  // destructor
50  GUM_DESTRUCTOR(DiscreteVariable);
51  }
52 
53  // Copy operator
55  operator=(const DiscreteVariable& aRV) {
56  if (&aRV != this) { Variable::operator=(aRV); }
57 
58  return *this;
59  }
60 
61  // equality operator
62  INLINE bool DiscreteVariable::operator==(const DiscreteVariable& aRV) const {
63  return (Variable::operator==(aRV) && (domainSize() == aRV.domainSize()));
64  }
65 
66  // inequality operator
67  INLINE bool DiscreteVariable::operator!=(const DiscreteVariable& aRV) const {
68  return (!operator==(aRV));
69  }
70 
71  // empty() <==> domainSize()<2
72  INLINE bool DiscreteVariable::empty() const { return domainSize() < 2; }
73 
74  // vector of labels
75  INLINE std::vector< std::string > DiscreteVariable::labels() const {
76  std::vector< std::string > v;
77  for (Idx i = 0; i < domainSize(); i++)
78  v.push_back(label(i));
79  return v;
80  }
81 } /* namespace gum */
82 
83 #endif // DOXYGEN_SHOULD_SKIP_THIS
std::vector< std::string > labels() const
vector of labels
DiscreteVariable & operator=(const DiscreteVariable &aRV)
Copy operator.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
virtual bool operator==(const DiscreteVariable &aRV) const
equality operator
virtual Size domainSize() const =0
virtual std::string label(Idx i) const =0
get the indice-th label. This method is pure virtual.
virtual bool operator!=(const DiscreteVariable &aRV) const
inequality operator
Variable & operator=(const Variable &aRV)
Copy operator.
virtual ~DiscreteVariable()
destructor
DiscreteVariable()
(protected) Default constructor
Variable()
(protected) Default constructor
Definition: variable.h:140