Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / fluid / modules / gapi / include / opencv2 / gapi / own / assert.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_OWN_ASSERT_HPP
9 #define OPENCV_GAPI_OWN_ASSERT_HPP
10
11 #if !defined(GAPI_STANDALONE)
12 #include <opencv2/core/base.hpp>
13 #define GAPI_Assert CV_Assert
14 #define GAPI_DbgAssert CV_DbgAssert
15
16 #else
17 #include <stdexcept>
18 #include <sstream>
19 #include "opencv2/gapi/util/throw.hpp"
20
21 namespace detail
22 {
23     inline void assert_abort(const char* str, int line, const char* file, const char* func)
24     {
25         std::stringstream ss;
26         ss << file << ":" << line << ": Assertion " << str << " in function " << func << " failed\n";
27         cv::util::throw_error(std::logic_error(ss.str()));
28     }
29 }
30
31 #define GAPI_Assert(expr) \
32 { if (!(expr)) ::detail::assert_abort(#expr, __LINE__, __FILE__, __func__); }
33
34
35 #ifdef NDEBUG
36 #  define GAPI_DbgAssert(expr)
37 #else
38 #  define GAPI_DbgAssert(expr) GAPI_Assert(expr)
39 #endif
40
41 #endif // GAPI_STANDALONE
42
43 #endif // OPENCV_GAPI_OWN_ASSERT_HPP