Awali
Another Weighted Automata library
basic_weightset.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 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_BASIC_WEIGHTSET_HH
18 #define DYN_BASIC_WEIGHTSET_HH
19 
21 
22 /* The description of each weightset is given in context_description.hh
23  where abstract_weightset objects are created
24 */
25 
26 namespace awali {
27 namespace dyn {
28 namespace context {
29 
31  private:
32  const std::string class_name;
33  const std::vector<std::string> promotion;
34  public:
35  basic_weightset(const std::string& public_name,
36  const std::string& class_name,
37  std::initializer_list<std::string> pr,
38  const std::string& desc
39  ) : abstract_weightset(public_name, desc), class_name(class_name),
40  promotion(pr) {}
41 
42  std::string const& tostring(weightset_description, bool) const override
43  {
44  return class_name;
45  }
46  //Returns an empty shared pointer if the string does not correspond to the weightset
47  weightset_description fromstring(const std::string &k) const override;
48 
49  inline
51  return fromstring(p->at("semiring")->to_string());
52  }
53 
54  bool is_promotable_to(weightset_description ws) const override ;
55 
56  virtual std::vector<std::string> const& possible_promotions() const override;
57 
58  virtual ~basic_weightset() {}
59  };
60 
61 
62  }
63  }
64 } //end of namespaces awali::dyn::context, awali::dyn, and awali
65 
66 #endif // DYN_BASIC_WEIGHTSET_HH
virtual std::string to_string() const
Coerces this node_t to an std::string.
Definition: node.hh:331
Definition: node.hh:367
virtual node_t * at(std::string const &key) override
std::shared_ptr< weightset_description_impl > weightset_description
Definition: description_types.hh:33
Main namespace of Awali.
Definition: ato.hh:22
Definition: abstract_weightset.hh:37
const std::string public_name
Definition: abstract_weightset.hh:41
const std::string desc
Definition: abstract_weightset.hh:42
Definition: basic_weightset.hh:30
basic_weightset(const std::string &public_name, const std::string &class_name, std::initializer_list< std::string > pr, const std::string &desc)
Definition: basic_weightset.hh:35
virtual std::vector< std::string > const & possible_promotions() const override
bool is_promotable_to(weightset_description ws) const override
weightset_description fromstring(const std::string &k) const override
std::string const & tostring(weightset_description, bool) const override
Definition: basic_weightset.hh:42
virtual ~basic_weightset()
Definition: basic_weightset.hh:58
weightset_description parse_weightset(json::object_t const *p) const override
Definition: basic_weightset.hh:50