ed5ba5fde84fd1372cdf4c14a96318ea6f3d9532
[platform/upstream/opencv.git] / modules / gapi / include / opencv2 / gapi / gcall.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 Intel Corporation
6
7
8 #ifndef OPENCV_GAPI_GCALL_HPP
9 #define OPENCV_GAPI_GCALL_HPP
10
11 #include <opencv2/gapi/garg.hpp>      // GArg
12 #include <opencv2/gapi/gmat.hpp>      // GMat
13 #include <opencv2/gapi/gscalar.hpp>   // GScalar
14 #include <opencv2/gapi/garray.hpp>    // GArray<T>
15 #include <opencv2/gapi/gopaque.hpp>   // GOpaque<T>
16
17 namespace cv {
18
19 struct GKernel;
20
21 // The whole idea of this class is to represent an operation
22 // which is applied to arguments. This is part of public API,
23 // since it is what users should use to define kernel interfaces.
24
25 class GAPI_EXPORTS GCall final
26 {
27 public:
28     class Priv;
29
30     explicit GCall(const GKernel &k);
31     ~GCall();
32
33     template<typename... Ts>
34     GCall& pass(Ts&&... args)
35     {
36         setArgs({cv::GArg(std::move(args))...});
37         return *this;
38     }
39
40     // A generic yield method - obtain a link to operator's particular GMat output
41     GMat    yield      (int output = 0);
42     GMatP   yieldP     (int output = 0);
43     GScalar yieldScalar(int output = 0);
44
45     template<class T> GArray<T> yieldArray(int output = 0)
46     {
47         return GArray<T>(yieldArray(output));
48     }
49
50     template<class T> GOpaque<T> yieldOpaque(int output = 0)
51     {
52         return GOpaque<T>(yieldOpaque(output));
53     }
54
55     // Internal use only
56     Priv& priv();
57     const Priv& priv() const;
58
59 protected:
60     std::shared_ptr<Priv> m_priv;
61
62     void setArgs(std::vector<GArg> &&args);
63
64     // Public versions return a typed array or opaque, those are implementation details
65     detail::GArrayU yieldArray(int output = 0);
66     detail::GOpaqueU yieldOpaque(int output = 0);
67 };
68
69 } // namespace cv
70
71 #endif // OPENCV_GAPI_GCALL_HPP