Ginkgo Generated from branch based on master. Ginkgo version 1.7.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
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
 
using components_type = typename PolymorphicBase::components_type
 
- Public Types inherited from gko::EnablePolymorphicAssignment< ConcreteFactory >
using result_type
 
- Public Types inherited from gko::ConvertibleTo< ResultType >
using result_type = ResultType
 

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.
 
- Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< AbstractObject, PolymorphicBase >
std::unique_ptr< AbstractObjectcreate_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractObjectcreate_default () const
 
std::unique_ptr< AbstractObjectclone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractObjectclone () const
 
AbstractObjectcopy_from (const PolymorphicObject *other)
 
template<typename Derived >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractObject > * copy_from (std::unique_ptr< Derived > &&other)
 
template<typename Derived >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractObject > * copy_from (const std::unique_ptr< Derived > &other)
 
AbstractObjectcopy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
AbstractObjectmove_from (ptr_param< PolymorphicObject > other)
 
AbstractObjectclear ()
 
- Public Member Functions inherited from gko::PolymorphicObject
PolymorphicObjectoperator= (const PolymorphicObject &)
 
std::unique_ptr< PolymorphicObjectcreate_default (std::shared_ptr< const Executor > exec) const
 Creates a new "default" object of the same dynamic type as this object.
 
std::unique_ptr< PolymorphicObjectcreate_default () const
 Creates a new "default" object of the same dynamic type as this object.
 
std::unique_ptr< PolymorphicObjectclone (std::shared_ptr< const Executor > exec) const
 Creates a clone of the object.
 
std::unique_ptr< PolymorphicObjectclone () const
 Creates a clone of the object.
 
PolymorphicObjectcopy_from (const PolymorphicObject *other)
 Copies another object into this object.
 
template<typename Derived , typename Deleter >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * copy_from (std::unique_ptr< Derived, Deleter > &&other)
 Moves another object into this object.
 
template<typename Derived , typename Deleter >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * copy_from (const std::unique_ptr< Derived, Deleter > &other)
 Copies another object into this object.
 
PolymorphicObjectcopy_from (const std::shared_ptr< const PolymorphicObject > &other)
 Copies another object into this object.
 
PolymorphicObjectmove_from (ptr_param< PolymorphicObject > other)
 Moves another object into this object.
 
PolymorphicObjectclear ()
 Transforms the object into its default state.
 
std::shared_ptr< const Executorget_executor () const noexcept
 Returns the Executor of the object.
 
- Public Member Functions inherited from gko::log::EnableLogging< PolymorphicObject >
void add_logger (std::shared_ptr< const Logger > logger) override
 Adds a new logger to the list of subscribed loggers.
 
void remove_logger (const Logger *logger) override
 Removes a logger from the list of subscribed loggers.
 
void remove_logger (ptr_param< const Logger > logger)
 
const std::vector< std::shared_ptr< const Logger > > & get_loggers () const override
 Returns the vector containing all loggers registered at this object.
 
void clear_loggers () override
 Remove all loggers registered at this object.
 
- Public Member Functions inherited from gko::log::Loggable
void remove_logger (ptr_param< const Logger > logger)
 
- 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.
 
void move_to (result_type *result) override
 Converts the implementer to an object of type result_type by moving data from this object.
 
- Public Member Functions inherited from gko::ConvertibleTo< ResultType >
virtual void convert_to (result_type *result) const =0
 Converts the implementer to an object of type result_type.
 
void convert_to (ptr_param< result_type > result) const
 
virtual void move_to (result_type *result)=0
 Converts the implementer to an object of type result_type by moving data from this object.
 
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.
 

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 Typedef Documentation

◆ abstract_product_type

Initial value:
typename PolymorphicBase::abstract_product_type

Member Function Documentation

◆ create()

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()

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: