Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
expansion.hh
Go to the documentation of this file.
1 #ifndef VCSN_DYN_EXPANSION_HH
2 # define VCSN_DYN_EXPANSION_HH
3 
4 # include <memory>
5 # include <string>
6 
7 namespace vcsn
8 {
9  namespace dyn
10  {
11  namespace detail
12  {
15  {
16  public:
20  virtual std::string vname(bool full = true) const = 0;
21 
22  template <typename ExpansionSet>
24  {
25  return dynamic_cast<expansion_wrapper<ExpansionSet>&>(*this);
26  }
27 
28  template <typename ExpansionSet>
30  {
31  return dynamic_cast<const expansion_wrapper<ExpansionSet>&>(*this);
32  }
33  };
34 
36  template <typename ExpansionSet>
38  {
39  public:
40  using expansionset_t = ExpansionSet;
42  using expansion_t = typename expansionset_t::value_t;
45  : expansion_(expansion)
46  , expansionset_(expansionset)
47  {}
48  virtual ~expansion_wrapper() {}
49 
50  virtual std::string vname(bool full = true) const override
51  {
52  return expansionset().vname(full);
53  }
54 
55  const expansion_t expansion() const
56  {
57  return expansion_;
58  }
59 
61  {
62  return expansionset_;
63  }
64 
65  protected:
70  };
71 
72  } // namespace detail
73 
74  using expansion = std::shared_ptr<const detail::expansion_base>;
75 
76  template <typename ExpansionSet>
77  inline
78  expansion
79  make_expansion(const ExpansionSet& ps,
80  const typename ExpansionSet::value_t& expansion)
81  {
83  return std::make_shared<wrapper_t>(expansion, ps);
84  }
85  } // namespace dyn
86 } // namespace vcsn
87 
88 #endif // !VCSN_DYN_EXPANSION_HH
expansion_wrapper(const expansion_t &expansion, const expansionset_t &expansionset)
Definition: expansion.hh:43
virtual std::string vname(bool full=true) const =0
A description of the expansion.
expansion make_expansion(const ExpansionSet &ps, const typename ExpansionSet::value_t &expansion)
Definition: expansion.hh:79
const expansion_t expansion_
The expansion.
Definition: expansion.hh:67
const expansionset_t & expansionset() const
Definition: expansion.hh:60
virtual std::string vname(bool full=true) const override
A description of the expansion.
Definition: expansion.hh:50
const expansion_wrapper< ExpansionSet > & as() const
Definition: expansion.hh:29
expansion_wrapper< ExpansionSet > & as()
Definition: expansion.hh:23
const expansionset_t expansionset_
The expansion set.
Definition: expansion.hh:69
typename expansionset_t::value_t expansion_t
Definition: expansion.hh:42
std::shared_ptr< const detail::expansion_base > expansion
Definition: expansion.hh:74
Aggregate a expansion and its expansionset.
Definition: expansion.hh:37
const expansion_t expansion() const
Definition: expansion.hh:55
An abstract expansion.
Definition: expansion.hh:14