Generic AppFactory class for building Application objects. More...
#include <AppFactory.h>
Classes | |
class | ClearAppParamsKey |
Class that is used as a parameter to clearAppParams() that allows only MooseApp to call clearAppParams(). More... | |
Public Member Functions | |
virtual | ~AppFactory () |
template<typename T > | |
void | reg (const std::string &name) |
Register a new object. More... | |
InputParameters | getValidParams (const std::string &name) |
Get valid parameters for the object. More... | |
const InputParameters & | getAppParams (const InputParameters ¶ms) const |
void | clearAppParams (const InputParameters ¶ms, const ClearAppParamsKey) |
Clears the stored parameters for the given application parameteres. More... | |
const auto & | registeredObjects () const |
Returns a reference to the map from names to AppFactoryBuildInfo pointers. More... | |
bool | isRegistered (const std::string &app_name) const |
Returns a Boolean indicating whether an application type has been registered. More... | |
std::size_t | createdAppCount (const std::string &app_type) const |
const AppFactoryBuildInfoMap & | registeredObjectBuildInfos () const |
Returns the map of object name to a function pointer for building said object's input parameters. More... | |
std::unique_ptr< MooseApp > | create (const std::string &app_type, const std::string &name, InputParameters parameters, MPI_Comm COMM_WORLD_IN) |
Create a MooseApp given a set of parameters. More... | |
std::shared_ptr< MooseApp > | createShared (const std::string &app_type, const std::string &name, InputParameters parameters, MPI_Comm COMM_WORLD_IN) |
AppFactory (AppFactory const &)=delete | |
Don't allow creation through copy/move construction or assignment. More... | |
Registry & | operator= (AppFactory const &)=delete |
AppFactory (AppFactory &&)=delete | |
Registry & | operator= (AppFactory &&)=delete |
Static Public Member Functions | |
static AppFactory & | instance () |
Get the instance of the AppFactory. More... | |
static InputParameters | validParams () |
static std::unique_ptr< MooseApp > | create (const std::string &app_type, const std::vector< std::string > &cli_args={}) |
Create an app with no input and command line arguments. More... | |
static std::unique_ptr< MooseApp > | create (std::unique_ptr< Parser > parser, std::unique_ptr< CommandLine > command_line) |
Create a MooseApp from a Parser and CommandLine, both of which should have parsed. More... | |
static std::shared_ptr< MooseApp > | createAppShared (const std::string &default_app_type, int argc, char **argv, MPI_Comm comm_word=MPI_COMM_WORLD) |
Deprecated helper function for creating a MooseApp for Apps haven't adapted to the new Parser and Builder changes. More... | |
Static Public Attributes | |
static const std::string | main_app_name = "main" |
The name for the "main" moose application. More... | |
Protected Attributes | |
AppFactoryBuildInfoMap | _name_to_build_info |
Private Member Functions | |
const InputParameters & | storeAppParams (InputParameters ¶ms) |
Stores the given parameters within _input_parameters for app construction. More... | |
std::size_t | getAppParamsID (const InputParameters ¶ms) const |
Get the ID for the InputParameters associated with an application, used in storing them in _input_parameters. More... | |
AppFactory () | |
Private constructor for singleton pattern. More... | |
FRIEND_TEST (::AppFactoryTest, manageAppParams) | |
FRIEND_TEST (::AppFactoryTest, appCopyConstructParams) | |
FRIEND_TEST (::AppFactoryTest, createNotRegistered) | |
Private Attributes | |
std::map< std::size_t, std::unique_ptr< InputParameters > > | _input_parameters |
Storage of input parameters used in applications (ID (from getAppParamsID()) -> params) More... | |
Generic AppFactory class for building Application objects.
Definition at line 55 of file AppFactory.h.
|
virtual |
Definition at line 28 of file AppFactory.C.
|
delete |
Don't allow creation through copy/move construction or assignment.
|
delete |
|
inlineprivate |
Private constructor for singleton pattern.
Definition at line 218 of file AppFactory.h.
Referenced by instance().
void AppFactory::clearAppParams | ( | const InputParameters & | params, |
const ClearAppParamsKey | |||
) |
Clears the stored parameters for the given application parameteres.
See getAppParams() for why this is needed.
Definition at line 51 of file AppFactory.C.
Referenced by MooseApp::~MooseApp().
|
static |
Create an app with no input and command line arguments.
Useful for unit testing.
Definition at line 62 of file AppFactory.C.
Referenced by create(), MultiApp::createApp(), createAppShared(), Moose::createMooseApp(), createShared(), and MooseServer::parseDocumentForDiagnostics().
|
static |
Create a MooseApp from a Parser and CommandLine, both of which should have parsed.
Definition at line 77 of file AppFactory.C.
std::unique_ptr< MooseApp > AppFactory::create | ( | const std::string & | app_type, |
const std::string & | name, | ||
InputParameters | parameters, | ||
MPI_Comm | COMM_WORLD_IN | ||
) |
Create a MooseApp given a set of parameters.
The Parser must be set in the _parser param and the CommandLine must be set in the _command_line param, both of which must have been parsed.
app_type | Type of the application being constructed |
name | Name for the object |
parameters | Parameters this object should have |
Definition at line 138 of file AppFactory.C.
|
static |
Deprecated helper function for creating a MooseApp for Apps haven't adapted to the new Parser and Builder changes.
This function needed to be removed after the new Parser and Builder merged
Definition at line 95 of file AppFactory.C.
std::size_t AppFactory::createdAppCount | ( | const std::string & | app_type | ) | const |
Definition at line 189 of file AppFactory.C.
std::shared_ptr< MooseApp > AppFactory::createShared | ( | const std::string & | app_type, |
const std::string & | name, | ||
InputParameters | parameters, | ||
MPI_Comm | COMM_WORLD_IN | ||
) |
Definition at line 180 of file AppFactory.C.
|
private |
|
private |
|
private |
const InputParameters & AppFactory::getAppParams | ( | const InputParameters & | params | ) | const |
name
This is needed because we poorly decided to not pass references of the InputParameters in all derived MooseApp objects. This enables the MooseApp to get the copy of the parameters that it was actually built with using this factory.
Definition at line 42 of file AppFactory.C.
|
private |
Get the ID for the InputParameters associated with an application, used in storing them in _input_parameters.
This is needed until app constructors do not copy construct parameters. See getAppParams() for more information.
The parameters passed in here (from the app) could be copy-constructed parameters, but will contain a "_app_params_id" parameter that allows us to get the actual parameters (owned by this factory).
Definition at line 214 of file AppFactory.C.
Referenced by clearAppParams(), and getAppParams().
InputParameters AppFactory::getValidParams | ( | const std::string & | name | ) |
Get valid parameters for the object.
name | Name of the object whose parameter we are requesting |
Definition at line 33 of file AppFactory.C.
Referenced by create(), MultiApp::createApp(), and createAppShared().
|
static |
Get the instance of the AppFactory.
Definition at line 18 of file AppFactory.C.
Referenced by JsonSyntaxTree::addGlobal(), create(), MultiApp::createApp(), MultiApp::createApps(), createAppShared(), Moose::createMooseApp(), createShared(), MooseApp::dynamicAppRegistration(), MooseServer::parseDocumentForDiagnostics(), MultiApp::validParams(), and MooseApp::~MooseApp().
|
inline |
Returns a Boolean indicating whether an application type has been registered.
Definition at line 169 of file AppFactory.h.
Referenced by MultiApp::createApp(), and reg().
|
delete |
|
delete |
void AppFactory::reg | ( | const std::string & | name | ) |
Register a new object.
name | Name of the object to register |
Definition at line 232 of file AppFactory.h.
|
inline |
Returns the map of object name to a function pointer for building said object's input parameters.
Definition at line 183 of file AppFactory.h.
|
inline |
Returns a reference to the map from names to AppFactoryBuildInfo pointers.
Definition at line 164 of file AppFactory.h.
Referenced by MultiApp::validParams().
|
private |
Stores the given parameters within _input_parameters for app construction.
Also calls finalize() on the parameters
Definition at line 200 of file AppFactory.C.
Referenced by create().
|
static |
|
private |
Storage of input parameters used in applications (ID (from getAppParamsID()) -> params)
Definition at line 227 of file AppFactory.h.
Referenced by clearAppParams(), getAppParams(), and storeAppParams().
|
protected |
Definition at line 194 of file AppFactory.h.
Referenced by create(), createdAppCount(), getValidParams(), isRegistered(), reg(), registeredObjectBuildInfos(), and registeredObjects().
|
static |
The name for the "main" moose application.
Definition at line 69 of file AppFactory.h.
Referenced by create(), MooseBase::messagePrefix(), and MooseServer::parseDocumentForDiagnostics().