core(parallel): plugins support

This commit is contained in:
Alexander Alekhin
2021-02-03 22:04:35 +00:00
parent e5d78960c6
commit cc73c36e32
35 changed files with 1509 additions and 354 deletions
+5
View File
@@ -587,3 +587,8 @@ cv::String getCacheDirectory(const char* /*sub_directory_name*/, const char* /*c
#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
}}} // namespace
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
#include "plugin_loader.impl.hpp"
#endif
@@ -0,0 +1,80 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Not a standalone header, part of filesystem.cpp
//
#include "opencv2/core/utils/plugin_loader.private.hpp"
#if !OPENCV_HAVE_FILESYSTEM_SUPPORT
#error "Invalid build configuration"
#endif
#if 0 // TODO
#ifdef NDEBUG
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG + 1
#else
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1
#endif
#include <opencv2/core/utils/logger.hpp>
#endif
namespace cv { namespace plugin { namespace impl {
DynamicLib::DynamicLib(const FileSystemPath_t& filename)
: handle(0), fname(filename), disableAutoUnloading_(false)
{
libraryLoad(filename);
}
DynamicLib::~DynamicLib()
{
if (!disableAutoUnloading_)
{
libraryRelease();
}
else if (handle)
{
CV_LOG_INFO(NULL, "skip auto unloading (disabled): " << toPrintablePath(fname));
handle = 0;
}
}
void* DynamicLib::getSymbol(const char* symbolName) const
{
if (!handle)
{
return 0;
}
void* res = getSymbol_(handle, symbolName);
if (!res)
{
CV_LOG_DEBUG(NULL, "No symbol '" << symbolName << "' in " << toPrintablePath(fname));
}
return res;
}
const std::string DynamicLib::getName() const
{
return toPrintablePath(fname);
}
void DynamicLib::libraryLoad(const FileSystemPath_t& filename)
{
handle = libraryLoad_(filename);
CV_LOG_INFO(NULL, "load " << toPrintablePath(filename) << " => " << (handle ? "OK" : "FAILED"));
}
void DynamicLib::libraryRelease()
{
if (handle)
{
CV_LOG_INFO(NULL, "unload "<< toPrintablePath(fname));
libraryRelease_(handle);
handle = 0;
}
}
}}} // namespace