3 #include <vcsn/algos/fwd.hh>
24 template <
typename A,
typename I>
27 template <
typename Aut, std::size_t... I>
36 template <std::
size_t Tape,
typename Aut>
39 project_context<Tape, context_t_of<Aut>>>
46 "focus: requires labels_are_tuples");
48 "focus: invalid tape number");
68 using label_t =
typename labelset_t::value_t;
73 using weight_t =
typename weightset_t::value_t;
92 template <
typename =
void>
102 std::tuple_size<full_label_t>::value - Tape - 1>>;
131 aut_->print_set(o, fmt);
135 full_context_t full_context() const
137 return aut_->context();
140 context_t context() const
146 hidden_label_of(transition_t t) const
148 return hidden_label_of_(t, hidden_indices);
154 return hidden_one_<full_labelset_t>(hidden_indices);
160 return res_labelset_(hidden_indices);
164 std::shared_ptr<labelset_t>
167 return std::make_shared<labelset_t>(aut_->labelset()->template set<Tape>());
173 hidden_indices_t hidden_indices{};
175 static label_t hide_(full_label_t l)
177 return std::get<Tape>(l);
180 template <std::size_t... I>
181 res_label_t hidden_label_of_(transition_t t, index_sequence<I...>) const
183 full_label_t l = aut_->label_of(t);
184 return std::make_tuple(std::get<I>(l)...);
187 template <typename L, std::size_t... I>
188 vcsn::enable_if_t<L::has_one(), res_label_t>
189 hidden_one_(index_sequence<I...>) const
191 full_label_t l = aut_->labelset()->one();
192 return std::make_tuple(std::get<I>(l)...);
195 template <typename L, std::size_t... I>
196 vcsn::enable_if_t<!L::has_one(), res_label_t>
197 hidden_one_(index_sequence<I...>) const
199 raise("Should not get here");
202 template <std::size_t... I>
203 res_labelset_t res_labelset_(index_sequence<I...>) const
205 return res_labelset_t{std::get<I>(aut_->labelset()->sets())...};
210 /*----------------------------.
211 | const methods that change. |
212 `----------------------------*/
215 auto label_of(transition_t t) const
218 return hide_(aut_->label_of(t));
221 // FIXME: http://llvm.org/bugs/show_bug.cgi?id=20175.
222 // using super_t::out;
225 -> decltype(aut_->out(s))
234 std::vector<transition_t>
235 out(state_t s, label_t l) const
237 std::vector<transition_t> res;
238 for (auto t: aut_->all_out(s))
239 if (labelset()->equal(label_of(t), l))
249 std::vector<transition_t>
250 in(state_t s, label_t l) const
252 std::vector<transition_t> res;
253 for (auto t: aut_->all_in(s))
254 if (this->labelset()->equal(label_of(t), l))
259 // FIXME: Having support for predicates in
260 // mutable_automaton::get_transition would help.
262 get_transition(state_t src, state_t dst, label_t l) const
264 for (auto t: out(src, l))
265 if (aut_->dst_of(t) == dst)
267 return aut_->null_transition();
272 has_transition(state_t src, state_t dst, label_t l) const
274 return get_transition(src, dst, l) != aut_->null_transition();
277 using super_t::del_transition;
280 del_transition(state_t src, state_t dst, label_t l)
282 auto t = get_transition(src, dst, l);
283 if (t != aut_->null_transition())
284 aut_->del_transition(t);
288 template <typename A>
290 new_transition_copy(state_t src, state_t dst,
292 typename A::element_type::transition_t t,
293 bool transpose = false)
295 return aut_->new_transition_copy(src, dst,
296 aut->strip(), t, transpose);
300 template <typename A>
302 add_transition_copy(state_t src, state_t dst,
304 typename A::element_type::transition_t t,
305 bool transpose = false)
307 return aut_->add_transition_copy(src, dst,
308 aut->strip(), t, transpose);
311 #define DEFINE(Name, Sig) \
314 raise("focus: cannot provide " #Name); \
317 DEFINE(add_transition,
318 (state_t, state_t, label_t, weight_t) -> transition_t);
319 DEFINE(add_transition,
320 (state_t, state_t, label_t) -> transition_t);
321 DEFINE(new_transition,
322 (state_t, state_t, label_t, weight_t) -> transition_t);
323 DEFINE(new_transition,
324 (state_t, state_t, label_t) -> transition_t);
325 DEFINE(set_transition,
326 (state_t, state_t, label_t, weight_t) -> transition_t);
334 context_t context_ = make_project_context<Tape>(full_context());
338 template <unsigned Tape, typename Aut>
340 focus_automaton<Tape, Aut>
343 return std::make_shared<detail::focus_automaton_impl<Tape, Aut>>(aut);
352 template <typename Aut, typename Tape>
354 focus(const automaton& aut, integral_constant)
356 auto& a = aut->as<Aut>();
357 return make_automaton(vcsn::focus<Tape::value>(a));
Aut automaton_t
The type of the wrapped automaton.
std::shared_ptr< const weightset_t > weightset_ptr
context_t_of< automaton_t > full_context_t
Underlying automaton context.
std::string to_string(identities i)
Wrapper around operator<<.
std::ostream & print_set(std::ostream &o, format fmt={}) const
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
state_t_of< automaton_t > state_t
This automaton's state and transition types are those of the wrapped automaton.
labelset_t_of< Aut > ls_t
Aggregate an automaton, and forward calls to it.
typename context_t::labelset_t labelset_t
Exposed labelset.
concat_sequence< make_index_range_t< 0, Tape >, make_index_range_t< Tape+1, std::tuple_size< full_label_t >::value-Tape-1 >> hidden_indices_t
Indices of the remaining tapes.
SharedPtr make_shared_ptr(Args &&...args)
Same as std::make_shared, but parameterized by the shared_ptr type, not the (pointed to) element_type...
typename concat_index_sequence< S1, S2 >::type concat_sequence
typename res_labelset_t::value_t res_label_t
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
typename context_t::weightset_ptr weightset_ptr
static dyn::context ctx(const driver &d)
Get the context of the driver.
typename context_t::weightset_t weightset_t
Exposed weightset.
focus_automaton_impl(const automaton_t &aut)
focus_automaton_impl(const full_context_t &ctx)
Provide a variadic mul on top of a binary mul(), and one().
typename context_t::labelset_ptr labelset_ptr
typename labelset_t::value_t label_t
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
std::shared_ptr< const labelset_t > labelset_ptr
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
Read-write on an automaton, that hides all tapes but one.
typename hidden_label_type< Aut, hidden_indices_t >::type res_labelset_t
typename full_labelset_t::value_t full_label_t
Underlying automaton label.
std::shared_ptr< detail::focus_automaton_impl< Tape, Aut >> focus_automaton
A focus automaton as a shared pointer.
typename weightset_t::value_t weight_t
typename full_context_t::labelset_t full_labelset_t
Underlying automaton labelset.
focus_automaton< Tape, fresh_automaton_t_of< automaton_t, full_context_t >> fresh_automaton_t
The type of automata to produce this kind of automata.
automaton_t aut_
The wrapped automaton, possibly const.
typename make_index_range< S, L >::type make_index_range_t
transition_t_of< automaton_t > transition_t