17#include "gtest/gtest.h"
26#define registerApp(name) AppFactory::instance().reg<name>(#name)
44 return std::make_unique<T>(params);
75 static std::unique_ptr<MooseApp>
create(
const std::string & app_type,
76 const std::vector<std::string> & cli_args = {});
81 static std::unique_ptr<MooseApp>
create(std::unique_ptr<Parser> parser,
82 std::unique_ptr<CommandLine> command_line);
96 std::unique_ptr<MooseApp>
create(
const std::string & app_type,
97 const std::string & name,
99 MPI_Comm COMM_WORLD_IN);
100 std::shared_ptr<MooseApp>
createShared(
const std::string & app_type,
101 const std::string & name,
103 MPI_Comm COMM_WORLD_IN);
110 static std::shared_ptr<MooseApp>
createAppShared(
const std::string & default_app_type,
113 MPI_Comm comm_word = MPI_COMM_WORLD);
119 template <
typename T>
120 void reg(
const std::string & name);
146#ifdef MOOSE_UNIT_TEST
224#ifdef MOOSE_UNIT_TEST
std::map< std::string, std::unique_ptr< AppFactoryBuildInfoBase > > AppFactoryBuildInfoMap
class GTEST_TEST_CLASS_NAME_(AppFactoryTest, manageAppParams)
Class that is used as a parameter to clearAppParams() that allows only MooseApp to call clearAppParam...
ClearAppParamsKey(const ClearAppParamsKey &)
FRIEND_TEST(::AppFactoryTest, manageAppParams)
Generic AppFactory class for building Application objects.
bool isRegistered(const std::string &app_name) const
Returns a Boolean indicating whether an application type has been registered.
const AppFactoryBuildInfoMap & registeredObjectBuildInfos() const
Returns the map of object name to a function pointer for building said object's input parameters.
AppFactory(AppFactory &&)=delete
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 Bui...
std::size_t getAppParamsID(const InputParameters ¶ms) const
Get the ID for the InputParameters associated with an application, used in storing them in _input_par...
const InputParameters & getAppParams(const InputParameters ¶ms) const
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.
const InputParameters & storeAppParams(InputParameters ¶ms)
Stores the given parameters within _input_parameters for app construction.
Registry & operator=(AppFactory &&)=delete
void registerAppCapability(const std::string &app_name)
Register an application name as a capability.
FRIEND_TEST(::AppFactoryTest, createNotRegistered)
const auto & registeredObjects() const
Returns a reference to the map from names to AppFactoryBuildInfo pointers.
std::shared_ptr< MooseApp > createShared(const std::string &app_type, const std::string &name, InputParameters parameters, MPI_Comm COMM_WORLD_IN)
AppFactoryBuildInfoMap _name_to_build_info
std::size_t createdAppCount(const std::string &app_type) const
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.
static InputParameters validParams()
AppFactory()
Private constructor for singleton pattern.
static const std::string main_app_name
The name for the "main" moose application.
std::map< std::size_t, std::unique_ptr< InputParameters > > _input_parameters
Storage of input parameters used in applications (ID (from getAppParamsID()) -> params)
static AppFactory & instance()
Get the instance of the AppFactory.
FRIEND_TEST(::AppFactoryTest, manageAppParams)
FRIEND_TEST(::AppFactoryTest, appCopyConstructParams)
AppFactory(AppFactory const &)=delete
Don't allow creation through copy/move construction or assignment.
void reg(const std::string &name)
Register a new object.
void clearAppParams(const InputParameters ¶ms, const ClearAppParamsKey)
Clears the stored parameters for the given application parameteres.
Registry & operator=(AppFactory const &)=delete
Base class for MOOSE-based applications.
const std::string & name() const
Get the name of the class.
The registry is used as a global singleton to collect information on all available MooseObject and Ac...
Polymorphic data structure with parameter and object build access.
virtual ~AppFactoryBuildInfoBase()=default
std::size_t _app_creation_count
virtual InputParameters buildParameters()=0
virtual std::unique_ptr< MooseApp > build(const InputParameters ¶ms)=0
virtual InputParameters buildParameters() override
virtual std::unique_ptr< MooseApp > build(const InputParameters ¶ms) override