18 # define DEBUG_IFELSE(Then, Else) Then
20 # define DEBUG_IFELSE(Then, Else) Else
23 #define DEBUG_IF(Then) DEBUG_IFELSE(Then,)
30 template <Automaton Aut>
31 class name_automaton_impl
32 :
public automaton_decorator<Aut>
50 static auto res =
symbol{
"name_automaton<"
57 o <<
"name_automaton<";
63 using smap = std::unordered_map<state_name_t, state_t>;
67 state_t state(const state_name_t& r, state_t s)
75 state_t state(const state_name_t& r)
77 // Benches show that the map_.emplace technique is slower, and
78 // then that operator[] is faster than emplace.
80 auto i = map_.find(r);
81 if (i == std::end(map_))
82 res = state(r, super_t::new_state());
88 using super_t::add_transition;
90 add_transition(state_t src, state_name_t dst,
91 label_t l, const weight_t& w)
93 super_t::add_transition(src, state(dst), l, w);
96 using super_t::new_transition;
98 new_transition(state_t src, state_name_t dst,
99 label_t l, const weight_t& w)
101 super_t::new_transition(src, state(dst), l, w);
104 using super_t::set_initial;
106 set_initial(state_name_t s, const weight_t& w)
108 super_t::set_initial(state(s), w);
111 bool state_has_name(state_t s) const
113 return has(origins(), s);
117 print_state_name(state_t s, std::ostream& o,
121 auto i = origins().find(s);
122 if (i == std::end(origins()))
123 this->print_state(s, o);
130 using origins_t = std::map<state_t, state_name_t>;
131 mutable origins_t origins_;
135 if (origins_.empty())
136 for (const auto& p: map_)
137 origins_[p.second] = p.first;
static symbol sname()
Static name.
std::ostream & print_set(std::ostream &o, format fmt={}) const
name_automaton_impl(const context_t &ctx)
label_t_of< super_t > label_t
weight_t_of< super_t > weight_t
auto print_set(Args &&...args) const -> decltype(aut_-> print_set(std::forward< Args >(args)...))
An input/output format for valuesets.
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
state_t_of< super_t > state_t
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
Aggregate an automaton, and forward calls to it.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
context_t_of< automaton_t > context_t
static dyn::context ctx(const driver &d)
Get the context of the driver.