https://mooseframework.inl.gov
DynamicObjectRegistrationAction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 
19 {
21  params.addClassDescription("Register MooseObjects from other applications dynamically.");
22  params.addParam<std::vector<std::string>>("register_objects_from",
23  "The names of other applications from which objects "
24  "will be registered from (dynamic registration).");
25  params.addParam<std::vector<std::string>>(
26  "object_names", "The names of the objects to register (Default: register all).");
27  params.addParam<std::string>("library_path",
28  "",
29  "Path to search for dynamic libraries (please "
30  "avoid committing absolute paths in addition to "
31  "MOOSE_LIBRARY_PATH)");
32  params.addParam<std::string>(
33  "library_name",
34  "",
35  "The file name of the library (*.la file) that will be dynamically loaded.");
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  {
58  &_factory,
60  &_awh.syntax(),
61  getParam<std::string>("library_path"),
62  getParam<std::string>("library_name"));
63  }
64  }
65 }
66 
67 void
69 {
70 }
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:133
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:159
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
registerMooseAction("MooseApp", DynamicObjectRegistrationAction, "dynamic_object_registration")
Base class for actions.
Definition: Action.h:33
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Factory & _factory
The Factory associated with the MooseApp.
static InputParameters validParams()
Definition: Action.C:24
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
ActionFactory & _action_factory
Builds Actions.
DynamicObjectRegistrationAction(const InputParameters &parameters)
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional 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:2643