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_GCALL_PRIV_HPP
9#define OPENCV_GCALL_PRIV_HPP
10
11#include <vector>
12#include <unordered_map>
13
14#include "opencv2/gapi/garg.hpp"
15#include "opencv2/gapi/gcall.hpp"
16#include "opencv2/gapi/gkernel.hpp"
17
18#include "api/gnode.hpp"
19
20namespace cv {
21
22// GCall is used to capture details (arguments) passed to operation when the graph is
23// constructed. It is, in fact, just a "serialization" of a function call (to some extent). The
24// only place where new GCall objects are constructed is KernelName::on(). Note that GCall not
25// only stores its input arguments, but also yields operation's pseudo-results to return
26// "results".
27// GCall arguments are GArgs which can wrap either our special types (like GMat) or other
28// stuff user may pass according to operation's signature (opaque to us).
29// If a dynamic g-object is wrapped in GArg, it has origin - something where that object comes
30// from. It is either another function call (again, a GCall) or nothing (for graph's starting
31// points, for example). By using these links, we understand what the flow is and construct the
32// real graph. Origin is a node in a graph, represented by GNode.
33// When a GCall is created, it instantiates it's appropriate GNode since we need an origin for
34// objects we produce with this call. This is what is stored in m_node and then is used in every
35// yield() call (the framework calls yield() according to template signature which we strip then
36// - aka type erasure).
37// Here comes the recursion - GNode knows it is created for GCall, and GCall stores that node
38// object as origin for yield(). In order to break it, in GNode's object destructor this m_node
39// pointer is reset (note - GCall::Priv remains alive). Now GCall's ownership "moves" to GNode
40// and remains there until the API part is destroyed.
41class GCall::Priv
42{
43public:
44 std::vector<GArg> m_args;
45 GKernel m_k;
46
47 // TODO: Rename to "constructionNode" or smt to reflect its lifetime
48 GNode m_node;
49 cv::util::any m_params;
50
51 explicit Priv(const GKernel &k);
52};
53
54}
55
56#endif // OPENCV_GCALL_PRIV_HPP
57

source code of opencv/modules/gapi/src/api/gcall_priv.hpp