Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / fluid / modules / gapi / src / api / gapi_priv.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_PRIV_HPP
9 #define OPENCV_GAPI_PRIV_HPP
10
11 #include <set>   // set
12 #include <map>   // map
13 #include <limits>
14
15 #include "opencv2/gapi/util/variant.hpp"   // variant
16 #include "opencv2/gapi/garray.hpp"         // ConstructVec
17 #include "opencv2/gapi/gscalar.hpp"
18 #include "opencv2/gapi/gcommon.hpp"
19
20 #include "opencv2/gapi/opencv_includes.hpp"
21
22 #include "api/gnode.hpp"
23
24 namespace cv
25 {
26
27 namespace gimpl
28 {
29     // Union type for various user-defined type constructors (GArray<T>, etc)
30     // FIXME: Replace construct-only API with a more generic one
31     //    (probably with bits of introspection)
32     // Not required for non-user-defined types (GMat, GScalar, etc)
33     using HostCtor = util::variant
34         < util::monostate
35         , detail::ConstructVec
36         >;
37
38     using ConstVal = util::variant
39         < util::monostate
40         , cv::gapi::own::Scalar
41         >;
42 }
43
44 // TODO namespace gimpl?
45
46 struct GOrigin
47 {
48     static constexpr const std::size_t INVALID_PORT = std::numeric_limits<std::size_t>::max();
49
50     GOrigin(GShape s,
51             const GNode& n,
52             std::size_t p = INVALID_PORT,
53             const gimpl::HostCtor h = {});
54     GOrigin(GShape s, gimpl::ConstVal value);
55
56     const GShape          shape;           // Shape of a produced object
57     const GNode           node;            // a GNode which produces an object
58     const gimpl::ConstVal value;           // Node can have initial constant value, now only scalar is supported
59     const std::size_t     port;            // GNode's output number; FIXME: "= max_size" in C++14
60     gimpl::HostCtor       ctor;            // FIXME: replace with an interface?
61 };
62
63 namespace detail
64 {
65     struct GOriginCmp
66     {
67         bool operator() (const GOrigin &lhs, const GOrigin &rhs) const;
68     };
69 } // namespace cv::details
70
71 // TODO introduce a hash on GOrigin and define this via unordered_ ?
72 using GOriginSet = std::set<GOrigin, detail::GOriginCmp>;
73 template<typename T> using GOriginMap = std::map<GOrigin, T, detail::GOriginCmp>;
74
75 } // namespace cv
76
77 #endif // OPENCV_GAPI_PRIV_HPP