queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
AlgorithmFactory.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2017 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #ifndef QUESO_ALGORITHM_FACTORY_H
26 #define QUESO_ALGORITHM_FACTORY_H
27 
28 #include <queso/Factory.h>
29 #include <queso/GslVector.h>
30 #include <queso/GslMatrix.h>
31 #include <queso/VectorSpace.h>
32 #include <queso/Algorithm.h>
33 
34 namespace QUESO
35 {
36 
42 class AlgorithmFactory : public Factory<Algorithm<GslVector, GslMatrix> >
43 {
44 public:
48  AlgorithmFactory(const std::string & name)
50  {}
51 
55  virtual ~AlgorithmFactory() {}
56 
57  static void set_environment(const BaseEnvironment & env)
58  {
59  m_env = &env;
60  }
61 
62  static void set_tk(const BaseTKGroup<GslVector, GslMatrix> & tk)
63  {
64  m_tk = &tk;
65  }
66 
67 protected:
69 
70  static const BaseEnvironment * m_env;
72 
73 private:
79 };
80 
81 inline
84 {
85  queso_require_msg(m_env, "ERROR: must call set_environment() before building alg!");
86  queso_require_msg(m_tk, "ERROR: must call set_tk() before building alg!");
87 
89 
90  queso_assert(new_alg);
91 
92  return new_alg;
93 }
94 
100 template <class DerivedAlgorithm>
102 {
103 public:
104  AlgorithmFactoryImp(const std::string & name)
105  : AlgorithmFactory(name)
106  {}
107 
108  virtual ~AlgorithmFactoryImp() {}
109 
110 private:
112  {
114  new_alg.reset(new DerivedAlgorithm(*(this->m_env), *(this->m_tk)));
115  return new_alg;
116  }
117 
118 };
119 
120 } // namespace QUESO
121 
122 #endif // QUESO_ALGORITHM_FACTORY_H
virtual SharedPtr< Algorithm< GslVector, GslMatrix > >::Type create()
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:198
static void set_tk(const BaseTKGroup< GslVector, GslMatrix > &tk)
AlgorithmFactoryImp(const std::string &name)
static const BaseTKGroup< GslVector, GslMatrix > * m_tk
virtual SharedPtr< Algorithm< GslVector, GslMatrix > >::Type build_algorithm()
Class for matrix operations using GSL library.
Definition: GslMatrix.h:49
virtual SharedPtr< Algorithm< GslVector, GslMatrix > >::Type build_algorithm()=0
AlgorithmFactory(const std::string &name)
Class for vector operations using GSL library.
Definition: GslVector.h:49
This base class allows the representation of a transition kernel.
Definition: Algorithm.h:32
static void set_environment(const BaseEnvironment &env)
static const BaseEnvironment * m_env

Generated on Tue Jun 5 2018 19:48:54 for queso-0.57.1 by  doxygen 1.8.5