Sequoia
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
sequoia::object::factory< Products > Class Template Reference

Generic factory with statically defined products. More...

#include <Factory.hpp>

Public Types

using key = std::string
 
using vessel = std::variant< Products... >
 
using names_iterator = utilities::iterator< const_storage_iterator, factory_dereference_policy< const_storage_iterator > >
 

Public Member Functions

template<class... Names>
requires (sizeof...(Names) == size()) && (std::is_constructible_v<std::string, Names> && ...)
 factory (Names... names)
 
template<class... Args>
requires (initializable_from<Products, Args...> && ...)
vessel make (std::string_view name, Args &&... args) const
 
template<class Product , class... Args>
requires ( (std::is_same_v<Product, Products> || ...) && (initializable_from<Products, Args...> && ...))
vessel make_or (std::string_view name, Args &&... args) const
 
names_iterator begin_names () const noexcept
 
names_iterator end_names () const noexcept
 

Static Public Member Functions

static constexpr std::size_t size () noexcept
 

Friends

bool operator== (const factory &, const factory &) noexcept=default
 

Detailed Description

template<class... Products>
requires (sizeof...(Products) > 0) && (std::movable<Products> && ...)
class sequoia::object::factory< Products >

Generic factory with statically defined products.

The constructor requires a list of unique key which are internally mapped to the products. To generate a product, clients should call one of make / make_or. The former throws if the supplied string does not match a key; the latter requires specification of a default product which is created in this situation.


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