"Fossies" - the Fresh Open Source Software Archive 
Member "dune-typetree-2.8.0/test/typetreetargetnodes.hh" (31 Aug 2021, 3511 Bytes) of package /linux/misc/dune/dune-typetree-2.8.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 struct TargetLeaf
2 : public Dune::TypeTree::LeafNode
3 {
4
5 template<typename Transformation>
6 TargetLeaf(const SimpleLeaf& sl, const Transformation& t)
7 : s(Dune::stackobject_to_shared_ptr(sl))
8 {}
9
10 template<typename Transformation>
11 TargetLeaf(std::shared_ptr<const SimpleLeaf> sl, const Transformation& t)
12 : s(sl)
13 {}
14
15 std::shared_ptr<const SimpleLeaf> s;
16
17 const char* name() const
18 {
19 return "TargetLeaf";
20 }
21
22 int id() const
23 {
24 return s->id();
25 }
26
27 };
28
29 template<typename S, typename T, std::size_t k>
30 struct TargetPower
31 : public Dune::TypeTree::PowerNode<T,k>
32 {
33
34 template<typename Transformation>
35 TargetPower(const S& sc, const Transformation& t, const std::array<std::shared_ptr<T>,k>& children)
36 : Dune::TypeTree::PowerNode<T,k>(children)
37 , s(Dune::stackobject_to_shared_ptr(sc))
38 {}
39
40 template<typename Transformation>
41 TargetPower(std::shared_ptr<const S> sc, const Transformation& t, const std::array<std::shared_ptr<T>,k>& children)
42 : Dune::TypeTree::PowerNode<T,k>(children)
43 , s(sc)
44 {}
45
46 std::shared_ptr<const S> s;
47
48 const char* name() const
49 {
50 return "TargetPower";
51 }
52
53 int id() const
54 {
55 return s->id();
56 }
57
58
59 };
60
61
62 template<typename S, typename T>
63 struct TargetDynamicPower
64 : public Dune::TypeTree::DynamicPowerNode<T>
65 {
66
67 template<typename Transformation>
68 TargetDynamicPower(const S& sc, const Transformation& t, const std::vector<std::shared_ptr<T>>& children)
69 : Dune::TypeTree::DynamicPowerNode<T>(children)
70 , s(Dune::stackobject_to_shared_ptr(sc))
71 {}
72
73 template<typename Transformation>
74 TargetDynamicPower(std::shared_ptr<const S> sc, const Transformation& t, const std::vector<std::shared_ptr<T>>& children)
75 : Dune::TypeTree::DynamicPowerNode<T>(children)
76 , s(sc)
77 {}
78
79 std::shared_ptr<const S> s;
80
81 const char* name() const
82 {
83 return "TargetDynamicPower";
84 }
85
86 int id() const
87 {
88 return s->id();
89 }
90
91 };
92
93
94 template<typename S, typename... Children>
95 struct TargetComposite
96 : public Dune::TypeTree::CompositeNode<Children...>
97 {
98
99 template<typename Transformation>
100 TargetComposite(const S& sc, const Transformation& t, std::shared_ptr<Children>... children)
101 : Dune::TypeTree::CompositeNode<Children...>(children...)
102 , s(Dune::stackobject_to_shared_ptr(sc))
103 {}
104
105 template<typename Transformation>
106 TargetComposite(std::shared_ptr<const S> sc, const Transformation& t, std::shared_ptr<Children>... children)
107 : Dune::TypeTree::CompositeNode<Children...>(children...)
108 , s(sc)
109 {}
110
111 std::shared_ptr<const S> s;
112
113 const char* name() const
114 {
115 return "TargetComposite";
116 }
117
118 int id() const
119 {
120 return s->id();
121 }
122
123
124 };
125
126
127 struct TestTransformation {};
128
129 // register leaf node
130 template<typename SL>
131 Dune::TypeTree::GenericLeafNodeTransformation<SimpleLeaf,TestTransformation,TargetLeaf>
132 registerNodeTransformation(SL* sl, TestTransformation* t, SimpleLeafTag* tag);
133
134 template<typename SP>
135 Dune::TypeTree::GenericPowerNodeTransformation<SP,TestTransformation,TargetPower>
136 registerNodeTransformation(SP* sp, TestTransformation* t, SimplePowerTag* tag);
137
138 template<typename SDP>
139 Dune::TypeTree::GenericDynamicPowerNodeTransformation<SDP,TestTransformation,TargetDynamicPower>
140 registerNodeTransformation(SDP* sdp, TestTransformation* t, SimpleDynamicPowerTag* tag);
141
142 template<typename SC>
143 Dune::TypeTree::GenericCompositeNodeTransformation<SC,TestTransformation,TargetComposite>
144 registerNodeTransformation(SC* sc, TestTransformation* t, SimpleCompositeTag* tag);