Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / fluid / modules / gapi / include / opencv2 / gapi / gmetaarg.hpp
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) 2018-2019 Intel Corporation
6
7
8 #ifndef OPENCV_GAPI_GMETAARG_HPP
9 #define OPENCV_GAPI_GMETAARG_HPP
10
11 #include <vector>
12 #include <type_traits>
13
14 #include "opencv2/gapi/util/util.hpp"
15 #include "opencv2/gapi/util/variant.hpp"
16
17 #include "opencv2/gapi/gmat.hpp"
18 #include "opencv2/gapi/gscalar.hpp"
19 #include "opencv2/gapi/garray.hpp"
20
21 namespace cv
22 {
23 // FIXME: Rename to GMeta?
24 // FIXME: user shouldn't deal with it - put to detail?
25 // GMetaArg is an union type over descriptions of G-types which can serve as
26 // GComputation's in/output slots.
27 //
28 // GMetaArg objects are passed as arguments to GComputation::compile()
29 // to specify which data a compiled computation should be specialized on.
30 // For manual compile(), user must supply this metadata, in case of apply()
31 // this metadata is taken from arguments computation should operate on.
32 //
33 // The first type (monostate) is equal to "uninitialized"/"unresolved" meta.
34 using GMetaArg = util::variant
35     < util::monostate
36     , GMatDesc
37     , GScalarDesc
38     , GArrayDesc
39     >;
40 GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const GMetaArg &);
41
42 using GMetaArgs = std::vector<GMetaArg>;
43
44 namespace detail
45 {
46     // These traits are used by GComputation::compile()
47
48     // FIXME: is_constructible<T> doesn't work as variant doesn't do any SFINAE
49     // in its current template constructor
50
51     template<typename T> struct is_meta_descr    : std::false_type {};
52     template<> struct is_meta_descr<GMatDesc>    : std::true_type {};
53     template<> struct is_meta_descr<GScalarDesc> : std::true_type {};
54     template<> struct is_meta_descr<GArrayDesc>  : std::true_type {};
55
56     template<typename... Ts>
57     using are_meta_descrs = all_satisfy<is_meta_descr, Ts...>;
58
59     template<typename... Ts>
60     using are_meta_descrs_but_last = all_satisfy<is_meta_descr, typename all_but_last<Ts...>::type>;
61
62 } // namespace detail
63
64 class Mat;
65 class UMat;
66 GAPI_EXPORTS cv::GMetaArgs descr_of(const std::vector<cv::Mat> &vec);
67 GAPI_EXPORTS cv::GMetaArgs descr_of(const std::vector<cv::UMat> &vec);
68 namespace gapi { namespace own {
69     class Mat;
70     GAPI_EXPORTS cv::GMetaArgs descr_of(const std::vector<Mat> &vec);
71 }} // namespace gapi::own
72
73 } // namespace cv
74
75 #endif // OPENCV_GAPI_GMETAARG_HPP