dune-typetree  2.4.1
simpletransformationdescriptors.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 
4 #ifndef DUNE_TYPETREE_SIMPLETRANSFORMATIONDESCRIPTORS_HH
5 #define DUNE_TYPETREE_SIMPLETRANSFORMATIONDESCRIPTORS_HH
6 
7 #include <array>
8 #include <memory>
9 
11 #include <dune/common/exceptions.hh>
12 
13 
14 namespace Dune {
15  namespace TypeTree {
16 
22  template<typename SourceNode, typename Transformation, typename TransformedNode>
24  {
25 
26  static const bool recursive = false;
27 
28  typedef TransformedNode transformed_type;
29  typedef std::shared_ptr<transformed_type> transformed_storage_type;
30 
31  static transformed_type transform(const SourceNode& s, const Transformation& t)
32  {
33  return transformed_type();
34  }
35 
36  static transformed_storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t)
37  {
38  return std::make_shared<transformed_type>();
39  }
40 
41  };
42 
43 
44  template<typename SourceNode, typename Transformation, template<typename Child, std::size_t> class TransformedNode>
46  {
47 
48  static const bool recursive = true;
49 
50  template<typename TC>
51  struct result
52  {
53  typedef TransformedNode<TC, SourceNode::CHILDREN> type;
54  typedef std::shared_ptr<type> storage_type;
55  };
56 
57  template<typename TC>
58  static typename result<TC>::type transform(const SourceNode& s, const Transformation& t, const std::array<std::shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
59  {
60  return typename result<TC>::type(children);
61  }
62 
63  template<typename TC>
64  static typename result<TC>::storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t, const std::array<std::shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
65  {
66  return std::make_shared<typename result<TC>::type>(children);
67  }
68 
69  };
70 
71 
72  template<typename SourceNode, typename Transformation, template<typename...> class TransformedNode>
74  {
75 
76  static const bool recursive = true;
77 
78  template<typename... TC>
79  struct result
80  {
81  typedef TransformedNode<TC...> type;
82  typedef std::shared_ptr<type> storage_type;
83  };
84 
85  template<typename... TC>
86  static typename result<TC...>::type transform(const SourceNode& s, const Transformation& t, std::shared_ptr<TC>... children)
87  {
88  return typename result<TC...>::type(children...);
89  }
90 
91  template<typename... TC>
92  static typename result<TC...>::storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t, std::shared_ptr<TC>... children)
93  {
94  return std::make_shared<typename result<TC...>::type>(children...);
95  }
96 
97  };
98 
100 
101  } // namespace TypeTree
102 } //namespace Dune
103 
104 #endif // DUNE_TYPETREE_SIMPLETRANSFORMATIONDESCRIPTORS_HH
TransformedNode transformed_type
Definition: simpletransformationdescriptors.hh:28
static transformed_storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t)
Definition: simpletransformationdescriptors.hh:36
TransformedNode< TC... > type
Definition: simpletransformationdescriptors.hh:81
Definition: simpletransformationdescriptors.hh:73
static result< TC >::storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t, const std::array< std::shared_ptr< TC >, result< TC >::type::CHILDREN > &children)
Definition: simpletransformationdescriptors.hh:64
static transformed_type transform(const SourceNode &s, const Transformation &t)
Definition: simpletransformationdescriptors.hh:31
Definition: simpletransformationdescriptors.hh:23
std::shared_ptr< type > storage_type
Definition: simpletransformationdescriptors.hh:54
static result< TC... >::type transform(const SourceNode &s, const Transformation &t, std::shared_ptr< TC >...children)
Definition: simpletransformationdescriptors.hh:86
std::shared_ptr< transformed_type > transformed_storage_type
Definition: simpletransformationdescriptors.hh:29
Definition: simpletransformationdescriptors.hh:79
static const bool recursive
Definition: simpletransformationdescriptors.hh:26
TransformedNode< TC, SourceNode::CHILDREN > type
Definition: simpletransformationdescriptors.hh:53
std::shared_ptr< type > storage_type
Definition: simpletransformationdescriptors.hh:82
Definition: accumulate_static.hh:12
Definition: simpletransformationdescriptors.hh:51
static result< TC >::type transform(const SourceNode &s, const Transformation &t, const std::array< std::shared_ptr< TC >, result< TC >::type::CHILDREN > &children)
Definition: simpletransformationdescriptors.hh:58
static result< TC... >::storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t, std::shared_ptr< TC >...children)
Definition: simpletransformationdescriptors.hh:92
Definition: simpletransformationdescriptors.hh:45