LCOV - code coverage report
Current view: top level - src/actions - DynamicObjectRegistrationAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 24 25 96.0 %
Date: 2025-07-17 01:28:37 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      10             : #include "DynamicObjectRegistrationAction.h"
      11             : #include "Factory.h"
      12             : #include "FEProblem.h"
      13             : #include "MooseApp.h"
      14             : 
      15             : registerMooseAction("MooseApp", DynamicObjectRegistrationAction, "dynamic_object_registration");
      16             : 
      17             : InputParameters
      18       21639 : DynamicObjectRegistrationAction::validParams()
      19             : {
      20       21639 :   InputParameters params = Action::validParams();
      21       21639 :   params.addClassDescription("Register MooseObjects from other applications dynamically.");
      22       21639 :   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       21639 :   params.addParam<std::vector<std::string>>(
      26             :       "object_names", "The names of the objects to register (Default: register all).");
      27       21639 :   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       21639 :   params.addParam<std::string>(
      33             :       "library_name",
      34             :       "",
      35             :       "The file name of the library (*.la file) that will be dynamically loaded.");
      36       21639 :   return params;
      37           0 : }
      38             : 
      39       21434 : DynamicObjectRegistrationAction::DynamicObjectRegistrationAction(const InputParameters & parameters)
      40       21434 :   : Action(parameters)
      41             : {
      42             :   /**
      43             :    * Dynamic object registration must occur before parsing. The parser needs to retrieve parameters
      44             :    * for each
      45             :    * registered object that it must build.
      46             :    */
      47       21434 :   if (isParamValid("register_objects_from"))
      48             :   {
      49             :     // Only register the requested objects
      50           9 :     if (isParamValid("object_names"))
      51           2 :       _factory.restrictRegisterableObjects(getParam<std::vector<std::string>>("object_names"));
      52             : 
      53             :     std::vector<std::string> application_names =
      54           9 :         getParam<std::vector<std::string>>("register_objects_from");
      55          18 :     for (const auto & app_name : application_names)
      56             :     {
      57          18 :       _app.dynamicAllRegistration(app_name,
      58           9 :                                   &_factory,
      59           9 :                                   &_action_factory,
      60           9 :                                   &_awh.syntax(),
      61             :                                   getParam<std::string>("library_path"),
      62          18 :                                   getParam<std::string>("library_name"));
      63             :     }
      64           9 :   }
      65       21434 : }
      66             : 
      67             : void
      68       21411 : DynamicObjectRegistrationAction::act()
      69             : {
      70       21411 : }

Generated by: LCOV version 1.14