17 #include "functions_base.hpp" 19 #include "context.hpp" 33 using element::element;
38 functions::scored_impls_list<Func>
select(
typename Func::params& params)
const 40 auto selector =
context()->
get<
typename Func::selector>();
41 return selector->select(params);
50 typename std::enable_if<std::is_base_of<functions::function_impl_execute<Func>,
typename Func::impl>::value,
51 std::shared_ptr<event>>::type
52 execute_function(
typename Func::params& params,
const std::vector<std::shared_ptr<event>>& dep_events = {})
const 54 auto impls = select<Func>(params);
55 if (impls.size() == 0)
60 return impls[0].second->execute(params, dep_events);
69 typename std::enable_if<std::is_base_of<functions::function_impl_command<Func>,
typename Func::impl>::value,
70 std::shared_ptr<event>>::type
71 execute_function(
typename Func::params& params,
const std::vector<std::shared_ptr<event>>& dep_events = {})
const 73 auto impls = select<Func>(params);
74 if (impls.size() == 0)
79 auto cmd_builder = impls[0].second->selected();
80 if (!cmd_builder)
throw std::logic_error(
"selected() is not implemented.");
81 auto cmd = cmd_builder(params);
82 return cmd->submit(dep_events);
functions::scored_impls_list< Func > select(typename Func::params ¶ms) const
Returns list of function implementations which accept specified function parameters.
std::enable_if< std::is_base_of< functions::function_impl_command< Func >, typename Func::impl >::value, std::shared_ptr< event > >::type execute_function(typename Func::params ¶ms, const std::vector< std::shared_ptr< event >> &dep_events={}) const
Executes a function.
Global library context provides access to all library objects.
Exception type indicates that provided actual function parameters are not supported.
Function implementations dispatcher.
std::enable_if< std::is_base_of< functions::function_impl_execute< Func >, typename Func::impl >::value, std::shared_ptr< event > >::type execute_function(typename Func::params ¶ms, const std::vector< std::shared_ptr< event >> &dep_events={}) const
Executes a function.
std::enable_if< std::is_base_of< element_base, T >::value, std::shared_ptr< T > >::type get(Args &&...args)
Construct or get an object owned by container (singleton lifetime).