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-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_BASIC_WEIGHTSET_HH
18 #define DYN_BASIC_WEIGHTSET_HH
19 
21 
22 namespace awali {
23 namespace dyn {
24 namespace context {
25 
27  private:
28  const std::string public_name;
29  const std::string class_name;
30  const std::vector<std::string> promotion;
31  const std::string desc;
32  public:
33  basic_weightset(const std::string& public_name,
34  const std::string& class_name,
35  std::initializer_list<std::string> pr,
36  const std::string& desc
37  ) : public_name(public_name), class_name(class_name),
38  promotion(pr) , desc(desc) {}
39 
40 
41  const std::string& tostring(weightset_description ws, bool dynamic) const override
42  {
43  return class_name;
44  }
45 
46  inline
47  const std::string& static_public_name() const override{
48  return public_name;
49  }
50 
51  inline
52  const std::string& static_desc() const override{
53  return desc;
54  }
55  //Returns an empty shared pointer if the string does not correspond to the weightset
56  weightset_description fromstring(const std::string &k) const override;
57 
58  inline
60  return fromstring(p->at("semiring")->to_string());
61  }
62 
63  bool is_promotable_to(weightset_description ws) const override ;
64 
65  virtual std::vector<std::string> const& possible_promotions() const override;
66 
67  virtual ~basic_weightset() {}
68  };
69 
70 
71  }
72  }
73 } //end of namespaces awali::dyn::context, awali::dyn, and awali
74 
75 #endif // DYN_BASIC_WEIGHTSET_HH
virtual std::string to_string() const
Coerces this node_t to an std::string.
Definition: node.hh:329
Definition: node.hh:365
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:36
Definition: basic_weightset.hh:26
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:33
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
virtual ~basic_weightset()
Definition: basic_weightset.hh:67
weightset_description parse_weightset(json::object_t const *p) const override
Definition: basic_weightset.hh:59
const std::string & static_public_name() const override
Definition: basic_weightset.hh:47
const std::string & static_desc() const override
Definition: basic_weightset.hh:52
const std::string & tostring(weightset_description ws, bool dynamic) const override
Definition: basic_weightset.hh:41