Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
automaton.hh
Go to the documentation of this file.
1 #ifndef VCSN_DYN_AUTOMATON_HH
2 # define VCSN_DYN_AUTOMATON_HH
3 
4 # include <memory> // shared_ptr
5 # include <string>
6 # include <vcsn/dyn/fwd.hh>
7 # include <vcsn/misc/export.hh>
8 
9 namespace vcsn
10 {
11  namespace dyn
12  {
13  namespace detail
14  {
17  {
18  public:
22  virtual std::string vname(bool full = true) const = 0;
23 
25  template <typename Aut>
26  Aut& as()
27  {
28  return dynamic_cast<automaton_wrapper<Aut>&>(*this).automaton();
29  }
30 
32  template <typename Aut>
33  const Aut& as() const
34  {
35  return dynamic_cast<const automaton_wrapper<Aut>&>(*this).automaton();
36  }
37  };
38 
40  template <typename Aut>
42  {
43  public:
44  using automaton_t = Aut;
45 
47  : automaton_(aut)
48  {}
49 
50  virtual std::string vname(bool full = true) const override
51  {
52  return automaton()->vname(full);
53  }
54 
56  {
57  return automaton_;
58  }
59 
60  const automaton_t& automaton() const
61  {
62  return automaton_;
63  }
64 
65  protected:
68  };
69  }
70 
71  using automaton = std::shared_ptr<detail::automaton_base>;
72 
74  template <typename Aut>
75  inline
76  automaton
77  make_automaton(const Aut& aut)
78  {
79  return std::make_shared<detail::automaton_wrapper<Aut>>(aut);
80  }
81  }
82 }
83 
84 #endif // !VCSN_DYN_AUTOMATON_HH
std::shared_ptr< detail::automaton_base > automaton
Definition: automaton.hh:71
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
Definition: automaton.hh:77
Aut & as()
Extract wrapped typed automaton.
Definition: automaton.hh:26
A wrapped typed automaton.
Definition: automaton.hh:41
const Aut & as() const
Extract wrapped typed automaton.
Definition: automaton.hh:33
automaton_t automaton_
The automaton.
Definition: automaton.hh:67
const automaton_t & automaton() const
Definition: automaton.hh:60
std::string vname(T &t)
Definition: name.hh:65
Base class for automata.
Definition: automaton.hh:16
virtual std::string vname(bool full=true) const override
A description of the automaton, sufficient to build it.
Definition: automaton.hh:50
#define LIBVCSN_API
Definition: export.hh:9