https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
15registerMooseAction("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
67void
registerMooseAction("MooseApp", DynamicObjectRegistrationAction, "dynamic_object_registration")
Base class for actions.
Definition Action.h:38
static InputParameters validParams()
Definition Action.C:26
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition Action.h:169
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
DynamicObjectRegistrationAction(const InputParameters &parameters)
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:162
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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 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 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:2638
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition MooseBase.h:406
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
ActionFactory & _action_factory
Builds Actions.
Factory & _factory
The Factory associated with the MooseApp.