Merge pull request #20836 from alexgiving:atrutnev/rename_Adapter_to_IAdapter
* Rename RMat::Adapter to RMat::IAdapter * Add comments
This commit is contained in:
parent
7b57df02a7
commit
17234f82d0
@ -25,11 +25,11 @@ namespace cv {
|
||||
// "Remote Mat", a general class which provides an abstraction layer over the data
|
||||
// storage and placement (host, remote device etc) and allows to access this data.
|
||||
//
|
||||
// The device specific implementation is hidden in the RMat::Adapter class
|
||||
// The device specific implementation is hidden in the RMat::IAdapter class
|
||||
//
|
||||
// The basic flow is the following:
|
||||
// * Backend which is aware of the remote device:
|
||||
// - Implements own AdapterT class which is derived from RMat::Adapter
|
||||
// - Implements own AdapterT class which is derived from RMat::IAdapter
|
||||
// - Wraps device memory into RMat via make_rmat utility function:
|
||||
// cv::RMat rmat = cv::make_rmat<AdapterT>(args);
|
||||
//
|
||||
@ -101,25 +101,27 @@ public:
|
||||
};
|
||||
|
||||
enum class Access { R, W };
|
||||
class Adapter
|
||||
class IAdapter
|
||||
// Adapter class is going to be deleted and renamed as IAdapter
|
||||
{
|
||||
public:
|
||||
virtual ~Adapter() = default;
|
||||
virtual ~IAdapter() = default;
|
||||
virtual GMatDesc desc() const = 0;
|
||||
// Implementation is responsible for setting the appropriate callback to
|
||||
// the view when accessed for writing, to ensure that the data from the view
|
||||
// is transferred to the device when the view is destroyed
|
||||
virtual View access(Access) = 0;
|
||||
virtual void serialize(cv::gapi::s11n::IOStream&) {
|
||||
GAPI_Assert(false && "Generic serialize method of RMat::Adapter does nothing by default. "
|
||||
GAPI_Assert(false && "Generic serialize method of RMat::IAdapter does nothing by default. "
|
||||
"Please, implement it in derived class to properly serialize the object.");
|
||||
}
|
||||
virtual void deserialize(cv::gapi::s11n::IIStream&) {
|
||||
GAPI_Assert(false && "Generic deserialize method of RMat::Adapter does nothing by default. "
|
||||
GAPI_Assert(false && "Generic deserialize method of RMat::IAdapter does nothing by default. "
|
||||
"Please, implement it in derived class to properly deserialize the object.");
|
||||
}
|
||||
};
|
||||
using AdapterP = std::shared_ptr<Adapter>;
|
||||
using Adapter = IAdapter; // Keep backward compatibility
|
||||
using AdapterP = std::shared_ptr<IAdapter>;
|
||||
|
||||
RMat() = default;
|
||||
RMat(AdapterP&& a) : m_adapter(std::move(a)) {}
|
||||
@ -136,7 +138,7 @@ public:
|
||||
// return nullptr if underlying type is different
|
||||
template<typename T> T* get() const
|
||||
{
|
||||
static_assert(std::is_base_of<Adapter, T>::value, "T is not derived from Adapter!");
|
||||
static_assert(std::is_base_of<IAdapter, T>::value, "T is not derived from IAdapter!");
|
||||
GAPI_Assert(m_adapter != nullptr);
|
||||
return dynamic_cast<T*>(m_adapter.get());
|
||||
}
|
||||
|
||||
@ -431,7 +431,7 @@ struct deserialize_runarg {
|
||||
static GRunArg exec(cv::gapi::s11n::IIStream& is, uint32_t idx) {
|
||||
if (idx == GRunArg::index_of<RMat>()) {
|
||||
// Type or void (if not found)
|
||||
using TA = typename cv::util::find_adapter_impl<RMat::Adapter, Types...>::type;
|
||||
using TA = typename cv::util::find_adapter_impl<RMat::IAdapter, Types...>::type;
|
||||
return deserialize_arg_with_adapter<RMat, TA>::exec(is);
|
||||
} else if (idx == GRunArg::index_of<MediaFrame>()) {
|
||||
// Type or void (if not found)
|
||||
|
||||
@ -45,7 +45,7 @@ namespace gimpl {
|
||||
#endif
|
||||
}
|
||||
|
||||
class RMatAdapter : public RMat::Adapter {
|
||||
class RMatAdapter : public RMat::IAdapter {
|
||||
cv::Mat m_mat;
|
||||
public:
|
||||
const void* data() const { return m_mat.data; }
|
||||
@ -58,7 +58,7 @@ namespace gimpl {
|
||||
struct Data;
|
||||
struct RcDesc;
|
||||
|
||||
struct GAPI_EXPORTS RMatMediaFrameAdapter final: public cv::RMat::Adapter
|
||||
struct GAPI_EXPORTS RMatMediaFrameAdapter final: public cv::RMat::IAdapter
|
||||
{
|
||||
using MapDescF = std::function<cv::GMatDesc(const GFrameDesc&)>;
|
||||
using MapDataF = std::function<cv::Mat(const GFrameDesc&, const cv::MediaFrame::View&)>;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#include <opencv2/gapi/rmat.hpp>
|
||||
|
||||
namespace opencv_test {
|
||||
class RMatAdapterRef : public RMat::Adapter {
|
||||
class RMatAdapterRef : public RMat::IAdapter {
|
||||
cv::Mat& m_mat;
|
||||
bool& m_callbackCalled;
|
||||
public:
|
||||
@ -36,7 +36,7 @@ public:
|
||||
virtual cv::GMatDesc desc() const override { return cv::descr_of(m_mat); }
|
||||
};
|
||||
|
||||
class RMatAdapterCopy : public RMat::Adapter {
|
||||
class RMatAdapterCopy : public RMat::IAdapter {
|
||||
cv::Mat& m_deviceMat;
|
||||
cv::Mat m_hostMat;
|
||||
bool& m_callbackCalled;
|
||||
|
||||
@ -94,7 +94,7 @@ TYPED_TEST(RMatTypedTest, CorrectAdapterCast) {
|
||||
EXPECT_NE(nullptr, this->rmat().template get<T>());
|
||||
}
|
||||
|
||||
class DummyAdapter : public RMat::Adapter {
|
||||
class DummyAdapter : public RMat::IAdapter {
|
||||
virtual RMat::View access(RMat::Access) override { return {}; }
|
||||
virtual cv::GMatDesc desc() const override { return {}; }
|
||||
};
|
||||
@ -103,7 +103,7 @@ TYPED_TEST(RMatTypedTest, IncorrectAdapterCast) {
|
||||
EXPECT_EQ(nullptr, this->rmat().template get<DummyAdapter>());
|
||||
}
|
||||
|
||||
class RMatAdapterForBackend : public RMat::Adapter {
|
||||
class RMatAdapterForBackend : public RMat::IAdapter {
|
||||
int m_i;
|
||||
public:
|
||||
RMatAdapterForBackend(int i) : m_i(i) {}
|
||||
|
||||
@ -127,7 +127,7 @@ template<> struct CompileArgTag<MyCustomTypeNoS11N> {
|
||||
} // namespace cv
|
||||
|
||||
namespace {
|
||||
class MyRMatAdapter : public cv::RMat::Adapter {
|
||||
class MyRMatAdapter : public cv::RMat::IAdapter {
|
||||
cv::Mat m_mat;
|
||||
int m_value;
|
||||
std::string m_str;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user