Awali
Another Weighted Automata library
traits.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef AWALI_CTX_TRAITS_HH
18 # define AWALI_CTX_TRAITS_HH
19 
20 # include <memory>
21 
22 #include <awali/sttc/core/rat/identities.hh> // FIXME: likely useless
23 
24 namespace awali {
25  namespace sttc {
26  namespace internal {
28  template <typename T>
29  using base_t
30  = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
31  }
32 
33 
34 
35  /*------------------.
36  | Computing types. |
37  `------------------*/
38 
39 # define DEFINE(Type) \
40  namespace internal \
41  { \
42  template <typename ValueSet> \
43  struct Type ## _of_impl \
44  { \
45  using type = typename ValueSet::Type; \
46  }; \
47  } \
48 
49  DEFINE(context_t)
51  DEFINE(labelset_t)
53  DEFINE(weightset_t)
54 
55 # undef DEFINE
56 # define DEFINE(Type) \
57  template <typename ValueSet> \
58  using Type ## _of \
59  = typename internal::Type ## _of_impl<internal::base_t<ValueSet>>::type;
60 
66  DEFINE(context_t)
76  DEFINE(labelset_t)
86  DEFINE(weightset_t)
87 
88 # undef DEFINE
89 
90 
91  /*------------------.
92  | shared pointers. |
93  `------------------*/
94 
95  // Forward traits about shared_ptr<T> to T.
96  namespace internal
97  {
98 # define DEFINE(Traits) \
99  template <typename ValueSet> \
100  struct Traits ## _t_of_impl<std::shared_ptr<ValueSet>> \
101  : Traits ## _t_of_impl<base_t<ValueSet>> \
102  {};
103 
105  DEFINE(label)
106  DEFINE(labelset)
107  DEFINE(weight)
109 # undef DEFINE
110  }
111 }}//end of ns awali::stc
112 
113 #endif // !AWALI_CTX_TRAITS_HH
carries the algebraic settings of automata
Definition: context.hh:40
#define DEFINE(Type)
Definition: traits.hh:98
weightset_description weightset(const std::string &k)
any_t label_t
Type for (transition) labels; it is an alias to any_t since its precise type depends on the weightset...
Definition: typedefs.hh:48
any_t weight_t
Type for (transition) weights; it is an alias to any_t since the its precise type depends on the weig...
Definition: typedefs.hh:61
typename std::remove_cv< typename std::remove_reference< T >::type >::type base_t
T without reference or const/volatile qualifiers.
Definition: traits.hh:30
Main namespace of Awali.
Definition: ato.hh:22