1 #ifndef VCSN_ALGOS_BLIND_HH
2 # define VCSN_ALGOS_BLIND_HH
4 # include <vcsn/algos/fwd.hh>
17 template <
typename A,
typename I>
20 template <
typename Aut, std::size_t... I>
23 template <std::
size_t J>
24 using elem =
typename std::tuple_element<J,
31 template <
size_t Tape,
36 return {ctx.labelset()->template set<Tape>(), *ctx.weightset()};
39 template <
typename Context,
size_t Tape>
47 template <std::
size_t Tape,
typename Aut>
50 blind_context_t<context_t_of<Aut>, Tape>>
57 "blind: requires labels_are_tuples");
59 "blind: invalid tape number");
68 typename automaton_t::element_type::automaton_nocv_t>;
88 using label_t =
typename labelset_t::value_t;
93 using weight_t =
typename weightset_t::value_t;
100 std::tuple_size<full_label_t>::value - Tape - 1>::type>;
124 std::string
vname(
bool full =
true)
const
127 +
aut_->vname(full) +
">");
132 return aut_->context();
159 std::shared_ptr<labelset_t>
162 return std::make_shared<labelset_t>(
aut_->labelset()->template set<Tape>());
172 return std::get<Tape>(l);
175 template <std::size_t... I>
179 return std::make_tuple(std::get<I>(l)...);
182 template <
typename L, std::size_t... I>
183 typename std::enable_if<L::has_one(), res_label_t>::type
187 return std::make_tuple(std::get<I>(l)...);
190 template <
typename L, std::size_t... I>
191 typename std::enable_if<!L::has_one(), res_label_t>::type
194 raise(
"Should not get here");
197 template <std::size_t... I>
220 -> decltype(
aut_->out(s))
229 std::vector<transition_t>
232 std::vector<transition_t> res;
233 for (
auto t:
aut_->all_out(s))
244 std::vector<transition_t>
247 std::vector<transition_t> res;
248 for (
auto t:
aut_->all_in(s))
259 for (
auto t:
out(src, l))
260 if (
aut_->dst_of(t) == dst)
262 return aut_->null_transition();
278 if (t !=
aut_->null_transition())
279 aut_->del_transition(t);
283 template <
typename A>
287 typename A::element_type::transition_t t,
290 return aut_->new_transition_copy(src, dst,
295 template <
typename A>
299 typename A::element_type::transition_t t,
302 return aut_->add_transition_copy(src, dst,
306 #define DEFINE(Name, Sig) \
309 raise("blind: cannot provide " #Name); \
333 template <
unsigned Tape,
typename Aut>
338 return std::make_shared<detail::blind_automaton_impl<Tape, Aut>>(aut);
347 template <
typename Aut,
typename Tape>
351 auto& a = aut->as<Aut>();
362 #endif // !VCSN_ALGOS_BLIND_HH
void del_transition(state_t src, state_t dst, label_t l)
Apparent label of a transition.
typename context_t::weightset_ptr weightset_ptr
context_t_of< automaton_t > full_context_t
Underlying automaton context.
typename labelset_t::value_t label_t
blind_automaton_impl(const automaton_t &aut)
hidden_indices_t hidden_indices
std::shared_ptr< detail::automaton_base > automaton
blind_automaton< Tape, Aut > blind(Aut aut)
typename context_t::labelset_ptr labelset_ptr
context_t context_
Our apparent context.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
A ValueSet which is a Cartesian product of ValueSets.
typename weightset_t::value_t weight_t
transition_t new_transition_copy(state_t src, state_t dst, const A &aut, typename A::element_type::transition_t t, bool transpose=false)
Copy the full wrapped transition.
typename concat_index_sequence< S1, S2 >::type concat_sequence
std::string to_string(identities i)
typename context_t::weightset_t weightset_t
Exposed weightset.
transition_t_of< automaton_t > transition_t
auto set_transition(state_t, state_t, label_t, weight_t) -> transition_t
decltype(blind_context< Tape >(std::declval< Context >())) blind_context_t
std::enable_if<!L::has_one(), res_label_t >::type hidden_one_(index_sequence< I...>) const
auto out(state_t s) const -> decltype(aut_->out(s))
res_labelset_t res_labelset() const
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
weight_t add_transition_copy(state_t src, state_t dst, const A &aut, typename A::element_type::transition_t t, bool transpose=false)
Copy the full wrapped transition.
auto new_transition(state_t, state_t, label_t, weight_t) -> transition_t
std::string vname(bool full=true) const
std::shared_ptr< detail::blind_automaton_impl< Tape, Aut >> blind_automaton
A blind automaton as a shared pointer.
auto add_transition(state_t, state_t, label_t, weight_t) -> weight_t
#define DEFINE(Name, Sig)
res_labelset_t res_labelset_(index_sequence< I...>) const
static std::string sname()
typename res_labelset_t::value_t res_label_t
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
full_context_t full_context() const
Aggregate an automaton, and forward calls to it.
#define REGISTER_DECLARE(Name, Signature)
A simple placeholder for integral constants.
blind_automaton< Tape, typename automaton_t::element_type::automaton_nocv_t > automaton_nocv_t
The type of automata to produce this kind of automata.
auto blind_context(const context< LabelSet, WeightSet > &ctx) -> context< typename LabelSet::template valueset_t< Tape >, WeightSet >
std::vector< transition_t > out(state_t s, const label_t &l) const
Indexes of all transitions leaving state s on label l.
std::vector< transition_t > in(state_t s, const label_t &l) const
static label_t hide_(full_label_t l)
concat_sequence< typename make_index_range< 0, Tape >::type, typename make_index_range< Tape+1, std::tuple_size< full_label_t >::value-Tape-1 >::type > hidden_indices_t
Indices of the remaining tapes.
Read-write on an automaton, that hides all tapes but one.
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
typename hidden_label_type< Aut, hidden_indices_t >::type res_labelset_t
blind_automaton_impl(const full_context_t &ctx)
typename context_t::labelset_t labelset_t
Exposed labelset.
state_t_of< automaton_t > state_t
This automaton's state and transition types are those of the wrapped automaton.
typename full_context_t::labelset_t full_labelset_t
Underlying automaton labelset.
typename std::tuple_element< J, typename labelset_t_of< Aut >::valuesets_t >::type elem
res_label_t hidden_label_of(transition_t t) const
bool has_transition(state_t src, state_t dst, label_t l) const
Apparent label of a transition.
res_label_t hidden_label_of_(transition_t t, index_sequence< I...>) const
context_t context() const
std::shared_ptr< labelset_t > labelset() const
Apparent labelset.
transition_t get_transition(state_t src, state_t dst, label_t l) const
Aut transpose(const transpose_automaton< Aut > &aut)
std::enable_if< L::has_one(), res_label_t >::type hidden_one_(index_sequence< I...>) const
res_label_t hidden_one() const
blind_context_t< full_context_t, Tape > context_t
Exposed context.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
SharedPtr make_shared_ptr(Args &&...args)
Same as std::make_shared, but parameterized by the shared_ptr type, not the (pointed to) element_type...
auto label_of(transition_t t) const -> label_t
Apparent label of a transition.
auto in(Args &&...args) const -> decltype(aut_-> in(std::forward< Args >(args)...))
typename full_labelset_t::value_t full_label_t
Underlying automaton label.
auto del_transition(Args &&...args) -> decltype(aut_-> del_transition(std::forward< Args >(args)...))
Aut automaton_t
The type of the wrapped automaton.
automaton_t aut_
The wrapped automaton, possibly const.