GRINS-0.8.0
catalycity_factory_abstract.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 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 GRINS_CATALYCITY_FACTORY_ABSTRACT_H
26 #define GRINS_CATALYCITY_FACTORY_ABSTRACT_H
27 
28 // GRINS
30 #include "grins/catalycity_base.h"
31 
32 namespace GRINS
33 {
34  // According to the standard, we need a declaration of the
35  // specialization which precedes any automatic instantiation.
37 
38  class CatalycityFactoryAbstract : public FactoryWithGetPot<CatalycityBase>
39  {
40  public:
41  CatalycityFactoryAbstract( const std::string& physics_name )
42  : FactoryWithGetPot<CatalycityBase>(physics_name)
43  {}
44 
46 
47  static void set_section( const std::string& section )
48  { _section = section; }
49 
50  protected:
51 
52  virtual libMesh::UniquePtr<CatalycityBase> build_catalycity( const GetPot& input,
53  const std::string& section ) =0;
54 
56  virtual void check_state() const;
57 
59  virtual void reset_state();
60 
61  static std::string _section;
62 
63  private:
64 
65  virtual libMesh::UniquePtr<CatalycityBase> create();
66  };
67 
68  inline
69  libMesh::UniquePtr<CatalycityBase> CatalycityFactoryAbstract::create()
70  {
71  this->check_state();
72 
73  libMesh::UniquePtr<CatalycityBase> new_catalycity = this->build_catalycity( *_input, _section );
74 
75  this->reset_state();
76 
77  return new_catalycity;
78  }
79 
80  inline
82  {
83  if( !_input )
84  libmesh_error_msg("ERROR: must call set_getpot() before building Catalycity!");
85 
86  if( _section == std::string("DIE!") )
87  libmesh_error_msg("ERROR: must call set_section() before building Catalycity!");
88  }
89 
90  inline
92  {
93  // Reset for error checking
94  _section = std::string("DIE!");
95  }
96 
97 } // end namespace GRINS
98 
99 #endif // GRINS_CATALYCITY_FACTORY_ABSTRACT_H
virtual libMesh::UniquePtr< CatalycityBase > build_catalycity(const GetPot &input, const std::string &section)=0
CatalycityFactoryAbstract(const std::string &physics_name)
static void set_section(const std::string &section)
GRINS namespace.
virtual void check_state() const
Helper function to reduce code duplication.
virtual void reset_state()
Helper function to reduce code duplication.
static const GetPot * _input
We store only a raw pointer here because we can't make a copy.
virtual libMesh::UniquePtr< CatalycityBase > create()
Subclasses implement the actual construction of the Base object in create().
Abstract factory that provides availability of GetPot.

Generated on Tue Dec 19 2017 12:47:27 for GRINS-0.8.0 by  doxygen 1.8.9.1