Commit e569e9dc authored by Andrey Golubev's avatar Andrey Golubev

Unify G_TYPED_KERNEL and G_TYPED_KERNEL_M

parent 57c99914
...@@ -228,6 +228,20 @@ public: ...@@ -228,6 +228,20 @@ public:
} }
}; };
namespace detail {
// This tiny class eliminates the semantic difference between
// GKernelType and GKernelTypeM.
template<typename, typename> class KernelTypeMedium;
template<typename K, typename... R, typename... Args>
class KernelTypeMedium<K, std::function<std::tuple<R...>(Args...)>> :
public cv::GKernelTypeM<K, std::function<std::tuple<R...>(Args...)>> {};
template<typename K, typename R, typename... Args>
class KernelTypeMedium<K, std::function<R(Args...)>> :
public cv::GKernelType<K, std::function<R(Args...)>> {};
} // namespace detail
} // namespace cv } // namespace cv
...@@ -256,12 +270,12 @@ public: ...@@ -256,12 +270,12 @@ public:
* *
* @param Class type name for this operation. * @param Class type name for this operation.
* @param API an `std::function<>`-like signature for the operation; * @param API an `std::function<>`-like signature for the operation;
* return type is a single value. * return type is a single value or a tuple of multiple values.
* @param Id string identifier for the operation. Must be unique. * @param Id string identifier for the operation. Must be unique.
*/ */
#define G_TYPED_KERNEL_HELPER(Class, API, Id) \ #define G_TYPED_KERNEL_HELPER(Class, API, Id) \
G_ID_HELPER_BODY(Class, Id) \ G_ID_HELPER_BODY(Class, Id) \
struct Class final: public cv::GKernelType<Class, std::function API >, \ struct Class final: public cv::detail::KernelTypeMedium<Class, std::function API >, \
public G_ID_HELPER_CLASS(Class) public G_ID_HELPER_CLASS(Class)
// {body} is to be defined by user // {body} is to be defined by user
...@@ -319,10 +333,7 @@ G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _ ...@@ -319,10 +333,7 @@ G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _
* return type is a tuple of multiple values. * return type is a tuple of multiple values.
* @param Id string identifier for the operation. Must be unique. * @param Id string identifier for the operation. Must be unique.
*/ */
#define G_TYPED_KERNEL_M_HELPER(Class, API, Id) \ #define G_TYPED_KERNEL_M_HELPER G_TYPED_KERNEL_HELPER
G_ID_HELPER_BODY(Class, Id) \
struct Class final: public cv::GKernelTypeM<Class, std::function API >, \
public G_ID_HELPER_CLASS(Class)
// {body} is to be defined by user // {body} is to be defined by user
#define G_TYPED_KERNEL_M_HELPER_2(Class, _1, _2, Id) \ #define G_TYPED_KERNEL_M_HELPER_2(Class, _1, _2, Id) \
...@@ -358,21 +369,10 @@ G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _ ...@@ -358,21 +369,10 @@ G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _
* *
* @param Class type name for this operation. * @param Class type name for this operation.
*/ */
#define G_TYPED_KERNEL_M(Class, ...) __WRAP_VAARGS(GET_G_TYPED_KERNEL(__VA_ARGS__, \ #define G_TYPED_KERNEL_M G_TYPED_KERNEL
G_TYPED_KERNEL_M_HELPER_10, \
G_TYPED_KERNEL_M_HELPER_9, \
G_TYPED_KERNEL_M_HELPER_8, \
G_TYPED_KERNEL_M_HELPER_7, \
G_TYPED_KERNEL_M_HELPER_6, \
G_TYPED_KERNEL_M_HELPER_5, \
G_TYPED_KERNEL_M_HELPER_4, \
G_TYPED_KERNEL_M_HELPER_3, \
G_TYPED_KERNEL_M_HELPER_2, \
G_TYPED_KERNEL_M_HELPER)(Class, __VA_ARGS__)) \
// {body} is to be defined by user
#define G_API_OP G_TYPED_KERNEL #define G_API_OP G_TYPED_KERNEL
#define G_API_OP_M G_TYPED_KERNEL_M #define G_API_OP_M G_API_OP
namespace cv namespace cv
{ {
......
...@@ -23,23 +23,6 @@ ...@@ -23,23 +23,6 @@
namespace cv { namespace cv {
namespace detail {
// This tiny class eliminates the semantic difference between
// GKernelType and GKernelTypeM.
// FIXME: Something similar can be reused for regular kernels
template<typename, typename>
struct KernelTypeMedium;
template<class K, typename... R, typename... Args>
struct KernelTypeMedium<K, std::function<std::tuple<R...>(Args...)> >:
public GKernelTypeM<K, std::function<std::tuple<R...>(Args...)> > {};
template<class K, typename R, typename... Args>
struct KernelTypeMedium<K, std::function<R(Args...)> >:
public GKernelType<K, std::function<R(Args...)> > {};
} // namespace detail
template<typename, typename> class GNetworkType; template<typename, typename> class GNetworkType;
// TODO: maybe tuple_wrap_helper from util.hpp may help with this. // TODO: maybe tuple_wrap_helper from util.hpp may help with this.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment