1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #20836 from alexgiving:atrutnev/rename_Adapter_to_IAdapter

* Rename RMat::Adapter to RMat::IAdapter

* Add comments
This commit is contained in:
Trutnev Aleksei
2021-11-01 15:43:27 +03:00
committed by GitHub
parent 7b57df02a7
commit 17234f82d0
6 changed files with 18 additions and 16 deletions
+10 -8
View File
@@ -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());
}
+1 -1
View File
@@ -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)