Ginkgo  Generated from pipelines/150876808 branch based on develop. Ginkgo version 1.1.1
A numerical linear algebra library targeting many-core architectures
Public Types | Public Member Functions | List of all members
gko::AbstractFactory< AbstractProductType, ComponentsType > Class Template Referenceabstract

The AbstractFactory is a generic interface template that enables easy implementation of the abstract factory design pattern. More...

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

Collaboration diagram for gko::AbstractFactory< AbstractProductType, ComponentsType >:
[legend]

Public Types

using abstract_product_type = AbstractProductType
 
using components_type = ComponentsType
 

Public Member Functions

template<typename... Args>
std::unique_ptr< AbstractProductType > generate (Args &&... args) const
 Creates a new product from the given components. More...
 
- Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< AbstractFactory< AbstractProductType, ComponentsType > >
std::unique_ptr< AbstractFactory< AbstractProductType, ComponentsType > > create_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractFactory< AbstractProductType, ComponentsType > > create_default () const
 
std::unique_ptr< AbstractFactory< AbstractProductType, ComponentsType > > clone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractFactory< AbstractProductType, ComponentsType > > clone () const
 
AbstractFactory< AbstractProductType, ComponentsType > * copy_from (const PolymorphicObject *other)
 
AbstractFactory< AbstractProductType, ComponentsType > * copy_from (std::unique_ptr< PolymorphicObject > other)
 
AbstractFactory< AbstractProductType, ComponentsType > * clear ()
 
- 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. More...
 
std::unique_ptr< PolymorphicObjectcreate_default () const
 Creates a new "default" object of the same dynamic type as this object. More...
 
std::unique_ptr< PolymorphicObjectclone (std::shared_ptr< const Executor > exec) const
 Creates a clone of the object. More...
 
std::unique_ptr< PolymorphicObjectclone () const
 Creates a clone of the object. More...
 
PolymorphicObjectcopy_from (const PolymorphicObject *other)
 Copies another object into this object. More...
 
PolymorphicObjectcopy_from (std::unique_ptr< PolymorphicObject > other)
 Moves another object into this object. More...
 
PolymorphicObjectclear ()
 Transforms the object into its default state. More...
 
std::shared_ptr< const Executorget_executor () const noexcept
 Returns the Executor of the object. More...
 
- 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. More...
 
void remove_logger (const Logger *logger) override
 Removes a logger from the list of subscribed loggers. More...
 

Detailed Description

template<typename AbstractProductType, typename ComponentsType>
class gko::AbstractFactory< AbstractProductType, ComponentsType >

The AbstractFactory is a generic interface template that enables easy implementation of the abstract factory design pattern.

The interface provides the AbstractFactory::generate() method that can produce products of type AbstractProductType using an object of ComponentsType (which can be constructed on the fly from parameters to its constructors). The generate() method is not declared as virtual, as this allows subclasses to hide the method with a variant that preserves the compile-time type of the objects. Instead, implementers should override the generate_impl() method, which is declared virtual.

Implementers of concrete factories should consider using the EnableDefaultFactory mixin to obtain default implementations of utility methods of PolymorphicObject and AbstractFactory.

Template Parameters
AbstractProductTypethe type of products the factory produces
ComponentsTypethe type of components the factory needs to produce the product

Member Function Documentation

◆ generate()

template<typename AbstractProductType, typename ComponentsType>
template<typename... Args>
std::unique_ptr<AbstractProductType> gko::AbstractFactory< AbstractProductType, ComponentsType >::generate ( Args &&...  args) const
inline

Creates a new product from the given components.

The method will create an ComponentsType object from the arguments of this method, and pass it to the generate_impl() function which will create a new AbstractProductType.

Template Parameters
Argstypes of arguments passed to the constructor of ComponentsType
Parameters
argsarguments passed to the constructor of ComponentsType
Returns
an instance of AbstractProductType

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