Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
transition.hh
Go to the documentation of this file.
1 #ifndef VCSN_CORE_TRANSITION_HH
2 # define VCSN_CORE_TRANSITION_HH
3 
4 # include <vcsn/empty.hh>
5 
6 # include <vcsn/misc/attributes.hh>
7 
8 namespace vcsn
9 {
10 
11  /*------------------------------------.
12  | possibly_labeled_transition_tuple. |
13  `------------------------------------*/
14 
15  template<class State, class Label>
17  {
18  State src;
19  State dst;
20 
21  using label_t = Label;
22  label_t get_label() const { return label; }
23  void set_label(label_t& l) { label = l; }
24 
25  private:
26  Label label;
27  };
28 
29  template<class State>
31  {
32  State src;
33  State dst;
34 
35  using label_t = empty_t;
36  label_t get_label() const { return {}; }
37  void set_label(label_t) {}
38  };
39 
40 
41  /*-------------------.
42  | transition_tuple. |
43  `-------------------*/
44 
45  template<class State, class Label, class Weight>
47  : possibly_labeled_transition_tuple<State, Label>
48  {
49  using weight_t = Weight;
50  weight_t get_weight() const { return weight; }
51  void set_weight(weight_t& k) { weight = k; }
52 
53  private:
55  };
56 
57  // We do not store the Boolean weights, which are assumed to be
58  // always true. This is correct for weight in the Boolean ring, as
59  // well as for those in the F₂ (a.k.a. ℤ/2ℤ) field, both encoded
60  // using the bool type.
61  template<class State, class Label>
62  struct transition_tuple<State, Label, bool>
63  : possibly_labeled_transition_tuple<State, Label>
64  {
65  using weight_t = bool;
66  weight_t get_weight() const { return true; }
67  void set_weight(weight_t& k) ATTRIBUTE_PURE { (void) k; assert(k == true); }
68  };
69 
70 }
71 
72 #endif // !VCSN_CORE_TRANSITION_HH
void set_weight(weight_t &k) ATTRIBUTE_PURE
Definition: transition.hh:67
void set_weight(weight_t &k)
Definition: transition.hh:51
Empty labels, for LAO.
Definition: empty.hh:9
weight_t get_weight() const
Definition: transition.hh:50