Template Struct InterfaceTraits
Defined in File interface_traits.hpp
Struct Documentation
-
template<class T>
struct InterfaceTraits Customization point that allows setting additional properties of an interface class.
Users can crete specializations of this class for the base type for which the properties should be set. Properties are optional and therefore might not exist in a given specialization. To access these properties, use their respective accessor traits which provide the default value when it is not specified.
Supported properties:
constructor_parameters(member type)accessor: interface_constructor_parameters
default: ConstructorParameters<>
defines the parameters with which will the class loader instantiate the derived classes
example:
defines that derived classes of class T (replace with the base class type used in this specialization) will be instantiated withusing constructor_parameters = ConstructorParameters<double, int>;
doubleandintas their constructor arguments
Example:
class BaseWithInterfaceCtor { public: // constructor parameters for the base class do not need to match the derived classes explicit BaseWithInterfaceCtor(std::string) {} virtual ~BaseWithInterfaceCtor() = default; virtual int get_number() = 0; }; // Specialize the class_loader::InterfaceTraits struct to define properties of your interface template<> struct class_loader::InterfaceTraits<BaseWithInterfaceCtor> { // derived classes will be instantiated with two parameters (string and unique_ptr<int>) using constructor_parameters = ConstructorParameters<std::string, std::unique_ptr<int>>; };
- Template Parameters:
T – Base class for which the traits are defined