Cantera 2.6.0
WallFactory.h
Go to the documentation of this file.
1//! @file WallFactory.h
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef WALL_FACTORY_H
7#define WALL_FACTORY_H
8
10#include "cantera/zeroD/Wall.h"
11
12namespace Cantera
13{
14
15//! Factory class to create WallBase objects
16//!
17//! This class is mainly used via the newWall() function, for example:
18//!
19//! ```cpp
20//! unique_ptr<WallBase> piston(newWall("Wall"));
21//! ```
22//!
23//! @ingroup ZeroD
24class WallFactory : public Factory<WallBase>
25{
26public:
27 static WallFactory* factory() {
28 std::unique_lock<std::mutex> lock(wall_mutex);
29 if (!s_factory) {
30 s_factory = new WallFactory;
31 }
32 return s_factory;
33 }
34
35 virtual void deleteFactory() {
36 std::unique_lock<std::mutex> lock(wall_mutex);
37 delete s_factory;
38 s_factory = 0;
39 }
40
41 //! Create a new wall by type name.
42 /*!
43 * @param wallType the type to be created.
44 */
45 virtual WallBase* newWall(const std::string& wallType);
46
47private:
48 static WallFactory* s_factory;
49 static std::mutex wall_mutex;
51};
52
53//! Create a WallBase object of the specified type
54//! @ingroup ZeroD
55inline WallBase* newWall(const std::string& model)
56{
57 return WallFactory::factory()->newWall(model);
58}
59
60}
61
62#endif
File contains the FactoryBase class declarations.
Header file for base class WallBase.
Factory class that supports registering functions to create objects.
Definition: FactoryBase.h:70
Base class for 'walls' (walls, pistons, etc.) connecting reactors.
Definition: Wall.h:25
Factory class to create WallBase objects.
Definition: WallFactory.h:25
virtual WallBase * newWall(const std::string &wallType)
Create a new wall by type name.
Definition: WallFactory.cpp:21
virtual void deleteFactory()
Virtual abstract function that deletes the factory.
Definition: WallFactory.h:35
WallBase * newWall(const std::string &model)
Create a WallBase object of the specified type.
Definition: WallFactory.h:55
Namespace for the Cantera kernel.
Definition: AnyMap.h:29