www.mooseframework.org
DynamicObjectRegistrationAction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "Factory.h"
12 #include "FEProblem.h"
13 #include "MooseApp.h"
14 
15 registerMooseAction("MooseApp", DynamicObjectRegistrationAction, "dynamic_object_registration");
16 
18 
21 {
23 
24  params.addParam<std::vector<std::string>>("register_objects_from",
25  "The names of other applications from which objects "
26  "will be registered from (dynamic registration).");
27  params.addParam<std::vector<std::string>>(
28  "object_names", "The names of the objects to register (Default: register all).");
29  params.addParam<std::string>("library_path",
30  "",
31  "Path to search for dynamic libraries (please "
32  "avoid committing absolute paths in addition to "
33  "MOOSE_LIBRARY_PATH)");
34  params.addParam<std::string>(
35  "library_name",
36  "",
37  "The file name of the library (*.la file) that will be dynamically loaded.");
38  return params;
39 }
40 
42  : Action(parameters)
43 {
49  if (isParamValid("register_objects_from"))
50  {
51  // Only register the requested objects
52  if (isParamValid("object_names"))
53  _factory.restrictRegisterableObjects(getParam<std::vector<std::string>>("object_names"));
54 
55  std::vector<std::string> application_names =
56  getParam<std::vector<std::string>>("register_objects_from");
57  for (const auto & app_name : application_names)
58  {
60  &_factory,
62  &_awh.syntax(),
63  getParam<std::string>("library_path"),
64  getParam<std::string>("library_name"));
65  }
66  }
67 }
68 
69 void
71 {
72 }
Action::_app
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:213
FEProblem.h
DynamicObjectRegistrationAction::act
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
Definition: DynamicObjectRegistrationAction.C:70
MooseApp::dynamicAllRegistration
void dynamicAllRegistration(const std::string &app_name, Factory *factory, ActionFactory *action_factory, Syntax *syntax, std::string library_path, const std::string &library_name)
Thes methods are called to register applications or objects on demand.
Definition: MooseApp.C:1225
DynamicObjectRegistrationAction::DynamicObjectRegistrationAction
DynamicObjectRegistrationAction(InputParameters parameters)
Definition: DynamicObjectRegistrationAction.C:41
InputParameters::addParam
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object.
Definition: InputParameters.h:1198
defineLegacyParams
defineLegacyParams(DynamicObjectRegistrationAction)
Action::_action_factory
ActionFactory & _action_factory
Builds Actions.
Definition: Action.h:219
Action
Base class for actions.
Definition: Action.h:39
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition: InputParameters.h:53
registerMooseAction
registerMooseAction("MooseApp", DynamicObjectRegistrationAction, "dynamic_object_registration")
Action::_factory
Factory & _factory
The Factory associated with the MooseApp.
Definition: Action.h:216
ActionWarehouse::syntax
Syntax & syntax()
Definition: ActionWarehouse.h:206
MooseApp.h
Factory::restrictRegisterableObjects
void restrictRegisterableObjects(const std::vector< std::string > &names)
Calling this object with a non-empty vector will cause this factory to ignore registrations from any ...
Definition: Factory.C:178
Action::isParamValid
bool isParamValid(const std::string &name) const
Definition: Action.h:144
DynamicObjectRegistrationAction::validParams
static InputParameters validParams()
Definition: DynamicObjectRegistrationAction.C:20
DynamicObjectRegistrationAction.h
Action::validParams
static InputParameters validParams()
Definition: Action.C:23
Action::_awh
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:237
DynamicObjectRegistrationAction
Definition: DynamicObjectRegistrationAction.h:19
Factory.h