mirror of
https://github.com/opencv/opencv.git
synced 2025-06-10 19:24:07 +08:00
Unify G_TYPED_KERNEL and G_TYPED_KERNEL_M
This commit is contained in:
parent
57c9991413
commit
e569e9dcbd
@ -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
|
||||
|
||||
|
||||
@ -256,12 +270,12 @@ public:
|
||||
*
|
||||
* @param Class type name for this 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.
|
||||
*/
|
||||
#define G_TYPED_KERNEL_HELPER(Class, API, Id) \
|
||||
G_ID_HELPER_BODY(Class, Id) \
|
||||
struct Class final: public cv::GKernelType<Class, std::function API >, \
|
||||
#define G_TYPED_KERNEL_HELPER(Class, API, Id) \
|
||||
G_ID_HELPER_BODY(Class, Id) \
|
||||
struct Class final: public cv::detail::KernelTypeMedium<Class, std::function API >, \
|
||||
public G_ID_HELPER_CLASS(Class)
|
||||
// {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, _
|
||||
* return type is a tuple of multiple values.
|
||||
* @param Id string identifier for the operation. Must be unique.
|
||||
*/
|
||||
#define G_TYPED_KERNEL_M_HELPER(Class, API, Id) \
|
||||
G_ID_HELPER_BODY(Class, Id) \
|
||||
struct Class final: public cv::GKernelTypeM<Class, std::function API >, \
|
||||
public G_ID_HELPER_CLASS(Class)
|
||||
#define G_TYPED_KERNEL_M_HELPER G_TYPED_KERNEL_HELPER
|
||||
// {body} is to be defined by user
|
||||
|
||||
#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, _
|
||||
*
|
||||
* @param Class type name for this operation.
|
||||
*/
|
||||
#define G_TYPED_KERNEL_M(Class, ...) __WRAP_VAARGS(GET_G_TYPED_KERNEL(__VA_ARGS__, \
|
||||
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_TYPED_KERNEL_M 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
|
||||
{
|
||||
|
@ -23,23 +23,6 @@
|
||||
|
||||
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;
|
||||
|
||||
// TODO: maybe tuple_wrap_helper from util.hpp may help with this.
|
||||
|
Loading…
Reference in New Issue
Block a user