Commit e5d1790b authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #10018 from alalek:ocl_binary_cache

parents fed2a277 8e6280fc
......@@ -261,6 +261,8 @@ public:
void setUseSVM(bool enabled);
struct Impl;
inline Impl* getImpl() const { return (Impl*)p; }
//protected:
Impl* p;
};
......
// 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.
#ifndef OPENCV_UTILS_FILESYSTEM_HPP
#define OPENCV_UTILS_FILESYSTEM_HPP
namespace cv { namespace utils { namespace fs {
CV_EXPORTS bool exists(const cv::String& path);
CV_EXPORTS bool isDirectory(const cv::String& path);
CV_EXPORTS cv::String getcwd();
CV_EXPORTS bool createDirectory(const cv::String& path);
CV_EXPORTS bool createDirectories(const cv::String& path);
#ifdef __OPENCV_BUILD
// TODO
//CV_EXPORTS cv::String getTempDirectory();
/**
* @brief Returns directory to store OpenCV cache files
* Create sub-directory in common OpenCV cache directory if it doesn't exist.
* @param sub_directory_name name of sub-directory. NULL or "" value asks to return root cache directory.
* @param configuration_name optional name of configuration parameter name which overrides default behavior.
* @return Path to cache directory. Returns empty string if cache directories support is not available. Returns "disabled" if cache disabled by user.
*/
CV_EXPORTS cv::String getCacheDirectory(const char* sub_directory_name, const char* configuration_name = NULL);
#endif
}}} // namespace
#endif // OPENCV_UTILS_FILESYSTEM_HPP
// 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.
#ifndef OPENCV_UTILS_FILESYSTEM_PRIVATE_HPP
#define OPENCV_UTILS_FILESYSTEM_PRIVATE_HPP
// TODO Move to CMake?
#ifndef OPENCV_HAVE_FILESYSTEM_SUPPORT
# if defined(__EMSCRIPTEN__) || defined(__native_client__)
/* no support */
# elif defined __ANDROID__ || defined __linux__ || defined _WIN32 || \
defined __FreeBSD__ || defined __bsdi__
# define OPENCV_HAVE_FILESYSTEM_SUPPORT 1
# elif defined(__APPLE__)
# include <TargetConditionals.h>
# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX) || (!defined(TARGET_OS_OSX) && !TARGET_OS_IPHONE)
# define OPENCV_HAVE_FILESYSTEM_SUPPORT 1 // OSX only
# endif
# else
/* unknown */
# endif
# ifndef OPENCV_HAVE_FILESYSTEM_SUPPORT
# define OPENCV_HAVE_FILESYSTEM_SUPPORT 0
# endif
#endif
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
namespace cv { namespace utils { namespace fs {
/**
* File-based lock object.
*
* Provides interprocess synchronization mechanism.
* Platform dependent.
*
* Supports multiple readers / single writer access pattern (RW / readers–writer / shared-exclusive lock).
*
* File must exist.
* File can't be re-used (for example, I/O operations via std::fstream is not safe)
*/
class CV_EXPORTS FileLock {
public:
explicit FileLock(const char* fname);
~FileLock();
void lock(); //< acquire exclusive (writer) lock
void unlock(); //< release exclusive (writer) lock
void lock_shared(); //< acquire sharable (reader) lock
void unlock_shared(); //< release sharable (reader) lock
struct Impl;
protected:
Impl* pImpl;
private:
FileLock(const FileLock&); // disabled
FileLock& operator=(const FileLock&); // disabled
};
}}} // namespace
#endif
#endif // OPENCV_UTILS_FILESYSTEM_PRIVATE_HPP
// 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.
#ifndef OPENCV_UTILS_LOCK_HPP
#define OPENCV_UTILS_LOCK_HPP
namespace cv { namespace utils {
/** @brief A simple scoped lock (RAII-style locking for exclusive/write access).
*
* Emulate std::lock_guard (C++11), partially std::unique_lock (C++11),
*/
template <class _Mutex>
class lock_guard {
public:
typedef _Mutex Mutex;
explicit inline lock_guard(Mutex &m) : mutex_(&m) { mutex_->lock(); }
inline ~lock_guard() { if (mutex_) mutex_->unlock(); }
inline void release()
{
CV_DbgAssert(mutex_);
mutex_->unlock();
mutex_ = NULL;
}
private:
Mutex* mutex_;
private:
lock_guard(const lock_guard&); // disabled
lock_guard& operator=(const lock_guard&); // disabled
};
/** @brief A shared scoped lock (RAII-style locking for shared/reader access).
*
* Emulate boost::shared_lock_guard, subset of std::shared_lock (C++14),
*/
template <class _Mutex>
class shared_lock_guard {
public:
typedef _Mutex Mutex;
explicit inline shared_lock_guard(Mutex &m) : mutex_(&m) { mutex_->lock_shared(); }
inline ~shared_lock_guard() { if (mutex_) mutex_->unlock_shared(); }
inline void release()
{
CV_DbgAssert(mutex_);
mutex_->unlock_shared();
mutex_ = NULL;
}
protected:
Mutex* mutex_;
private:
shared_lock_guard(const shared_lock_guard&); // disabled
shared_lock_guard& operator=(const shared_lock_guard&); // disabled
};
/** @brief An optional simple scoped lock (RAII-style locking for exclusive/write access).
*
* Doesn't lock if mutex pointer is NULL.
*
* @sa lock_guard
*/
template <class _Mutex>
class optional_lock_guard {
public:
typedef _Mutex Mutex;
explicit inline optional_lock_guard(Mutex* m) : mutex_(m) { if (mutex_) mutex_->lock(); }
inline ~optional_lock_guard() { if (mutex_) mutex_->unlock(); }
private:
Mutex* mutex_;
private:
optional_lock_guard(const optional_lock_guard&); // disabled
optional_lock_guard& operator=(const optional_lock_guard&); // disabled
};
/** @brief An optional shared scoped lock (RAII-style locking for shared/reader access).
*
* Doesn't lock if mutex pointer is NULL.
*
* @sa shared_lock_guard
*/
template <class _Mutex>
class optional_shared_lock_guard {
public:
typedef _Mutex Mutex;
explicit inline optional_shared_lock_guard(Mutex* m) : mutex_(m) { if (mutex_) mutex_->lock_shared(); }
inline ~optional_shared_lock_guard() { if (mutex_) mutex_->unlock_shared(); }
protected:
Mutex* mutex_;
private:
optional_shared_lock_guard(const optional_shared_lock_guard&); // disabled
optional_shared_lock_guard& operator=(const optional_shared_lock_guard&); // disabled
};
}} // namespace
#endif // OPENCV_UTILS_LOCK_HPP
......@@ -42,6 +42,8 @@
#include "precomp.hpp"
#include "opencv2/core/utils/filesystem.hpp"
#if defined _WIN32 || defined WINCE
# include <windows.h>
const char dir_separators[] = "/\\";
......@@ -169,6 +171,12 @@ static bool isDir(const cv::String& path, DIR* dir)
#endif
}
bool cv::utils::fs::isDirectory(const cv::String& path)
{
CV_INSTRUMENT_REGION()
return isDir(path, NULL);
}
static bool wildcmp(const char *string, const char *wild)
{
// Based on wildcmp written by Jack Handy - <A href="mailto:jakkhandy@hotmail.com">jakkhandy@hotmail.com</A>
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment