Vcsn  2.8
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  {
20  class identities
21  {
22  public:
23  using self_t = identities;
24 
25  enum ids_t
26  {
29 
32 
35 
39 
42 
45 
48  };
49 
51  : ids_{id}
52  {}
53 
55  identities(const std::string& i);
56 
58  identities(const char* cp);
59 
60  ids_t ids() const
61  {
62  return ids_;
63  }
64 
66  bool is_agressive() const
67  {
68  return agressive <= ids_;
69  }
70 
72  bool is_associative() const
73  {
74  return associative <= ids_;
75  }
76 
78  bool is_distributive() const
79  {
80  return ids_ == distributive;
81  }
82 
84  bool is_linear() const
85  {
86  return linear <= ids_;
87  }
88 
90  bool is_trivial() const
91  {
92  return trivial <= ids_;
93  }
94 
96  operator bool() const
97  {
98  return ids_ != none;
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 ids_ == that.ids_;
109  }
110 
111  bool operator!=(self_t that) const
112  {
113  return !operator==(that);
114  }
115 
116  private:
118  };
119 
121  std::string to_string(identities i);
122 
124  std::istream& operator>>(std::istream& is, identities& i);
125 
127  std::ostream& operator<<(std::ostream& os, identities i);
128 
131  } // namespace rat
132 
133  namespace detail
134  {
136  template <>
138  {
141  {
142  return std::max(i1, i2);
143  }
144  };
145  }
146 } // namespace vcsn
Associative plus commutativity, and "idempotence" for add.
Definition: identities.hh:38
Linear plus distribution. Used for series identities.
Definition: identities.hh:41
bool operator==(self_t that) const
Definition: identities.hh:106
Strictly obey to the syntax.
Definition: identities.hh:28
bool is_trivial() const
Whether trivial identities are on.
Definition: identities.hh:90
#define LIBVCSN_API
Definition: export.hh:8
bool is_agressive() const
Whether agressive optimizations are on.
Definition: identities.hh:66
Trivial identities only.
Definition: identities.hh:31
bool is_distributive() const
Whether distributive identities are on.
Definition: identities.hh:78
ids_t ids() const
Definition: identities.hh:60
bool operator<(self_t that) const
Definition: identities.hh:101
An expressionset can implement several different sets of identities on expressions.
Definition: identities.hh:20
identities meet(identities i1, identities i2)
More restricted of these identities (min).
Definition: identities.cc:72
Trivial, plus associativity of add and product.
Definition: identities.hh:34
bool is_associative() const
Whether associative identities are on.
Definition: identities.hh:72
std::ostringstream os
The output stream: the corresponding C++ snippet to compile.
Definition: translate.cc:404
A structure that implements the computation of join(V1, V2).
Definition: join.hh:18
Definition: a-star.hh:8
bool is_linear() const
Whether linear identities are on.
Definition: identities.hh:84
Distributive plus optimizations.
Definition: identities.hh:44
std::string to_string(identities i)
Wrapper around operator<<.
Definition: identities.cc:38
bool operator!=(self_t that) const
Definition: identities.hh:111
static type join(rat::identities i1, rat::identities i2)
Definition: identities.hh:140
::vcsn::rat::identities identities
Sets of identities on expressions.
Definition: fwd.hh:17
std::ostream & operator<<(std::ostream &o, type_t t)
Print a expression type.
Definition: printer.hxx:13
std::istream & operator>>(std::istream &is, identities &i)
Read from string form.
Definition: identities.cc:63
identities(ids_t id=deflt)
Definition: identities.hh:50
The default value.
Definition: identities.hh:47