18 #ifndef FACTORY_IMPL_HH_ 19 #define FACTORY_IMPL_HH_ 26 template<
class Type,
class... Arguments>
29 static Factory<Type, Arguments...> factory;
34 template<
class Type,
class... Arguments>
37 auto creating_function =
38 [](Arguments... args)->std::shared_ptr<Type>
39 {
return std::make_shared<Child>(args...); };
41 auto func_wrapper = std::function<std::shared_ptr<Type>(Arguments...)>(creating_function);
48 template<
class Type,
class... Arguments>
52 auto it = factory_registry_.find(name);
53 if(
it != factory_registry_.end()) {
54 auto factory_function = boost::any_cast<std::function< shared_ptr<Type>(Arguments...)> > (
it->second);
55 return factory_function(arguments...);
57 THROW( ExcNotRegistredClass() << EI_KeyName(name) << EI_TypeName(
typeid(Type).name()) );
63 template <
class ChildType,
class... Arguments>
66 return Input::Factory<
typename ChildType::FactoryBaseType, Arguments...>::template register_class< ChildType >(class_name);
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.