www.mooseframework.org
DynamicObjectRegistrationAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
16 #include "Factory.h"
17 #include "FEProblem.h"
18 #include "MooseApp.h"
19 
20 template <>
23 {
25 
26  params.addParam<std::vector<std::string>>("register_objects_from",
27  "The names of other applications from which objects "
28  "will be registered from (dynamic registration).");
29  params.addParam<std::vector<std::string>>(
30  "object_names", "The names of the objects to register (Default: register all).");
31  params.addParam<std::string>("library_path",
32  "",
33  "Path to search for dynamic libraries (please "
34  "avoid committing absolute paths in addition to "
35  "MOOSE_LIBRARY_PATH)");
36  return params;
37 }
38 
40  : Action(parameters)
41 {
47  if (isParamValid("register_objects_from"))
48  {
49  // Only register the requested objects
50  if (isParamValid("object_names"))
51  _factory.restrictRegisterableObjects(getParam<std::vector<std::string>>("object_names"));
52 
53  std::vector<std::string> application_names =
54  getParam<std::vector<std::string>>("register_objects_from");
55  for (const auto & app_name : application_names)
56  {
57  _app.dynamicObjectRegistration(app_name, &_factory, getParam<std::string>("library_path"));
59  app_name, &_awh.syntax(), &_action_factory, getParam<std::string>("library_path"));
60  }
61  }
62 }
63 
64 void
66 {
67 }
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:82
void dynamicSyntaxAssociation(const std::string &app_name, Syntax *syntax, ActionFactory *action_factory, std::string library_path)
Definition: MooseApp.C:931
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:122
ActionFactory & _action_factory
Builds Actions.
Definition: Action.h:104
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Factory & _factory
The Factory associated with the MooseApp.
Definition: Action.h:101
Base class for actions.
Definition: Action.h:39
DynamicObjectRegistrationAction(InputParameters parameters)
InputParameters validParams< DynamicObjectRegistrationAction >()
bool isParamValid(const std::string &name) const
Definition: Action.h:80
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...
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:98
void dynamicObjectRegistration(const std::string &app_name, Factory *factory, std::string library_path)
Thes methods are called to register applications or objects on demand.
Definition: MooseApp.C:915
InputParameters validParams< Action >()
Definition: Action.C:23
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: Action.h:139