AbstractFactory< AbstractProductType, ComponentsType > Class Template Reference#
|
Reference API
|
#include <ginkgo/core/base/abstract_factory.hpp>
Public Types | |
| using | abstract_product_type = AbstractProductType |
| using | components_type = ComponentsType |
Public Member Functions | |
| template<typename... Args> | |
| std::unique_ptr< abstract_product_type > | generate (Args &&... args) const |
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) |
| std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractFactory< AbstractProductType, ComponentsType > > * | copy_from (std::unique_ptr< Derived > &&other) |
| std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractFactory< AbstractProductType, ComponentsType > > * | copy_from (const std::unique_ptr< Derived > &other) |
| AbstractFactory< AbstractProductType, ComponentsType > * | copy_from (const std::shared_ptr< const PolymorphicObject > &other) |
| AbstractFactory< AbstractProductType, ComponentsType > * | move_from (ptr_param< PolymorphicObject > other) |
| AbstractFactory< AbstractProductType, ComponentsType > * | clear () |
Public Member Functions inherited from gko::PolymorphicObject | |
| PolymorphicObject & | operator= (const PolymorphicObject &) |
| std::unique_ptr< PolymorphicObject > | create_default (std::shared_ptr< const Executor > exec) const |
| std::unique_ptr< PolymorphicObject > | create_default () const |
| std::unique_ptr< PolymorphicObject > | clone (std::shared_ptr< const Executor > exec) const |
| std::unique_ptr< PolymorphicObject > | clone () const |
| PolymorphicObject * | copy_from (const PolymorphicObject *other) |
| 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) |
| 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) |
| PolymorphicObject * | copy_from (const std::shared_ptr< const PolymorphicObject > &other) |
| PolymorphicObject * | move_from (ptr_param< PolymorphicObject > other) |
| PolymorphicObject * | clear () |
| std::shared_ptr< const Executor > | get_executor () const noexcept |
Public Member Functions inherited from gko::log::EnableLogging< PolymorphicObject > | |
| void | add_logger (std::shared_ptr< const Logger > logger) override |
| void | remove_logger (const Logger *logger) override |
| void | remove_logger (ptr_param< const Logger > logger) |
| const std::vector< std::shared_ptr< const Logger > > & | get_loggers () const override |
| void | clear_loggers () override |
Public Member Functions inherited from gko::log::Loggable | |
| void | remove_logger (ptr_param< const Logger > logger) |
Protected Member Functions | |
| AbstractFactory (std::shared_ptr< const Executor > exec) | |
| virtual std::unique_ptr< abstract_product_type > | generate_impl (ComponentsType args) const =0 |
Protected Member Functions inherited from gko::PolymorphicObject | |
| PolymorphicObject (std::shared_ptr< const Executor > exec) | |
| PolymorphicObject (const PolymorphicObject &other) | |
| virtual std::unique_ptr< PolymorphicObject > | create_default_impl (std::shared_ptr< const Executor > exec) const =0 |
| virtual PolymorphicObject * | copy_from_impl (const PolymorphicObject *other)=0 |
| virtual PolymorphicObject * | copy_from_impl (std::unique_ptr< PolymorphicObject > other)=0 |
| virtual PolymorphicObject * | move_from_impl (PolymorphicObject *other)=0 |
| virtual PolymorphicObject * | move_from_impl (std::unique_ptr< PolymorphicObject > other)=0 |
| virtual PolymorphicObject * | clear_impl ()=0 |
Protected Member Functions inherited from gko::log::EnableLogging< PolymorphicObject > | |
| void | log (Params &&... params) const |
Additional Inherited Members | |
Protected Attributes inherited from gko::log::EnableLogging< PolymorphicObject > | |
| std::vector< std::shared_ptr< const Logger > > | loggers_ |
Detailed Description
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
-
AbstractProductType the type of products the factory produces ComponentsType the type of components the factory needs to produce the product
Constructor & Destructor Documentation
◆ AbstractFactory()
|
inlineprotected |
Constructs a new factory on the specified executor.
- Parameters
-
exec the executor where the factory should be constructed
Member Function Documentation
◆ generate()
|
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
-
Args types of arguments passed to the constructor of ComponentsType
- Parameters
-
args arguments passed to the constructor of ComponentsType
- Returns
- an instance of AbstractProductType
References gko::AbstractFactory< AbstractProductType, ComponentsType >::generate_impl().
◆ generate_impl()
|
protectedpure virtual |
Constructs a new product from the given components.
- Parameters
-
args the components from which to create the product
- Returns
- an instance of AbstractProductType
Referenced by gko::AbstractFactory< AbstractProductType, ComponentsType >::generate().
The documentation for this class was generated from the following file:
- ginkgo/core/base/abstract_factory.hpp
Generated by
Public Member Functions inherited from