xc
TablaLiterales.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 //TablaLiterales.h
22 
23 #ifndef TABLALITERALES_H
24 #define TABLALITERALES_H
25 
26 #include "Operando.h"
27 #include <map>
28 
30  {
31  private:
32  class Literal : public Operando
33  {
34  //static TablaLiterales *ptr_tabla;
35  //Literal &operator=(const Literal &otro);
36  public:
37  explicit Literal(const double &d= 0.0);
38  inline virtual bool Evaluable(void) const
39  { return true; }
40  inline virtual bool EqualTo(const double &d) const
41  { return (valor == d); }
42  virtual Rama Diferencia(const Variable &,const Rama &) const;
43  virtual int GetPrioridad(void) const
44  { return 8; }
45  std::ostream &Imprime(std::ostream &os) const;
46 
47  friend int operator <(const Literal &c1,const Literal &c2)
48  { return (c1.valor < c2.valor); }
49  friend int operator ==(const Literal &c1,const Literal &c2)
50  { return (c1.valor == c2.valor); }
51  friend int operator !=(const Literal &c1,const Literal &c2)
52  { return (c1.valor != c2.valor); }
53  friend int operator >(const Literal &c1,const Literal &c2)
54  { return (c1.valor > c2.valor); }
55 
56  };
57  typedef std::map<Literal,size_t> tabla_literales;
58  typedef tabla_literales::iterator iterator;
59  typedef tabla_literales::const_iterator const_iterator;
60  typedef tabla_literales::value_type value_type;
61  tabla_literales literales;
62 
63  const Literal *Nuevo(const Literal &l);
64  void NuevaRef(const Literal &l);
65  void Borra(const Literal &l);
66  public:
67  TablaLiterales(void);
68  inline const Operando *NuevoDbl(const double &d)
69  { return Nuevo(Literal(d)); }
70  void NuevaRef(const double &);
71  void NuevaRef(const Segnal *);
72  void Borra(const double &d);
73  void BorraSiLiteral(const Segnal *s);
74  inline size_t size(void) const
75  { return literales.size(); }
76  };
77 
78 #endif
void BorraSiLiteral(const Segnal *s)
Quita el literal de la tabla si efectivamente el puntero corresponde a un literal.
Definition: TablaLiterales.cc:121
Definition: Variable.h:31
Operando.
Definition: Operando.h:42
Definition: Rama.h:33
Componente elemental de una expresión.
Definition: Segnal.h:60
Definition: TablaLiterales.h:29
TablaLiterales(void)
Constructor.
Definition: TablaLiterales.cc:49