ASPECT
Functions
aspect::Plugins Namespace Reference

Functions

template<typename TestType , typename PluginType , typename = typename std::enable_if<std::is_base_of<PluginType,TestType>::value>::type>
bool plugin_type_matches (const PluginType &object)
 
template<typename TestType , typename PluginType , typename = typename std::enable_if<std::is_base_of<PluginType,TestType>::value>::type>
TestType & get_plugin_as_type (PluginType &object)
 

Function Documentation

§ plugin_type_matches()

template<typename TestType , typename PluginType , typename = typename std::enable_if<std::is_base_of<PluginType,TestType>::value>::type>
bool aspect::Plugins::plugin_type_matches ( const PluginType &  object)
inline

This function returns if a given plugin (e.g. a material model returned from SimulatorAccess::get_material_model() ) matches a certain plugin type (e.g. MaterialModel::Simple). This check is needed, because often it is only possible to get a reference to an Interface, not the actual plugin type, but the actual plugin type might be important. For example a radial gravity model might only be implemented for spherical geometry models, and would want to check if the current geometry is in fact a spherical shell.

This function can only be called with types that correspond to the same plugin system. In other words, the type of the plugin has to either be derived from the type of the object being tested, or they have to both be derived from a common base class. This function is not appropriate to check whether a class TestType derived from an interface base class is also derived from a second base class PluginType. For these cases, use a dynamic_cast.

Definition at line 73 of file plugins.h.

§ get_plugin_as_type()

template<typename TestType , typename PluginType , typename = typename std::enable_if<std::is_base_of<PluginType,TestType>::value>::type>
TestType& aspect::Plugins::get_plugin_as_type ( PluginType &  object)
inline

This function converts a reference to a type (in particular a reference to an interface class) into a reference to a different type (in particular a plugin class). This allows accessing members of the plugin that are not specified in the interface class. Note that you should first check if the plugin type is actually convertible by calling plugin_matches_type() before calling this function. If the plugin is not convertible this function throws an exception.

This function can only be called with types that correspond to the same plugin system. In other words, the type of the plugin has to either be derived from the type of the object being tested, or they have to both be derived from a common base class. This function is not appropriate to convert references to classes whether a class TestType derived from an interface base class is also derived from a second base class PluginType. For these cases, use a dynamic_cast.

Definition at line 99 of file plugins.h.