Awali
Another Weighted Automata library
abstract_context.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2021 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef DYN_ABSTRACT_CONTEXT_HH
18 #define DYN_ABSTRACT_CONTEXT_HH
19 
20 #include<memory>
21 #include<string>
22 #include<vector>
23 #include<list>
24 
25 #include <awali/dyn/core/any.hh>
27 
28 
29 namespace awali { namespace dyn {
30 
35 
41  virtual std::string sname() const =0;
42 
49  virtual std::string vname(bool full = true) const =0;
50 
52  virtual std::string labelset_name() const =0;
53 
55  virtual std::string weightset_name(std::string format="text") const =0;
56 
58  virtual std::vector<any_t> alphabet() const = 0;
59 
60  /* Returns the object representing epsilon.
61  *
62  * @beware Although printing the returned value of this function would give
63  * `\e`, it is not an std::string internally.
64  */
65  virtual label_t epsilon() const = 0;
66 
68  virtual bool is_eps_allowed() const = 0;
69 
71  virtual void add_letter(label_t let) = 0;
72 
74  virtual bool has_letter(label_t let) const = 0;
75 
79  virtual bool show_one() const = 0;
80 
83  virtual weight_t weight_one() const = 0;
84 
88  virtual weight_t weight_zero() const = 0;
89  virtual bool is_finite_weightset() const =0;
90  virtual bool is_locally_finite_weightset() const =0;
91 
92  virtual weight_t add_weights(weight_t l, weight_t r) const = 0;
93  virtual weight_t mul_weights(weight_t l, weight_t r) const = 0;
94  virtual weight_t div_weights(weight_t l, weight_t r) const = 0;
95 
96  virtual weight_t get_weight(std::string w) const =0;
97  virtual label_t get_label(std::string w) const =0;
98  virtual label_t get_label(std::string w, size_t i) const =0;
99 
100  virtual std::string weight_to_string(weight_t w) const=0;
101  virtual std::string label_to_string(label_t w) const=0;
102 
103 
104  virtual std::list<any_t> expand_label(any_t l) const=0;
105 
106 
107  virtual ~abstract_context_t() {}
108  };
109 
110 
111 }}//end of ns awali::dyn
112 #endif
awali::dyn::abstract_context_t::expand_label
virtual std::list< any_t > expand_label(any_t l) const =0
awali::dyn::abstract_context_t::weight_zero
virtual weight_t weight_zero() const =0
Gives the value zero, that is, the neutral additive element of the weightset.
awali
Main namespace of Awali.
Definition: ato.hh:22
awali::version::full
static const std::string full
Completely version of Awali as a std::string.
Definition: version.hh:40
awali::dyn::abstract_context_t::weightset_name
virtual std::string weightset_name(std::string format="text") const =0
Gives the name of the weightset.
awali::dyn::abstract_context_t::vname
virtual std::string vname(bool full=true) const =0
Returns the runtime internal name of the context.
awali::dyn::abstract_context_t::weight_to_string
virtual std::string weight_to_string(weight_t w) const =0
awali::dyn::any_t
Structure used to erase the type of labels/weights at the dyn layer.
Definition: any.hh:53
awali::dyn::abstract_context_t::label_to_string
virtual std::string label_to_string(label_t w) const =0
awali::dyn::abstract_context_t::add_letter
virtual void add_letter(label_t let)=0
Adds a letter in the alphabet.
awali::dyn::abstract_context_t::has_letter
virtual bool has_letter(label_t let) const =0
Tests whether let is a valid letter.
awali::dyn::abstract_context_t::is_finite_weightset
virtual bool is_finite_weightset() const =0
awali::dyn::abstract_context_t::mul_weights
virtual weight_t mul_weights(weight_t l, weight_t r) const =0
awali::dyn::abstract_context_t::get_label
virtual label_t get_label(std::string w) const =0
awali::dyn::abstract_context_t
Abstract interface representing the weightset and labelset of an automaton, a rational expression or ...
Definition: abstract_context.hh:34
awali::dyn::abstract_context_t::add_weights
virtual weight_t add_weights(weight_t l, weight_t r) const =0
awali::dyn::abstract_context_t::~abstract_context_t
virtual ~abstract_context_t()
Definition: abstract_context.hh:107
awali::dyn::abstract_context_t::alphabet
virtual std::vector< any_t > alphabet() const =0
Returns the alphabet.
awali::dyn::abstract_context_t::weight_one
virtual weight_t weight_one() const =0
Returns the value one, that is, the neutral multiplicative element of the weightset.
awali::dyn::abstract_context_t::is_locally_finite_weightset
virtual bool is_locally_finite_weightset() const =0
awali::dyn::abstract_context_t::div_weights
virtual weight_t div_weights(weight_t l, weight_t r) const =0
awali::dyn::abstract_context_t::sname
virtual std::string sname() const =0
Returns the compile-time internal name of the context.
awali::sttc::format
auto format(const ValueSet &vs, const typename ValueSet::value_t &v, Args &&... args) -> std::string
Format v via vs.print.
Definition: stream.hh:109
awali::dyn::abstract_context_t::show_one
virtual bool show_one() const =0
Returns true if one (neutral multiplicative element of the weightset) should be printed in expression...
awali::dyn::abstract_context_t::epsilon
virtual label_t epsilon() const =0
awali::dyn::abstract_context_t::get_weight
virtual weight_t get_weight(std::string w) const =0
awali::dyn::abstract_context_t::is_eps_allowed
virtual bool is_eps_allowed() const =0
Returns true if epsilon is allowed as label.
awali::dyn::abstract_context_t::labelset_name
virtual std::string labelset_name() const =0
Gives the name of the labelset.
any.hh
typedefs.hh