xc
Operando.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //Operando.h
22 
23 #ifndef OPERANDO_H
24 #define OPERANDO_H
25 
26 #include "Segnal.h"
27 #include "ProtoExpr.h"
28 #include "string"
29 
36 enum Posicion{prefija,infija,sufija};
37 
38 class Rama;
39 class ConjVariables;
40 
42 class Operando: public Segnal, public ProtoExpresion
43  {
44  protected:
45  double valor;
46  public:
47  inline explicit Operando(const double &d= 0.0)
48  : valor(d) {}
49  void Put(const double &v)
50  { valor= v; }
51  virtual const std::string &getName(void) const;
52  virtual const std::string &GetFullString(void) const;
53  inline virtual Clase GetClase(void) const
54  { return operando; }
55  inline virtual Posicion GetPosicion(void) const
56  { return infija; }
57  virtual bool Evaluable(void) const
58  { return false; }
59  inline virtual const Operando &Opera(const Operando *, const Operando *) const
60  { return *this; }
61  virtual Rama Diferencia(const Variable &,const Rama &) const;
62  virtual Rama *Simplifica(Rama *) const;
63  virtual Rama *Distrib(Rama *) const;
64  inline virtual void GetVariables(ConjVariables &) const {}
65  inline virtual const double &GetValor(const double &v1=0.0, const double &v2=0.0) const
66  { return valor; }
67  };
68 
69 #endif
Definition: ProtoExpr.h:35
virtual const std::string & GetFullString(void) const
Devuelve la cadena de caracteres correspondiente al valor con toda la precisión posible.
Definition: Operando.cc:51
Definition: Variable.h:31
virtual const std::string & getName(void) const
Return the operand name.
Definition: Operando.cc:46
Definition: ConjVariables.h:30
Operando.
Definition: Operando.h:42
Definition: Rama.h:33
Componente elemental de una expresión.
Definition: Segnal.h:60
virtual Rama * Distrib(Rama *) const
En su caso, aplica la propiedad distributiva.
Definition: Operando.cc:42
virtual Rama * Simplifica(Rama *) const
Simplifica la expresión.
Definition: Operando.cc:38