57#ifndef LIB_MULTIFACT_H
58#define LIB_MULTIFACT_H
83 template<
typename TAR>
90 template<
class FUN,
typename... ARGS>
92 wrap (FUN create, ARGS&&... args)
noexcept
94 return create(std::forward<ARGS>(args)...);
103 template<
typename RAW>
106 using RawType = std::remove_pointer<RAW>::type;
110 template<
class FUN,
typename... ARGS>
112 wrap (FUN create, ARGS&&... args)
114 return ResultType (create(std::forward<ARGS>(args)...));
130 template<
typename TAR>
133 template<
typename RAW>
148 template<
class FUN,
typename... ARGS>
150 wrap (FUN create, ARGS&&... args)
152 return wrapper_(std::forward<BareType> (create(std::forward<ARGS>(args)...)));
170 template<
typename SIG,
typename ID>
207 template<
typename TY
208 ,
template<
class>
class Wrapper
224 template<
typename RET
226 ,
template<
class>
class Wrapper
254 template<
typename SIG
256 ,
template<
class>
class Wrapper = PassAsIs
259 :
public FabConfig<SIG,Wrapper>::WrapFunctor
290 template<
typename... ARGS>
294 static_assert (
sizeof...(ARGS) == _Conf::ARGUMENT_CNT,
295 "MultiFac instance invoked with the wrong number "
296 "of fabrication arguments. See template parameter SIG");
299 return this->wrap (creator, std::forward<ARGS>(args)...);
303 template<
typename... ARGS>
307 return this->
operator() (
id, std::forward<ARGS>(args)...);
314 template<
typename FUNC>
336 return std::bind (&SingleFact::operator()
Access point to singletons and other kinds of dependencies designated by type.
static Factory & factory()
Convenience shortcut for automatically setting up a production line, to fabricate a singleton instanc...
Creator createSingleton_accessFunction()
Singleton(MultiFact &factory, ID id)
lib::Depend< IMP > SingleFact
Factory for creating a family of objects by ID.
FabConfig< SIG, Wrapper > _Conf
void defineProduction(ID id, FUNC &&fun)
to set up a production line, associated with a specific ID
bool contains(ID id) const
Creator & selectProducer(ID const &id)
_Conf::WrappedProduct Product
_Fab::FactoryFunc Creator
Product operator()(ID const &id, ARGS &&...args)
Core operation of the factory: Select a production line and invoke the fabrication function.
Product invokeFactory(ID const &id, ARGS &&...args)
more legible alias for the function operator
Singleton services and Dependency Injection.
Lumiera error handling (C++ interface).
Policy: use a custom functor to finish the generated product.
Implementation namespace for support and library code.
LumieraError< LERR_(INVALID)> Invalid
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
Wrapper taking ownership, by wrapping into smart-ptr.
std::remove_pointer< RAW >::type RawType
std::shared_ptr< RawType > ResultType
ResultType wrap(FUN create, ARGS &&... args)
void defineFinalWrapper(WrapFunc &&fun)
std::function< ResultType(BareType)> WrapFunc
ResultType wrap(FUN create, ARGS &&... args)
Wrapper< RET > WrapFunctor
WrapFunctor::BareType BareProduct
WrapFunctor::ResultType WrappedProduct
BareProduct SIG_Fab(ARGS...)
BareProduct SIG_Fab(void)
Wrapper< TY > WrapFunctor
WrapFunctor::BareType BareProduct
WrapFunctor::ResultType WrappedProduct
Table of registered production functions for MultiFact.
bool contains(ID id) const
std::function< SIG > FactoryFunc
std::map< ID, FactoryFunc > producerTable_
void defineProduction(ID const &id, FactoryFunc fun)
FactoryFunc & select(ID const &id)
Dummy "wrapper", to perform the fabrication and return the unaltered product.
ResultType wrap(FUN create, ARGS &&... args) noexcept
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...