Vcsn  2.4
Be Rational
identities.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <string>
5 
6 #include <vcsn/core/join.hh>
7 #include <vcsn/misc/export.hh>
8 
9 namespace vcsn LIBVCSN_API
10 {
11  namespace rat
12  {
13 
21  class identities
22  {
23  public:
24  using self_t = identities;
25 
26  enum ids_t
27  {
30 
33 
36 
40 
43 
46 
49  };
50 
52  : ids_{id}
53  {}
54 
56  identities(const std::string& i);
57 
59  identities(const char* cp);
60 
61  ids_t ids() const
62  {
63  return ids_;
64  }
65 
67  bool is_agressive() const
68  {
69  return ids_ == agressive;
70  }
71 
73  bool is_associative() const
74  {
75  return associative <= ids_;
76  }
77 
79  bool is_distributive() const
80  {
81  return ids_ == distributive;
82  }
83 
85  bool is_linear() const
86  {
87  return linear <= ids_;
88  }
89 
91  operator bool() const
92  {
93  return ids_ != none;
94  }
95 
96  bool operator<(self_t that) const
97  {
98  return ids_ < that.ids_;
99  }
100 
101  bool operator==(self_t that) const
102  {
103  return ids_ == that.ids_;
104  }
105 
106  bool operator!=(self_t that) const
107  {
108  return !operator==(that);
109  }
110 
111  private:
113  };
114 
116  std::string to_string(identities i);
117 
119  std::istream& operator>>(std::istream& is, identities& i);
120 
122  std::ostream& operator<<(std::ostream& os, identities i);
123 
125 
126  } // namespace rat
127 
128  namespace detail
129  {
130  template <>
131  struct join_impl<rat::identities, rat::identities>
132  {
135  {
136  return std::max(i1, i2);
137  }
138  };
139  }
140 } // namespace vcsn
Linear plus optimizations.
Definition: identities.hh:45
identities(ids_t id=deflt)
Definition: identities.hh:51
bool is_associative() const
Whether associative.
Definition: identities.hh:73
Strictly obey to the syntax.
Definition: identities.hh:29
std::ostream & operator<<(std::ostream &o, type_t t)
Print a expression type.
Definition: printer.hxx:13
identities meet(identities i1, identities i2)
Definition: identities.cc:76
bool operator<(self_t that) const
Definition: identities.hh:96
Linear plus distribution. Used for series identities.
Definition: identities.hh:42
Trivial, plus associativity of add and product.
Definition: identities.hh:35
std::istream & operator>>(std::istream &is, identities &i)
Read from string form.
Definition: identities.cc:67
ids_t ids() const
Definition: identities.hh:61
#define LIBVCSN_API
Definition: export.hh:8
bool is_agressive() const
Whether agressive optimizations are on.
Definition: identities.hh:67
std::ostringstream os
The output stream: the corresponding C++ snippet to compile.
Definition: translate.cc:375
Definition: a-star.hh:8
Associative plus commutativity, and "idempotence" for add.
Definition: identities.hh:39
bool operator!=(self_t that) const
Definition: identities.hh:106
static type join(rat::identities i1, rat::identities i2)
Definition: identities.hh:134
A structure that implements the computation of join(V1, V2).
Definition: join.hh:18
bool operator==(self_t that) const
Definition: identities.hh:101
The default value.
Definition: identities.hh:48
An expressionset can implement several different sets of identities on expressions.
Definition: identities.hh:21
Trivial identities only.
Definition: identities.hh:32
bool is_distributive() const
Whether distributive.
Definition: identities.hh:79
bool is_linear() const
Whether linear.
Definition: identities.hh:85
std::string to_string(identities i)
Wrapper around operator<<.
Definition: identities.cc:42