Awali
Another Weighted Automata library
automaton_decorator.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 AWALI_CORE_AUTOMATON_DECORATOR_HH
18 # define AWALI_CORE_AUTOMATON_DECORATOR_HH
19 
21 #include <awali/sttc/ctx/traits.hh>
22 
23 namespace awali { namespace sttc {
24 
25  namespace internal
26  {
33  template <typename Aut,
34  typename Context = context_t_of<Aut>>
36  {
37  public:
39  using automaton_t = Aut;
40 
43  using automaton_nocv_t = typename automaton_t::element_type::automaton_nocv_t;
44 
45  using context_t = Context;
46  using kind_t = typename context_t::kind_t;
47 
48  using labelset_t = typename context_t::labelset_t;
49  using labelset_ptr = typename context_t::labelset_ptr;
50  using label_t = typename labelset_t::value_t;
51 
52  using weightset_t = typename context_t::weightset_t;
53  using weightset_ptr = typename context_t::weightset_ptr;
54  using weight_t = typename weightset_t::value_t;
55 
56  public:
58  : aut_{aut}
59  {}
60 
62  : aut_(aut.aut_)
63  {}
64 
67  {}
68 
70  {
71  std::swap(aut_, aut.aut_);
72  }
73 
75  {
76  if (this != &that)
77  aut_ = std::move(that.aut_);
78  return *this;
79  }
80 
83  {
84  return aut_;
85  }
86 
87  protected:
89  // Must be defined early to please decltype.
91 
92 
93  public:
94  /*------------.
95  | constexpr. |
96  `------------*/
97 
98 # define DEFINE(Name) \
99  template <typename... Args> \
100  static constexpr \
101  auto \
102  Name(Args&&... args) \
103  -> decltype(automaton_t::element_type::Name(std::forward<Args>(args)...)) \
104  { \
105  return automaton_t::element_type::Name(std::forward<Args>(args)...); \
106  }
107 
113 
114 #undef DEFINE
115 
116  /*--------.
117  | const. |
118  `--------*/
119 
120 # define DEFINE(Name) \
121  template <typename... Args> \
122  auto \
123  Name(Args&&... args) const \
124  -> decltype(aut_->Name(std::forward<Args>(args)...)) \
125  { \
126  return aut_->Name(std::forward<Args>(args)...); \
127  }
128 
162 
163 # undef DEFINE
164 
165 
166  /*------------.
167  | non const. |
168  `------------*/
169 
170 # define DEFINE(Name) \
171  template <typename... Args> \
172  auto \
173  Name(Args&&... args) \
174  -> decltype(aut_->Name(std::forward<Args>(args)...)) \
175  { \
176  return aut_->Name(std::forward<Args>(args)...); \
177  }
178 
197 
198 # undef DEFINE
199  };
200  }
201 }}//end of ns awali::stc
202 
203 #endif // !AWALI_CORE_AUTOMATON_DECORATOR_HH
#define DEFINE(Name)
Definition: automaton_decorator.hh:170
carries the algebraic settings of automata
Definition: context.hh:40
Aggregate an automaton, and forward calls to it.
Definition: automaton_decorator.hh:36
auto dst_of(Args &&... args) const -> decltype(aut_-> dst_of(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:134
auto final_transitions(Args &&... args) const -> decltype(aut_-> final _transitions(std
Definition: automaton_decorator.hh:135
auto set_transition(Args &&... args) -> decltype(aut_-> set_transition(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:193
auto print_state_name(Args &&... args) const -> decltype(aut_-> print_state_name(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:155
auto label_of(Args &&... args) const -> decltype(aut_-> label_of(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:145
auto new_transition_copy(Args &&... args) -> decltype(aut_-> new_transition_copy(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:189
Aut automaton_t
The type of automaton to wrap.
Definition: automaton_decorator.hh:39
auto weight_of(Args &&... args) const -> decltype(aut_-> weight_of(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:160
static constexpr auto post(Args &&... args) -> decltype(automaton_t::element_type::post(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:110
typename context_t::kind_t kind_t
Definition: automaton_decorator.hh:46
auto add_final(Args &&... args) -> decltype(aut_-> add_ final(std
Definition: automaton_decorator.hh:179
auto set_initial(Args &&... args) -> decltype(aut_-> set_initial(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:192
auto outin(Args &&... args) const -> decltype(aut_-> outin(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:153
automaton_decorator(automaton_decorator &&aut)
Definition: automaton_decorator.hh:69
static constexpr auto sname(Args &&... args) -> decltype(automaton_t::element_type::sname(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:112
auto print_state(Args &&... args) const -> decltype(aut_-> print_state(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:154
auto is_initial(Args &&... args) const -> decltype(aut_-> is_initial(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:144
static constexpr auto null_state(Args &&... args) -> decltype(automaton_t::element_type::null_state(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:108
auto states(Args &&... args) const -> decltype(aut_-> states(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:157
auto all_out(Args &&... args) const -> decltype(aut_-> all_out(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:130
automaton_decorator & operator=(automaton_decorator &&that)
Definition: automaton_decorator.hh:74
auto src_of(Args &&... args) const -> decltype(aut_-> src_of(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:156
auto add_initial(Args &&... args) -> decltype(aut_-> add_initial(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:180
auto has_state(Args &&... args) const -> decltype(aut_-> has_state(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:140
auto num_initials(Args &&... args) const -> decltype(aut_-> num_initials(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:149
auto num_all_states(Args &&... args) const -> decltype(aut_-> num_all_states(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:147
auto labelset(Args &&... args) const -> decltype(aut_-> labelset(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:146
auto new_transition(Args &&... args) -> decltype(aut_-> new_transition(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:188
auto add_weight(Args &&... args) -> decltype(aut_-> add_weight(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:183
automaton_decorator(const automaton_decorator &aut)
Definition: automaton_decorator.hh:61
static constexpr auto pre(Args &&... args) -> decltype(automaton_t::element_type::pre(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:111
auto is_final(Args &&... args) const -> decltype(aut_-> is_ final(std
Definition: automaton_decorator.hh:143
typename context_t::labelset_ptr labelset_ptr
Definition: automaton_decorator.hh:49
typename labelset_t::value_t label_t
Definition: automaton_decorator.hh:50
auto unset_initial(Args &&... args) -> decltype(aut_-> unset_initial(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:196
auto add_state(Args &&... args) -> decltype(aut_-> add_state(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:187
auto initial_transitions(Args &&... args) const -> decltype(aut_-> initial_transitions(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:142
auto transitions(Args &&... args) const -> decltype(aut_-> transitions(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:158
auto num_finals(Args &&... args) const -> decltype(aut_-> num_ final s(std
Definition: automaton_decorator.hh:148
auto num_transitions(Args &&... args) const -> decltype(aut_-> num_transitions(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:151
typename context_t::weightset_ptr weightset_ptr
Definition: automaton_decorator.hh:53
auto in(Args &&... args) const -> decltype(aut_-> in(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:141
static constexpr auto null_transition(Args &&... args) -> decltype(automaton_t::element_type::null_transition(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:109
auto has_transition(Args &&... args) const -> decltype(aut_-> has_transition(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:139
auto all_in(Args &&... args) const -> decltype(aut_-> all_in(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:129
typename automaton_t::element_type::automaton_nocv_t automaton_nocv_t
The (shared pointer) type to use it we have to create an automaton of the same (underlying) type.
Definition: automaton_decorator.hh:43
auto del_state(Args &&... args) -> decltype(aut_-> del_state(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:184
Context context_t
Definition: automaton_decorator.hh:45
typename weightset_t::value_t weight_t
Definition: automaton_decorator.hh:54
auto add_transition_copy(Args &&... args) -> decltype(aut_-> add_transition_copy(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:182
auto num_states(Args &&... args) const -> decltype(aut_-> num_states(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:150
automaton_decorator(const context_t &ctx)
Definition: automaton_decorator.hh:65
auto get_initial_weight(Args &&... args) const -> decltype(aut_-> get_initial_weight(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:137
auto vname(Args &&... args) const -> decltype(aut_-> vname(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:159
auto weightset(Args &&... args) const -> decltype(aut_-> weightset(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:161
automaton_decorator(automaton_t aut)
Definition: automaton_decorator.hh:57
automaton_t strip_history()
Definition: automaton_decorator.hh:82
auto out(Args &&... args) const -> decltype(aut_-> out(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:152
typename context_t::labelset_t labelset_t
Definition: automaton_decorator.hh:48
auto rmul_weight(Args &&... args) -> decltype(aut_-> rmul_weight(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:190
auto set_weight(Args &&... args) -> decltype(aut_-> set_weight(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:194
automaton_t aut_
The wrapped automaton, possibly const.
Definition: automaton_decorator.hh:90
auto set_final(Args &&... args) -> decltype(aut_-> set_ final(std
Definition: automaton_decorator.hh:191
auto unset_final(Args &&... args) -> decltype(aut_-> unset_ final(std
Definition: automaton_decorator.hh:195
auto all_states(Args &&... args) const -> decltype(aut_-> all_states(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:131
auto get_final_weight(Args &&... args) const -> decltype(aut_-> get_ final _weight(std
Definition: automaton_decorator.hh:136
auto get_transition(Args &&... args) const -> decltype(aut_-> get_transition(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:138
auto add_transition(Args &&... args) -> decltype(aut_-> add_transition(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:181
typename context_t::weightset_t weightset_t
Definition: automaton_decorator.hh:52
auto del_transition(Args &&... args) -> decltype(aut_-> del_transition(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:185
auto all_transitions(Args &&... args) const -> decltype(aut_-> all_transitions(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:132
auto lmul_weight(Args &&... args) -> decltype(aut_-> lmul_weight(std::forward< Args >(args)...))
Definition: automaton_decorator.hh:186
SharedPtr make_shared_ptr(Args &&... args)
Same as std::make_shared, but parameterized by the shared_ptr type, not the (pointed to) element_type...
Definition: memory.hh:29
Main namespace of Awali.
Definition: ato.hh:22