Skip to content

Commit

Permalink
Merge pull request #5956 from bangerth/manager-access-lists
Browse files Browse the repository at this point in the history
Provide functions that can access the elements of the lists stored in ManagerBase.
  • Loading branch information
gassmoeller authored Jul 3, 2024
2 parents 68fc05e + bd51808 commit f55c513
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions include/aspect/plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ namespace aspect
* to it. If no postprocessor is active that matches the given type,
* throw an exception.
*
* The returned object is necessarily an element in the list returned by
* `get_active_plugins()`, but cast to a derived type.
*
* This function can only be called if the given template type (the first template
* argument) is a class derived from the Interface class in this namespace.
*/
Expand All @@ -255,6 +258,23 @@ namespace aspect
const PluginType &
get_matching_active_plugin () const;

/**
* Return a list of plugin objects that have been requested in the
* parameter file and that are, consequently, active in the current
* manager object.
*/
const std::list<std::unique_ptr<InterfaceType>> &
get_active_plugins () const;

/**
* Return a list of names used in the input file to select plugins,
* and that are, consequently, active in the current manager object.
* The names in the returned list correspond to the objects returned
* by `get_active_plugins()`.
*/
const std::vector<std::string> &
get_active_plugin_names () const;

protected:
/**
* A list of plugin objects that have been requested in the
Expand Down Expand Up @@ -372,6 +392,25 @@ namespace aspect
// We will never get here, because we had the Assert above. Just to avoid warnings.
return Plugins::get_plugin_as_type<PluginType>(**(plugin_objects.begin()));
}



template <typename InterfaceType>
const std::list<std::unique_ptr<InterfaceType>> &
ManagerBase<InterfaceType>::get_active_plugins () const
{
return plugin_objects;
}



template <typename InterfaceType>
const std::vector<std::string> &
ManagerBase<InterfaceType>::get_active_plugin_names () const
{
return plugin_names;
}

}

namespace internal
Expand Down

0 comments on commit f55c513

Please sign in to comment.