Ginkgo  Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
gko::EnableDefaultFactory< ConcreteFactory, ProductType, ParametersType, PolymorphicBase > Class Template Reference

This mixin provides a default implementation of a concrete factory. More...

#include <ginkgo/core/base/abstract_factory.hpp>

Inheritance diagram for gko::EnableDefaultFactory< ConcreteFactory, ProductType, ParametersType, PolymorphicBase >:
[legend]
Collaboration diagram for gko::EnableDefaultFactory< ConcreteFactory, ProductType, ParametersType, PolymorphicBase >:
[legend]

Public Types

using product_type = ProductType
 
using parameters_type = ParametersType
 
using polymorphic_base = PolymorphicBase
 
using abstract_product_type = typename PolymorphicBase::abstract_product_type
 
using components_type = typename PolymorphicBase::components_type
 
- Public Types inherited from gko::EnablePolymorphicAssignment< ConcreteFactory >
using result_type = ConcreteFactory
 
- Public Types inherited from gko::ConvertibleTo< ConcreteFactory >
using result_type = ConcreteFactory
 

Public Member Functions

template<typename... Args>
std::unique_ptr< product_type > generate (Args &&... args) const
 
const parameters_type & get_parameters () const noexcept
 Returns the parameters of the factory. More...
 
- Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< ConcreteFactory, PolymorphicBase >
std::unique_ptr< ConcreteFactory > create_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< ConcreteFactory > create_default () const
 
std::unique_ptr< ConcreteFactory > clone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< ConcreteFactory > clone () const
 
ConcreteFactory * copy_from (const PolymorphicObject *other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, ConcreteFactory > * copy_from (std::unique_ptr< Derived > &&other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, ConcreteFactory > * copy_from (const std::unique_ptr< Derived > &other)
 
ConcreteFactory * copy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
ConcreteFactory * move_from (ptr_param< PolymorphicObject > other)
 
ConcreteFactory * clear ()
 
- Public Member Functions inherited from gko::EnablePolymorphicAssignment< ConcreteFactory >
void convert_to (result_type *result) const override
 Converts the implementer to an object of type result_type. More...
 
void move_to (result_type *result) override
 Converts the implementer to an object of type result_type by moving data from this object. More...
 
- Public Member Functions inherited from gko::ConvertibleTo< ConcreteFactory >
void convert_to (ptr_param< result_type > result) const
 
void move_to (ptr_param< result_type > result)
 

Static Public Member Functions

static parameters_type create ()
 Creates a new ParametersType object which can be used to instantiate a new ConcreteFactory. More...
 

Friends

class EnablePolymorphicObject< ConcreteFactory, PolymorphicBase >
 

Detailed Description

template<typename ConcreteFactory, typename ProductType, typename ParametersType, typename PolymorphicBase>
class gko::EnableDefaultFactory< ConcreteFactory, ProductType, ParametersType, PolymorphicBase >

This mixin provides a default implementation of a concrete factory.

It implements all the methods of AbstractFactory and PolymorphicObject. Its implementation of the generate_impl() method delegates the creation of the product by calling the ProductType::ProductType(const ConcreteFactory *, const components_type &) constructor. The factory also supports parameters by using the ParametersType structure, which is defined by the user.

For a simple example, see IntFactory in core/test/base/abstract_factory.cpp.

Template Parameters
ConcreteFactorythe concrete factory which is being implemented [CRTP parameter]
ProductTypethe concrete type of products which this factory produces, has to be a subclass of PolymorphicBase::abstract_product_type
ParametersTypea type representing the parameters of the factory, has to inherit from the enable_parameters_type mixin
PolymorphicBaseparent of ConcreteFactory in the polymorphic hierarchy, has to be a subclass of AbstractFactory

Member Function Documentation

◆ create()

template<typename ConcreteFactory , typename ProductType , typename ParametersType , typename PolymorphicBase >
static parameters_type gko::EnableDefaultFactory< ConcreteFactory, ProductType, ParametersType, PolymorphicBase >::create ( )
inlinestatic

Creates a new ParametersType object which can be used to instantiate a new ConcreteFactory.

This method does not construct the factory directly, but returns a new parameters_type object, which can be used to set the parameters of the factory. Once the parameters have been set, the parameters_type::on() method can be used to obtain an instance of the factory with those parameters.

Returns
a default parameters_type object

◆ get_parameters()

template<typename ConcreteFactory , typename ProductType , typename ParametersType , typename PolymorphicBase >
const parameters_type& gko::EnableDefaultFactory< ConcreteFactory, ProductType, ParametersType, PolymorphicBase >::get_parameters ( ) const
inlinenoexcept

Returns the parameters of the factory.

Returns
the parameters of the factory

The documentation for this class was generated from the following file: