FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
dynamic_factory.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
9#include <kernel/cubature/scalar/factory_wrapper.hpp>
10
11namespace FEAT
12{
13 namespace Cubature
14 {
15 namespace Scalar
16 {
18 {
19 private:
20 String _name;
21
22 public:
23 explicit DynamicFactory(const String& name) :
24 _name(name)
25 {
26 }
27
28 template<typename Weight_, typename Coord_>
29 bool create(Rule<Weight_, Coord_>& rule) const
30 {
31 return create(rule, _name);
32 }
33
34 template<typename Weight_, typename Coord_>
35 static bool create(Rule<Weight_, Coord_>& rule, const String& name)
36 {
37 CreateFunctor<Rule<Weight_, Coord_> > functor(rule, name);
38 FactoryWrapper::factory(functor);
39 return functor.okay();
40 }
41
43 private:
44 template<typename Rule_>
45 class CreateFunctor
46 {
47 private:
48 Rule_& _rule;
49 const String& _name;
50 bool _okay;
51
52 public:
53 CreateFunctor(Rule_& rule, const String& name) :
54 _rule(rule),
55 _name(name),
56 _okay(false)
57 {
58 }
59
60 template<typename Factory_>
61 void factory()
62 {
63 if(!_okay)
64 {
65 _okay = Factory_::create(_rule, _name);
66 }
67 }
68
69 bool okay() const
70 {
71 return _okay;
72 }
73 };
75 }; // class DynamicFactory
76 } // namespace Scalar
77 } // namespace Cubature
78} // namespace FEAT
Scalar Cubature Rule class template.
Definition: rule.hpp:39
String class implementation.
Definition: string.hpp:46
FEAT namespace.
Definition: adjactor.hpp:12