gapi_tests_helpers.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. //
  5. // Copyright (C) 2019 Intel Corporation
  6. #ifndef OPENCV_GAPI_TESTS_HELPERS_HPP
  7. #define OPENCV_GAPI_TESTS_HELPERS_HPP
  8. #include <tuple>
  9. #include <limits>
  10. namespace opencv_test
  11. {
  12. // Ensure correct __VA_ARGS__ expansion on Windows
  13. #define __WRAP_VAARGS(x) x
  14. #define __TUPLE_PARAM_TYPE(i) std::tuple_element<i, AllParams::specific_params_t>::type
  15. // implementation of recursive in-class declaration and initialization of member variables
  16. #define __DEFINE_PARAMS_IMPL1(index, param_name) \
  17. __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam<index>();
  18. #define __DEFINE_PARAMS_IMPL2(index, param_name, ...) \
  19. __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam<index>(); \
  20. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL1(index+1, __VA_ARGS__))
  21. #define __DEFINE_PARAMS_IMPL3(index, param_name, ...) \
  22. __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam<index>(); \
  23. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL2(index+1, __VA_ARGS__))
  24. #define __DEFINE_PARAMS_IMPL4(index, param_name, ...) \
  25. __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam<index>(); \
  26. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL3(index+1, __VA_ARGS__))
  27. #define __DEFINE_PARAMS_IMPL5(index, param_name, ...) \
  28. __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam<index>(); \
  29. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL4(index+1, __VA_ARGS__))
  30. #define __DEFINE_PARAMS_IMPL6(index, param_name, ...) \
  31. __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam<index>(); \
  32. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL5(index+1, __VA_ARGS__))
  33. #define __DEFINE_PARAMS_IMPL7(index, param_name, ...) \
  34. __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam<index>(); \
  35. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL6(index+1, __VA_ARGS__))
  36. #define __DEFINE_PARAMS_IMPL8(index, param_name, ...) \
  37. __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam<index>(); \
  38. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL7(index+1, __VA_ARGS__))
  39. #define __DEFINE_PARAMS_IMPL9(index, param_name, ...) \
  40. __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam<index>(); \
  41. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL8(index+1, __VA_ARGS__))
  42. #define __DEFINE_PARAMS_IMPL10(index, param_name, ...) \
  43. __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam<index>(); \
  44. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL9(index+1, __VA_ARGS__))
  45. #define __DEFINE_PARAMS_IMPL11(index, param_name, ...) \
  46. __TUPLE_PARAM_TYPE(index) param_name = getSpecificParam<index>(); \
  47. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL10(index+1, __VA_ARGS__))
  48. // user interface to define member variables of specified names
  49. #define DEFINE_SPECIFIC_PARAMS_0()
  50. #define DEFINE_SPECIFIC_PARAMS_1(...) \
  51. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL1(0, __VA_ARGS__))
  52. #define DEFINE_SPECIFIC_PARAMS_2(...) \
  53. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL2(0, __VA_ARGS__))
  54. #define DEFINE_SPECIFIC_PARAMS_3(...) \
  55. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL3(0, __VA_ARGS__))
  56. #define DEFINE_SPECIFIC_PARAMS_4(...) \
  57. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL4(0, __VA_ARGS__))
  58. #define DEFINE_SPECIFIC_PARAMS_5(...) \
  59. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL5(0, __VA_ARGS__))
  60. #define DEFINE_SPECIFIC_PARAMS_6(...) \
  61. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL6(0, __VA_ARGS__))
  62. #define DEFINE_SPECIFIC_PARAMS_7(...) \
  63. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL7(0, __VA_ARGS__))
  64. #define DEFINE_SPECIFIC_PARAMS_8(...) \
  65. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL8(0, __VA_ARGS__))
  66. #define DEFINE_SPECIFIC_PARAMS_9(...) \
  67. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL9(0, __VA_ARGS__))
  68. #define DEFINE_SPECIFIC_PARAMS_10(...) \
  69. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL10(0, __VA_ARGS__))
  70. #define DEFINE_SPECIFIC_PARAMS_11(...) \
  71. __WRAP_VAARGS(__DEFINE_PARAMS_IMPL11(0, __VA_ARGS__))
  72. } // namespace opencv_test
  73. #endif //OPENCV_GAPI_TESTS_HELPERS_HPP