14#define ADTF_UCOM_PROVIDES_IFUNCTION 1
27template <
typename Signature>
33template <
typename ResultType,
typename ...Arguments>
40 virtual ResultType
operator()(Arguments... args)
const = 0;
46template <
typename Signature>
52template <
typename Signature>
58template <
typename ResultType,
typename ...Arguments>
67 m_fnFunction(fnFunction)
78 ResultType operator()(Arguments... args)
const override
80 return m_fnFunction(std::forward<Arguments>(args)...);
84 std::function<ResultType(Arguments...)> m_fnFunction;
92template <
typename Function>
93struct function_traits :
public function_traits<decltype(&Function::operator())>
97template <
typename ClassType,
typename ReturnType,
typename... Arguments>
98struct function_traits<ReturnType(ClassType::*)(Arguments...) const>
100 using return_type = ReturnType;
102 template <std::
size_t Index>
103 using argument =
typename std::tuple_element<Index, std::tuple<Arguments...>>::type;
105 static constexpr std::size_t argument_count =
sizeof...(Arguments);
108template <
typename ClassType,
typename ReturnType,
typename... Arguments>
109struct function_traits<ReturnType(ClassType::*)(Arguments...)>
111 using return_type = ReturnType;
113 template <std::
size_t Index>
114 using argument =
typename std::tuple_element<Index, std::tuple<Arguments...>>::type;
116 static constexpr std::size_t argument_count =
sizeof...(Arguments);
119template<
typename FunctionTraits,
typename Unused>
122template<
typename FunctionTraits, std::size_t... Indices>
123struct signature<FunctionTraits, std::index_sequence<Indices...>>
125 using type =
typename FunctionTraits::return_type(
typename FunctionTraits::template argument<Indices>...);
128template<
typename Callable,
typename FunctionTraits = function_traits<std::remove_reference_t<Callable>>>
129using signature_t =
typename signature<FunctionTraits, std::make_index_sequence<FunctionTraits::argument_count>>::type;
131template <
typename Signature>
134template <
typename ResultType,
typename ...Arguments>
135class function_ptr<ResultType(Arguments...)>:
public object_ptr<ifunction<ResultType(Arguments...)>>
138 using base_type = object_ptr<ifunction<ResultType(Arguments...)>>;
140 using base_type::base_type;
142 ResultType operator()(Arguments... args)
const
144 return (*this->Get())(std::forward<Arguments>(args)...);
158template <
typename Callable,
typename Signature = detail::signature_t<Callable>>
170template <
typename Callable,
typename Signature = detail::signature_t<Callable>>
181template <
typename Signature>
184 return std::function<Signature>(std::ref(fnFunction));
192template <
typename Signature>
195 return std::function<Signature>(detail::function_ptr<Signature>(pFunction));
200using nitro::ifunction;
202using nitro::function_wrapper;
Copyright © Audi Electronics Venture GmbH.
Base class for every interface type within the uCOM.
Base object pointer to realize binary compatible reference counting in interface methods.
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
function_wrapper(std::function< ResultType(Arguments...)> fnFunction)
Constructor that initializes the object with the given function reference.
Implements iucom_function for the given signature.
virtual ResultType operator()(Arguments... args) const =0
The call operator which calls the referenced function.
Interface for functions that can be passed via IObject interfaces.
object_ptr< Implementation > make_object_ptr(Args &&... args)
Create an instance of type object_ptr with Implementation as the shared resource.
Namespace for all functionality provided since v3.13.
ant::object_ptr< ifunction< Signature > > make_function_ptr(Callable &&fnCallback)
creates an object_ptr shared pointer to an ucom_function pointing to the given callable.
ant::iobject_ptr< ifunction< Signature > > ifunction_ptr
Interface for shared pointers to iucom_function.
function_wrapper< Signature > make_function(Callable &&fnCallback)
creates a ucom_function object for the given callable.
std::function< Signature > to_std_function(const ifunction< Signature > &fnFunction)
Helper conversion to a std::function object.
Namespace for the ADTF uCOM3 SDK.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.