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 
17 template <>
20 {
22 
23  params.addParam<std::vector<std::string>>("register_objects_from",
24  "The names of other applications from which objects "
25  "will be registered from (dynamic registration).");
26  params.addParam<std::vector<std::string>>(
27  "object_names", "The names of the objects to register (Default: register all).");
28  params.addParam<std::string>("library_path",
29  "",
30  "Path to search for dynamic libraries (please "
31  "avoid committing absolute paths in addition to "
32  "MOOSE_LIBRARY_PATH)");
33  params.addParam<std::string>(
34  "library_name",
35  "",
36  "The file name of the library (*.la file) that will be dynamically loaded.");
37  return params;
38 }
39 
41  : Action(parameters)
42 {
48  if (isParamValid("register_objects_from"))
49  {
50  // Only register the requested objects
51  if (isParamValid("object_names"))
52  _factory.restrictRegisterableObjects(getParam<std::vector<std::string>>("object_names"));
53 
54  std::vector<std::string> application_names =
55  getParam<std::vector<std::string>>("register_objects_from");
56  for (const auto & app_name : application_names)
57  {
59  &_factory,
61  &_awh.syntax(),
62  getParam<std::string>("library_path"),
63  getParam<std::string>("library_name"));
64  }
65  }
66 }
67 
68 void
70 {
71 }
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:172
bool isParamValid(const std::string &name) const
Definition: Action.h:115
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:207
ActionFactory & _action_factory
Builds Actions.
Definition: Action.h:189
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: Action.h:224
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:186
registerMooseAction("MooseApp", DynamicObjectRegistrationAction, "dynamic_object_registration")
Base class for actions.
Definition: Action.h:35
DynamicObjectRegistrationAction(InputParameters parameters)
InputParameters validParams< DynamicObjectRegistrationAction >()
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
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...
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:1138
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:183
InputParameters validParams< Action >()
Definition: Action.C:22