Awali
Another Weighted Automata library
transition.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 AWALI_CORE_TRANSITION_HH
18 # define AWALI_CORE_TRANSITION_HH
19 
20 #include <awali/sttc/empty.hh>
21 
23 
24 namespace awali {
25  namespace sttc {
26 
27  namespace internal {
28  /*,------------------------------------.
29  | possibly_labeled_transition_tuple. |
30  `-----------------------------------*/
31 
32  template<class State, class Label>
34  {
35  State src;
36  State dst;
37 
38  using label_t = Label;
39  label_t get_label() const { return label; }
40  void set_label(label_t& l) { label = l; }
41 
42  private:
43  Label label;
44  };
45 
46  template<class State>
48  {
49  State src;
50  State dst;
51 
52  using label_t = empty_t;
53  label_t get_label() const { return {}; }
54  void set_label(label_t) {}
55  };
56  }
57 
58  /*-------------------.
59  | transition_tuple. |
60  `-------------------*/
61 
62  template<class State, class Label, class Weight>
65  {
66  using weight_t = Weight;
67  weight_t get_weight() const { return weight; }
68  void set_weight(weight_t& k) { weight = k; }
69 
70  private:
71  weight_t weight;
72  };
73 
74  // We do not store the Boolean weights, which are assumed to be
75  // always true. This is correct for weight in the Boolean ring, as
76  // well as for those in the F₂ (a.k.a. ℤ/2ℤ) field, both encoded
77  // using the bool type.
78  template<class State, class Label>
79  struct transition_tuple<State, Label, bool>
81  {
82  using weight_t = bool;
83  weight_t get_weight() const { return true; }
84  void set_weight(weight_t& k) { (void) k; assert(k == true); }
85  };
86 
87 }}//end of ns awali::stc
88 
89 #endif // !AWALI_CORE_TRANSITION_HH
Empty labels, for LAO.
Definition: empty.hh:28
Main namespace of Awali.
Definition: ato.hh:22
label_t get_label() const
Definition: transition.hh:39
void set_label(label_t &l)
Definition: transition.hh:40
weight_t get_weight() const
Definition: transition.hh:83
void set_weight(weight_t &k)
Definition: transition.hh:84
bool weight_t
Definition: transition.hh:82
Definition: transition.hh:65
weight_t get_weight() const
Definition: transition.hh:67
void set_weight(weight_t &k)
Definition: transition.hh:68
Weight weight_t
Definition: transition.hh:66