NO_COPY_CLASS c++11
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
*/
|
||||
class PIP_EXPORT PIConditionLock {
|
||||
public:
|
||||
NO_COPY_CLASS(PIConditionLock)
|
||||
explicit PIConditionLock();
|
||||
~PIConditionLock();
|
||||
|
||||
@@ -43,7 +44,6 @@ public:
|
||||
void * handle();
|
||||
|
||||
private:
|
||||
NO_COPY_CLASS(PIConditionLock)
|
||||
PRIVATE_DECLARATION
|
||||
};
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
*/
|
||||
class PIP_EXPORT PIConditionVariable {
|
||||
public:
|
||||
NO_COPY_CLASS(PIConditionVariable)
|
||||
explicit PIConditionVariable();
|
||||
virtual ~PIConditionVariable();
|
||||
|
||||
@@ -111,7 +112,6 @@ public:
|
||||
virtual bool waitFor(PIConditionLock& lk, int timeoutMs, const std::function<bool()>& condition);
|
||||
|
||||
private:
|
||||
NO_COPY_CLASS(PIConditionVariable)
|
||||
PRIVATE_DECLARATION
|
||||
};
|
||||
|
||||
|
||||
@@ -96,9 +96,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PIP_CXX11_SUPPORT
|
||||
# include <functional>
|
||||
#endif
|
||||
#include <functional>
|
||||
|
||||
#include <cstddef>
|
||||
#ifdef WINDOWS
|
||||
@@ -220,8 +218,8 @@
|
||||
#define PRIVATEWB __privateinitializer__.p
|
||||
|
||||
#define NO_COPY_CLASS(name) \
|
||||
explicit name(const name & ); \
|
||||
void operator =(const name & );
|
||||
name(const name&) = delete; \
|
||||
name& operator=(const name&) = delete;
|
||||
|
||||
#ifdef FREERTOS
|
||||
# define PIP_MIN_MSLEEP 10.
|
||||
@@ -255,15 +253,9 @@ typedef unsigned long long ullong;
|
||||
typedef long long llong;
|
||||
typedef long double ldouble;
|
||||
|
||||
#ifdef PIP_CXX11_SUPPORT
|
||||
#define piMove(v) std::move(v)
|
||||
#else
|
||||
#define piMove(v) v
|
||||
#endif
|
||||
|
||||
/*! \brief Templated function for swap two values
|
||||
* \details Example:\n \snippet piincludes.cpp swap */
|
||||
template<typename T> inline void piSwap(T & f, T & s) {T t(piMove(f)); f = piMove(s); s = piMove(t);}
|
||||
template<typename T> inline void piSwap(T & f, T & s) {T t(std::move(f)); f = std::move(s); s = std::move(t);}
|
||||
|
||||
/*! \brief Templated function for swap two values without "="
|
||||
* \details Example:\n \snippet piincludes.cpp swapBinary */
|
||||
|
||||
@@ -54,6 +54,7 @@ class PIP_EXPORT PIIODevice: public PIThread
|
||||
PIOBJECT_SUBCLASS(PIIODevice, PIThread)
|
||||
friend void __DevicePool_threadReadDP(void * ddp);
|
||||
public:
|
||||
NO_COPY_CLASS(PIIODevice)
|
||||
|
||||
//! Constructs a empty PIIODevice
|
||||
explicit PIIODevice();
|
||||
@@ -388,8 +389,6 @@ protected:
|
||||
void * ret_data_;
|
||||
|
||||
private:
|
||||
NO_COPY_CLASS(PIIODevice)
|
||||
|
||||
EVENT_HANDLER2(void, check_start, void * , data, int, delim);
|
||||
EVENT_HANDLER(void, write_func);
|
||||
|
||||
|
||||
@@ -32,12 +32,13 @@ class PIP_EXPORT PIDiagnostics: public PITimer
|
||||
PIOBJECT_SUBCLASS(PIDiagnostics, PITimer)
|
||||
friend class PIConnection;
|
||||
public:
|
||||
NO_COPY_CLASS(PIDiagnostics)
|
||||
|
||||
//! Constructs an empty diagnostics and if "start_" start it
|
||||
PIDiagnostics(bool start_ = true);
|
||||
|
||||
virtual ~PIDiagnostics();
|
||||
|
||||
|
||||
//! Connection quality
|
||||
enum Quality {
|
||||
Unknown /** Unknown, no one packet received yet */ = 1,
|
||||
@@ -122,8 +123,6 @@ public:
|
||||
//! \}
|
||||
|
||||
private:
|
||||
NO_COPY_CLASS(PIDiagnostics)
|
||||
|
||||
struct Entry {
|
||||
Entry() {bytes_ok = bytes_fail = 0; cnt_ok = cnt_fail = 0; empty = true;}
|
||||
ullong bytes_ok;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*! \file pimutex.h
|
||||
* \brief Mutex
|
||||
* \brief PIMutexLocker
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Mutex
|
||||
PIMutexLocker
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -25,15 +25,19 @@
|
||||
|
||||
#include "piinit.h"
|
||||
|
||||
|
||||
//! \brief PIMutexLocker
|
||||
//! \details Same as std::lock_guard<std::mutex>.
|
||||
//! When a PIMutexLocker object is created, it attempts to lock the mutex it is given, if "condition" true.
|
||||
//! When control leaves the scope in which the PIMutexLocker object was created,
|
||||
//! the PIMutexLocker is destructed and the mutex is released, if "condition" true.
|
||||
//! If "condition" false this class do nothing.
|
||||
//! The PIMutexLocker class is non-copyable.
|
||||
class PIP_EXPORT PIMutexLocker
|
||||
{
|
||||
public:
|
||||
NO_COPY_CLASS(PIMutexLocker)
|
||||
PIMutexLocker(PIMutex & m, bool condition = true): mutex(m), cond(condition) {if (cond) mutex.lock();}
|
||||
~PIMutexLocker() {if (cond) mutex.unlock();}
|
||||
|
||||
PIMutexLocker(const PIMutexLocker&) = delete;
|
||||
PIMutexLocker& operator=(const PIMutexLocker&) = delete;
|
||||
private:
|
||||
PIMutex & mutex;
|
||||
std::atomic_bool cond;
|
||||
|
||||
@@ -71,7 +71,8 @@ class PIP_EXPORT PIThread: public PIObject
|
||||
PIOBJECT_SUBCLASS(PIThread, PIObject)
|
||||
friend class PIIntrospectionThreads;
|
||||
public:
|
||||
|
||||
NO_COPY_CLASS(PIThread)
|
||||
|
||||
//! Contructs thread with custom data "data", external function "func" and main loop delay "loop_delay".
|
||||
PIThread(void * data, ThreadFunc func, bool startNow = false, int loop_delay = -1);
|
||||
|
||||
@@ -257,8 +258,6 @@ protected:
|
||||
PRIVATE_DECLARATION
|
||||
|
||||
private:
|
||||
NO_COPY_CLASS(PIThread)
|
||||
|
||||
bool _startThread(void * func);
|
||||
void _beginThread();
|
||||
void _runThread();
|
||||
|
||||
@@ -78,7 +78,8 @@ protected:
|
||||
class PIP_EXPORT PITimer: public PIObject {
|
||||
PIOBJECT_SUBCLASS(PITimer, PIObject)
|
||||
public:
|
||||
|
||||
NO_COPY_CLASS(PITimer)
|
||||
|
||||
//! \brief Constructs timer with PITimer::Thread implementation
|
||||
explicit PITimer();
|
||||
|
||||
@@ -254,17 +255,13 @@ protected:
|
||||
virtual void tick(void * data_, int delimiter) {}
|
||||
|
||||
void * data_t;
|
||||
volatile bool lockRun, callEvents;
|
||||
std::atomic_bool lockRun, callEvents;
|
||||
PIMutex mutex_;
|
||||
TimerEvent ret_func;
|
||||
TimerImplementation imp_mode;
|
||||
PIVector<Delimiter> delims;
|
||||
|
||||
mutable _PITimerBase * imp;
|
||||
|
||||
private:
|
||||
NO_COPY_CLASS(PITimer)
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user