Vcsn  2.4
Be Rational
automaton-decorator.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/concepts/automaton.hh> // Automaton.
4 #include <vcsn/ctx/traits.hh>
5 #include <vcsn/misc/memory.hh>
6 
7 namespace vcsn
8 {
9  namespace detail
10  {
17  template <Automaton Aut,
18  typename Context = context_t_of<Aut>>
20  {
21  public:
23  using automaton_t = Aut;
24 
25  using context_t = Context;
26 
28  using element_type = typename automaton_t::element_type;
29 
32  template <typename Ctx = context_t>
33  using fresh_automaton_t
34  = typename element_type::template fresh_automaton_t<Ctx>;
35 
36  using kind_t = typename context_t::kind_t;
37 
38  using labelset_t = typename context_t::labelset_t;
39  using labelset_ptr = typename context_t::labelset_ptr;
40  using label_t = typename labelset_t::value_t;
41 
42  using weightset_t = typename context_t::weightset_t;
43  using weightset_ptr = typename context_t::weightset_ptr;
44  using weight_t = typename weightset_t::value_t;
45 
48 
50  : aut_{aut}
51  {}
52 
54  : aut_(aut.aut_)
55  {}
56 
59  {}
60 
62  {
63  std::swap(aut_, aut.aut_);
64  }
65 
67  {
68  if (this != &that)
69  aut_ = std::move(that.aut_);
70  return *this;
71  }
72 
77  {
78  return aut_;
79  }
80 
81  protected:
83  // Must be defined early to please decltype.
85 
86 
87  public:
88  /*------------.
89  | constexpr. |
90  `------------*/
91 
92 #define DEFINE(Name) \
93  template <typename... Args> \
94  static constexpr \
95  auto \
96  Name(Args&&... args) \
97  -> decltype(element_type::Name(std::forward<Args>(args)...)) \
98  { \
99  return element_type::Name(std::forward<Args>(args)...); \
100  }
101 
108 
109 #undef DEFINE
110 
111  /*--------.
112  | const. |
113  `--------*/
114 
115 #define DEFINE(Name) \
116  template <typename... Args> \
117  auto \
118  Name(Args&&... args) const \
119  -> decltype(aut_->Name(std::forward<Args>(args)...)) \
120  { \
121  return aut_->Name(std::forward<Args>(args)...); \
122  }
123 
156 
157 #undef DEFINE
158 
159 
160  /*------------.
161  | non const. |
162  `------------*/
163 
164 #define DEFINE(Name) \
165  template <typename... Args> \
166  auto \
167  Name(Args&&... args) \
168  -> decltype(aut_->Name(std::forward<Args>(args)...)) \
169  { \
170  return aut_->Name(std::forward<Args>(args)...); \
171  }
172 
193 
194 #undef DEFINE
195  };
196  }
197 }
auto labelset(Args &&...args) const -> decltype(aut_-> labelset(std::forward< Args >(args)...))
auto unset_final(Args &&...args) -> decltype(aut_-> unset_ final(std
auto is_initial(Args &&...args) const -> decltype(aut_-> is_initial(std::forward< Args >(args)...))
auto has_state(Args &&...args) const -> decltype(aut_-> has_state(std::forward< Args >(args)...))
auto new_state(Args &&...args) -> decltype(aut_-> new_state(std::forward< Args >(args)...))
auto all_transitions(Args &&...args) const -> decltype(aut_-> all_transitions(std::forward< Args >(args)...))
auto num_initials(Args &&...args) const -> decltype(aut_-> num_initials(std::forward< Args >(args)...))
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:13
auto del_transition(Args &&...args) -> decltype(aut_-> del_transition(std::forward< Args >(args)...))
auto new_transition_copy(Args &&...args) -> decltype(aut_-> new_transition_copy(std::forward< Args >(args)...))
auto is_lazy_in(Args &&...args) const -> decltype(aut_-> is_lazy_in(std::forward< Args >(args)...))
static constexpr auto pre(Args &&...args) -> decltype(element_type::pre(std::forward< Args >(args)...))
auto del_state(Args &&...args) -> decltype(aut_-> del_state(std::forward< Args >(args)...))
automaton_t strip()
The automaton we decorate.
auto num_all_states(Args &&...args) const -> decltype(aut_-> num_all_states(std::forward< Args >(args)...))
auto all_in(Args &&...args) const -> decltype(aut_-> all_in(std::forward< Args >(args)...))
auto src_of(Args &&...args) const -> decltype(aut_-> src_of(std::forward< Args >(args)...))
auto num_transitions(Args &&...args) const -> decltype(aut_-> num_transitions(std::forward< Args >(args)...))
#define Automaton
Definition: automaton.hh:23
Aggregate an automaton, and forward calls to it.
auto dst_of(Args &&...args) const -> decltype(aut_-> dst_of(std::forward< Args >(args)...))
auto print_set(Args &&...args) const -> decltype(aut_-> print_set(std::forward< Args >(args)...))
auto has_transition(Args &&...args) const -> decltype(aut_-> has_transition(std::forward< Args >(args)...))
auto is_final(Args &&...args) const -> decltype(aut_-> is_ final(std
static constexpr auto lazy_transition(Args &&...args) -> decltype(element_type::lazy_transition(std::forward< Args >(args)...))
auto num_finals(Args &&...args) const -> decltype(aut_-> num_ final s(std
auto set_final(Args &&...args) -> decltype(aut_-> set_ final(std
auto set_weight(Args &&...args) -> decltype(aut_-> set_weight(std::forward< Args >(args)...))
auto unset_initial(Args &&...args) -> decltype(aut_-> unset_initial(std::forward< Args >(args)...))
auto is_lazy(Args &&...args) const -> decltype(aut_-> is_lazy(std::forward< Args >(args)...))
auto set_transition(Args &&...args) -> decltype(aut_-> set_transition(std::forward< Args >(args)...))
auto num_states(Args &&...args) const -> decltype(aut_-> num_states(std::forward< Args >(args)...))
auto weight_of(Args &&...args) const -> decltype(aut_-> weight_of(std::forward< Args >(args)...))
auto prepost_label(Args &&...args) const -> decltype(aut_-> prepost_label(std::forward< Args >(args)...))
auto label_of(Args &&...args) const -> decltype(aut_-> label_of(std::forward< Args >(args)...))
auto get_transition(Args &&...args) const -> decltype(aut_-> get_transition(std::forward< Args >(args)...))
Definition: a-star.hh:8
static constexpr auto post(Args &&...args) -> decltype(element_type::post(std::forward< Args >(args)...))
auto set_lazy_in(Args &&...args) -> decltype(aut_-> set_lazy_in(std::forward< Args >(args)...))
static constexpr auto null_state(Args &&...args) -> decltype(element_type::null_state(std::forward< Args >(args)...))
auto add_transition_copy(Args &&...args) -> decltype(aut_-> add_transition_copy(std::forward< Args >(args)...))
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
Definition: traits.hh:64
auto state_has_name(Args &&...args) const -> decltype(aut_-> state_has_name(std::forward< Args >(args)...))
typename element_type::template fresh_automaton_t< Ctx > fresh_automaton_t
The (shared pointer) type to use it we have to create an automaton of the same (underlying) type...
automaton_decorator(const context_t &ctx)
auto get_final_weight(Args &&...args) const -> decltype(aut_-> get_ final _weight(std
auto add_weight(Args &&...args) -> decltype(aut_-> add_weight(std::forward< Args >(args)...))
auto add_initial(Args &&...args) -> decltype(aut_-> add_initial(std::forward< Args >(args)...))
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
Definition: traits.hh:65
auto set_initial(Args &&...args) -> decltype(aut_-> set_initial(std::forward< Args >(args)...))
automaton_decorator & operator=(automaton_decorator &&that)
auto print_state(Args &&...args) const -> decltype(aut_-> print_state(std::forward< Args >(args)...))
auto print_state_name(Args &&...args) const -> decltype(aut_-> print_state_name(std::forward< Args >(args)...))
auto print(Args &&...args) const -> decltype(aut_-> print(std::forward< Args >(args)...))
auto rweight(Args &&...args) -> decltype(aut_-> rweight(std::forward< Args >(args)...))
static constexpr auto sname(Args &&...args) -> decltype(element_type::sname(std::forward< Args >(args)...))
auto all_states(Args &&...args) const -> decltype(aut_-> all_states(std::forward< Args >(args)...))
automaton_decorator(automaton_decorator &&aut)
auto add_transition(Args &&...args) -> decltype(aut_-> add_transition(std::forward< Args >(args)...))
automaton_t aut_
The wrapped automaton, possibly const.
auto add_final(Args &&...args) -> decltype(aut_-> add_ final(std
auto set_lazy(Args &&...args) -> decltype(aut_-> set_lazy(std::forward< Args >(args)...))
automaton_decorator(const automaton_decorator &aut)
static constexpr auto null_transition(Args &&...args) -> decltype(element_type::null_transition(std::forward< Args >(args)...))
#define DEFINE(Name)
auto lweight(Args &&...args) -> decltype(aut_-> lweight(std::forward< Args >(args)...))
auto states(Args &&...args) const -> decltype(aut_-> states(std::forward< Args >(args)...))
auto get_initial_weight(Args &&...args) const -> decltype(aut_-> get_initial_weight(std::forward< Args >(args)...))
auto new_transition(Args &&...args) -> decltype(aut_-> new_transition(std::forward< Args >(args)...))
auto all_out(Args &&...args) const -> decltype(aut_-> all_out(std::forward< Args >(args)...))
auto weightset(Args &&...args) const -> decltype(aut_-> weightset(std::forward< Args >(args)...))