#15 убрать PIP_CXX11_SUPPORT
This commit is contained in:
@@ -133,11 +133,7 @@ public:
|
|||||||
bool direction;
|
bool direction;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
typedef std::function<void(KeyEvent, void *)> KBFunc;
|
typedef std::function<void(KeyEvent, void *)> KBFunc;
|
||||||
#else
|
|
||||||
typedef void (*KBFunc)(KeyEvent, void * );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//! Constructs keyboard listener with external function "slot" and custom data "data"
|
//! Constructs keyboard listener with external function "slot" and custom data "data"
|
||||||
explicit PIKbdListener(KBFunc slot = 0, void * data = 0, bool startNow = true);
|
explicit PIKbdListener(KBFunc slot = 0, void * data = 0, bool startNow = true);
|
||||||
@@ -154,10 +150,8 @@ public:
|
|||||||
//! Set external function to "slot"
|
//! Set external function to "slot"
|
||||||
void setSlot(KBFunc slot) {ret_func = slot;}
|
void setSlot(KBFunc slot) {ret_func = slot;}
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
//! Set external function to "slot"
|
//! Set external function to "slot"
|
||||||
void setSlot(std::function<void(KeyEvent)> slot) {ret_func = [slot](KeyEvent e, void *){slot(e);};}
|
void setSlot(std::function<void(KeyEvent)> slot) {ret_func = [slot](KeyEvent e, void *){slot(e);};}
|
||||||
#endif
|
|
||||||
|
|
||||||
//! Returns if exit key if awaiting
|
//! Returns if exit key if awaiting
|
||||||
bool exitCaptured() const {return exit_enabled;}
|
bool exitCaptured() const {return exit_enabled;}
|
||||||
|
|||||||
@@ -364,7 +364,6 @@ public:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
const PIDeque<T> & forEach(std::function<void(const T &)> f) const {
|
const PIDeque<T> & forEach(std::function<void(const T &)> f) const {
|
||||||
for (uint i = 0; i < pid_size; ++i)
|
for (uint i = 0; i < pid_size; ++i)
|
||||||
f(pid_data[i + pid_start]);
|
f(pid_data[i + pid_start]);
|
||||||
@@ -388,7 +387,6 @@ public:
|
|||||||
ret << f(pid_data[i + pid_start]);
|
ret << f(pid_data[i + pid_start]);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void _reset() {pid_size = pid_rsize = pid_start = 0; pid_data = 0;}
|
inline void _reset() {pid_size = pid_rsize = pid_start = 0; pid_data = 0;}
|
||||||
|
|||||||
@@ -358,7 +358,6 @@ public:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
const PIVector<T> & forEach(std::function<void(const T &)> f) const {
|
const PIVector<T> & forEach(std::function<void(const T &)> f) const {
|
||||||
for (uint i = 0; i < piv_size; ++i)
|
for (uint i = 0; i < piv_size; ++i)
|
||||||
f(piv_data[i]);
|
f(piv_data[i]);
|
||||||
@@ -382,7 +381,6 @@ public:
|
|||||||
ret << f(piv_data[i]);
|
ret << f(piv_data[i]);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void _reset() {piv_size = piv_rsize = 0; piv_data = 0;}
|
inline void _reset() {piv_size = piv_rsize = 0; piv_data = 0;}
|
||||||
|
|||||||
@@ -313,7 +313,6 @@ bool PIObject::piConnectU(PIObject * src, const PIString & sig, PIObject * dest_
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
bool PIObject::piConnectLS(PIObject * src, const PIString & sig, std::function<void()> * f, const char * loc) {
|
bool PIObject::piConnectLS(PIObject * src, const PIString & sig, std::function<void()> * f, const char * loc) {
|
||||||
if (src == 0) {
|
if (src == 0) {
|
||||||
delete f;
|
delete f;
|
||||||
@@ -345,7 +344,6 @@ bool PIObject::piConnectLS(PIObject * src, const PIString & sig, std::function<v
|
|||||||
//piCout << "finished";
|
//piCout << "finished";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void PIObject::piDisconnect(PIObject * src, const PIString & sig, PIObject * dest, void * ev_h) {
|
void PIObject::piDisconnect(PIObject * src, const PIString & sig, PIObject * dest, void * ev_h) {
|
||||||
@@ -669,8 +667,6 @@ void PIObject::__MetaData::addScope(const PIString & s, uint shash) {
|
|||||||
|
|
||||||
|
|
||||||
void PIObject::__Connection::destroy() {
|
void PIObject::__Connection::destroy() {
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
if (functor) delete functor;
|
if (functor) delete functor;
|
||||||
functor = nullptr;
|
functor = nullptr;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -459,9 +459,7 @@
|
|||||||
|
|
||||||
#define CONNECTU(src, event, dest, handler) PIObject::piConnectU(src, PIStringAscii(#event), dest, dest, PIStringAscii(#handler), LOCATION);
|
#define CONNECTU(src, event, dest, handler) PIObject::piConnectU(src, PIStringAscii(#event), dest, dest, PIStringAscii(#handler), LOCATION);
|
||||||
#define CONNECTU_QUEUED(src, event, dest, handler, performer) PIObject::piConnectU(src, PIStringAscii(#event), dest, dest, PIStringAscii(#handler), LOCATION, performer);
|
#define CONNECTU_QUEUED(src, event, dest, handler, performer) PIObject::piConnectU(src, PIStringAscii(#event), dest, dest, PIStringAscii(#handler), LOCATION, performer);
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
#define CONNECTL(src, event, functor) PIObject::piConnectLS(src, PIStringAscii(#event), PIObject::__newFunctor(&(src)->__stat_eh_##event##__, functor), LOCATION);
|
||||||
# define CONNECTL(src, event, functor) PIObject::piConnectLS(src, PIStringAscii(#event), PIObject::__newFunctor(&(src)->__stat_eh_##event##__, functor), LOCATION);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CONNECT0(ret, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*))(&(src)->__stat_eh_##event##__), 0, LOCATION);
|
#define CONNECT0(ret, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*))(&(src)->__stat_eh_##event##__), 0, LOCATION);
|
||||||
#define CONNECT1(ret, a0, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*, a0))(&(src)->__stat_eh_##event##__), 1, LOCATION);
|
#define CONNECT1(ret, a0, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*, a0))(&(src)->__stat_eh_##event##__), 1, LOCATION);
|
||||||
@@ -499,21 +497,13 @@ class PIP_EXPORT PIObject {
|
|||||||
typedef void __Parent__;
|
typedef void __Parent__;
|
||||||
friend class PIIntrospection;
|
friend class PIIntrospection;
|
||||||
public:
|
public:
|
||||||
|
NO_COPY_CLASS(PIObject)
|
||||||
|
|
||||||
//! Contructs PIObject with name "name"
|
//! Contructs PIObject with name "name"
|
||||||
explicit PIObject(const PIString & name = PIString());
|
explicit PIObject(const PIString & name = PIString());
|
||||||
|
|
||||||
virtual ~PIObject();
|
virtual ~PIObject();
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
explicit PIObject(const PIObject & ) = delete;
|
|
||||||
void operator =(const PIObject & ) = delete;
|
|
||||||
#else
|
|
||||||
private:
|
|
||||||
explicit PIObject(const PIObject & );
|
|
||||||
void operator =(const PIObject & );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint _signature_;
|
uint _signature_;
|
||||||
|
|
||||||
@@ -607,13 +597,11 @@ public:
|
|||||||
// / Direct connect
|
// / Direct connect
|
||||||
static void piConnect(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, void * ev_h, void * e_h, int args, const char * loc);
|
static void piConnect(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, void * ev_h, void * e_h, int args, const char * loc);
|
||||||
static bool piConnectU(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, const PIString & hname, const char * loc, PIObject * performer = 0);
|
static bool piConnectU(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, const PIString & hname, const char * loc, PIObject * performer = 0);
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
static bool piConnectLS(PIObject * src, const PIString & sig, std::function<void()> * f, const char * loc);
|
static bool piConnectLS(PIObject * src, const PIString & sig, std::function<void()> * f, const char * loc);
|
||||||
template <typename INPUT, typename... TYPES>
|
template <typename INPUT, typename... TYPES>
|
||||||
static std::function<void()> * __newFunctor(void(*stat_handler)(void*,TYPES...), INPUT functor) {
|
static std::function<void()> * __newFunctor(void(*stat_handler)(void*,TYPES...), INPUT functor) {
|
||||||
return (std::function<void()>*)(new std::function<void(TYPES...)>(functor));
|
return (std::function<void()>*)(new std::function<void(TYPES...)>(functor));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// / Through names and mixed
|
// / Through names and mixed
|
||||||
static void piConnect(const PIString & src, const PIString & sig, void * dest, void * ev_h);
|
static void piConnect(const PIString & src, const PIString & sig, void * dest, void * ev_h);
|
||||||
@@ -635,11 +623,9 @@ public:
|
|||||||
for (int j = 0; j < sender->connections.size_s(); ++j) {
|
for (int j = 0; j < sender->connections.size_s(); ++j) {
|
||||||
__Connection i(sender->connections[j]);
|
__Connection i(sender->connections[j]);
|
||||||
if (i.eventID != eventID) continue;
|
if (i.eventID != eventID) continue;
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
if (i.functor) {
|
if (i.functor) {
|
||||||
(*(i.functor))();
|
(*(i.functor))();
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
if (i.performer) {
|
if (i.performer) {
|
||||||
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender));
|
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender));
|
||||||
} else {
|
} else {
|
||||||
@@ -652,9 +638,7 @@ public:
|
|||||||
if (ts) i.dest_o->mutex_.unlock();
|
if (ts) i.dest_o->mutex_.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (!sender->isPIObject()) break;
|
if (!sender->isPIObject()) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -664,11 +648,9 @@ public:
|
|||||||
for (int j = 0; j < sender->connections.size_s(); ++j) {
|
for (int j = 0; j < sender->connections.size_s(); ++j) {
|
||||||
__Connection i(sender->connections[j]);
|
__Connection i(sender->connections[j]);
|
||||||
if (i.eventID != eventID) continue;
|
if (i.eventID != eventID) continue;
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
if (i.functor) {
|
if (i.functor) {
|
||||||
(*((std::function<void(T0)>*)i.functor))(v0);
|
(*((std::function<void(T0)>*)i.functor))(v0);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
if (i.performer) {
|
if (i.performer) {
|
||||||
PIVector<PIVariant> vl;
|
PIVector<PIVariant> vl;
|
||||||
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
|
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
|
||||||
@@ -684,9 +666,7 @@ public:
|
|||||||
if (ts) i.dest_o->mutex_.unlock();
|
if (ts) i.dest_o->mutex_.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (!sender->isPIObject()) break;
|
if (!sender->isPIObject()) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -695,11 +675,9 @@ public:
|
|||||||
for (int j = 0; j < sender->connections.size_s(); ++j) {
|
for (int j = 0; j < sender->connections.size_s(); ++j) {
|
||||||
__Connection i(sender->connections[j]);
|
__Connection i(sender->connections[j]);
|
||||||
if (i.eventID != eventID) continue;
|
if (i.eventID != eventID) continue;
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
if (i.functor) {
|
if (i.functor) {
|
||||||
(*((std::function<void(T0, T1)>*)i.functor))(v0, v1);
|
(*((std::function<void(T0, T1)>*)i.functor))(v0, v1);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
if (i.performer) {
|
if (i.performer) {
|
||||||
PIVector<PIVariant> vl;
|
PIVector<PIVariant> vl;
|
||||||
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
|
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
|
||||||
@@ -719,9 +697,7 @@ public:
|
|||||||
if (ts) i.dest_o->mutex_.unlock();
|
if (ts) i.dest_o->mutex_.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (!sender->isPIObject()) break;
|
if (!sender->isPIObject()) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -730,11 +706,9 @@ public:
|
|||||||
for (int j = 0; j < sender->connections.size_s(); ++j) {
|
for (int j = 0; j < sender->connections.size_s(); ++j) {
|
||||||
__Connection i(sender->connections[j]);
|
__Connection i(sender->connections[j]);
|
||||||
if (i.eventID != eventID) continue;
|
if (i.eventID != eventID) continue;
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
if (i.functor) {
|
if (i.functor) {
|
||||||
(*((std::function<void(T0, T1, T2)>*)i.functor))(v0, v1, v2);
|
(*((std::function<void(T0, T1, T2)>*)i.functor))(v0, v1, v2);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
if (i.performer) {
|
if (i.performer) {
|
||||||
PIVector<PIVariant> vl;
|
PIVector<PIVariant> vl;
|
||||||
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
|
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
|
||||||
@@ -756,9 +730,7 @@ public:
|
|||||||
if (ts) i.dest_o->mutex_.unlock();
|
if (ts) i.dest_o->mutex_.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (!sender->isPIObject()) break;
|
if (!sender->isPIObject()) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -767,11 +739,9 @@ public:
|
|||||||
for (int j = 0; j < sender->connections.size_s(); ++j) {
|
for (int j = 0; j < sender->connections.size_s(); ++j) {
|
||||||
__Connection i(sender->connections[j]);
|
__Connection i(sender->connections[j]);
|
||||||
if (i.eventID != eventID) continue;
|
if (i.eventID != eventID) continue;
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
if (i.functor) {
|
if (i.functor) {
|
||||||
(*((std::function<void(T0, T1, T2, T3)>*)i.functor))(v0, v1, v2, v3);
|
(*((std::function<void(T0, T1, T2, T3)>*)i.functor))(v0, v1, v2, v3);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
if (i.performer) {
|
if (i.performer) {
|
||||||
PIVector<PIVariant> vl;
|
PIVector<PIVariant> vl;
|
||||||
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
|
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
|
||||||
@@ -795,9 +765,7 @@ public:
|
|||||||
if (ts) i.dest_o->mutex_.unlock();
|
if (ts) i.dest_o->mutex_.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (!sender->isPIObject()) break;
|
if (!sender->isPIObject()) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -897,16 +865,12 @@ private:
|
|||||||
dest = d;
|
dest = d;
|
||||||
args_count = ac;
|
args_count = ac;
|
||||||
performer = p;
|
performer = p;
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
functor = 0;
|
functor = 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
void destroy();
|
void destroy();
|
||||||
void * slot;
|
void * slot;
|
||||||
void * signal;
|
void * signal;
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
std::function<void()> * functor;
|
std::function<void()> * functor;
|
||||||
#endif
|
|
||||||
PIString event;
|
PIString event;
|
||||||
uint eventID;
|
uint eventID;
|
||||||
PIObject * dest_o;
|
PIObject * dest_o;
|
||||||
|
|||||||
@@ -68,15 +68,10 @@ inline complexd sign(const complexd & x) {return complexd(sign(x.real()), sign(x
|
|||||||
inline complexd round(const complexd & c) {return complexd(piRound<double>(c.real()), piRound<double>(c.imag()));}
|
inline complexd round(const complexd & c) {return complexd(piRound<double>(c.real()), piRound<double>(c.imag()));}
|
||||||
inline complexd floor(const complexd & c) {return complexd(floor(c.real()), floor(c.imag()));}
|
inline complexd floor(const complexd & c) {return complexd(floor(c.real()), floor(c.imag()));}
|
||||||
inline complexd ceil (const complexd & c) {return complexd(ceil(c.real()), ceil(c.imag()));}
|
inline complexd ceil (const complexd & c) {return complexd(ceil(c.real()), ceil(c.imag()));}
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
# define acosc acos
|
#define acosc acos
|
||||||
# define asinc asin
|
#define asinc asin
|
||||||
# define atanc atan
|
#define atanc atan
|
||||||
#else
|
|
||||||
inline complexd atanc(const complexd & c) {return complexd(0., 0.5) * log((complexd_1 - complexd_i * c) / (complexd_1 + complexd_i * c));}
|
|
||||||
inline complexd asinc(const complexd & c) {return -complexd_i * log(complexd_i * c + sqrt(complexd_1 - c * c));}
|
|
||||||
inline complexd acosc(const complexd & c) {return -complexd_i * log(c + complexd_i * sqrt(complexd_1 - c * c));}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CC_GCC
|
#ifdef CC_GCC
|
||||||
# if CC_GCC_VERSION <= 0x025F
|
# if CC_GCC_VERSION <= 0x025F
|
||||||
|
|||||||
@@ -20,10 +20,6 @@
|
|||||||
#ifndef PIPLATFORM_H
|
#ifndef PIPLATFORM_H
|
||||||
#define PIPLATFORM_H
|
#define PIPLATFORM_H
|
||||||
|
|
||||||
#if (__cplusplus >= 201103L) // стандарт C++ 11 или выше
|
|
||||||
#define PIP_CXX11_SUPPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
|
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
|
||||||
# define WINDOWS
|
# define WINDOWS
|
||||||
# define ARCH_BITS_64
|
# define ARCH_BITS_64
|
||||||
|
|||||||
@@ -184,7 +184,6 @@ PIThread::PIThread(void * data, ThreadFunc func, bool startNow, int timer_delay)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
PIThread::PIThread(std::function<void ()> func, bool startNow, int timer_delay) {
|
PIThread::PIThread(std::function<void ()> func, bool startNow, int timer_delay) {
|
||||||
PIINTROSPECTION_THREAD_NEW(this);
|
PIINTROSPECTION_THREAD_NEW(this);
|
||||||
tid_ = -1;
|
tid_ = -1;
|
||||||
@@ -196,7 +195,6 @@ PIThread::PIThread(std::function<void ()> func, bool startNow, int timer_delay)
|
|||||||
delay_ = timer_delay;
|
delay_ = timer_delay;
|
||||||
if (startNow) start(timer_delay);
|
if (startNow) start(timer_delay);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
PIThread::PIThread(bool startNow, int timer_delay): PIObject() {
|
PIThread::PIThread(bool startNow, int timer_delay): PIObject() {
|
||||||
|
|||||||
@@ -60,11 +60,7 @@ public:
|
|||||||
static __PIThreadCollection_Initializer__ __PIThreadCollection_initializer__;
|
static __PIThreadCollection_Initializer__ __PIThreadCollection_initializer__;
|
||||||
|
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
typedef std::function<void(void *)> ThreadFunc;
|
typedef std::function<void(void *)> ThreadFunc;
|
||||||
#else
|
|
||||||
typedef void (*ThreadFunc)(void * );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class PIP_EXPORT PIThread: public PIObject
|
class PIP_EXPORT PIThread: public PIObject
|
||||||
{
|
{
|
||||||
@@ -76,10 +72,8 @@ public:
|
|||||||
//! Contructs thread with custom data "data", external function "func" and main loop delay "loop_delay".
|
//! 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);
|
PIThread(void * data, ThreadFunc func, bool startNow = false, int loop_delay = -1);
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
//! Contructs thread with external function "func" and main loop delay "loop_delay".
|
//! Contructs thread with external function "func" and main loop delay "loop_delay".
|
||||||
PIThread(std::function<void()> func, bool startNow = false, int loop_delay = -1);
|
PIThread(std::function<void()> func, bool startNow = false, int loop_delay = -1);
|
||||||
#endif
|
|
||||||
|
|
||||||
//! Contructs thread with main loop delay "loop_delay".
|
//! Contructs thread with main loop delay "loop_delay".
|
||||||
PIThread(bool startNow = false, int loop_delay = -1);
|
PIThread(bool startNow = false, int loop_delay = -1);
|
||||||
@@ -99,10 +93,8 @@ public:
|
|||||||
EVENT_HANDLER1(bool, start, int, timer_delay);
|
EVENT_HANDLER1(bool, start, int, timer_delay);
|
||||||
bool start(ThreadFunc func) {return start(func, -1);}
|
bool start(ThreadFunc func) {return start(func, -1);}
|
||||||
bool start(ThreadFunc func, int timer_delay) {ret_func = func; return start(timer_delay);}
|
bool start(ThreadFunc func, int timer_delay) {ret_func = func; return start(timer_delay);}
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
bool start(std::function<void()> func) {return start(func, -1);}
|
bool start(std::function<void()> func) {return start(func, -1);}
|
||||||
bool start(std::function<void()> func, int timer_delay) {ret_func = [func](void*){func();}; return start(timer_delay);}
|
bool start(std::function<void()> func, int timer_delay) {ret_func = [func](void*){func();}; return start(timer_delay);}
|
||||||
#endif
|
|
||||||
EVENT_HANDLER0(bool, startOnce);
|
EVENT_HANDLER0(bool, startOnce);
|
||||||
EVENT_HANDLER1(bool, startOnce, ThreadFunc, func) {ret_func = func; return startOnce();}
|
EVENT_HANDLER1(bool, startOnce, ThreadFunc, func) {ret_func = func; return startOnce();}
|
||||||
EVENT_HANDLER0(void, stop) {stop(false);}
|
EVENT_HANDLER0(void, stop) {stop(false);}
|
||||||
@@ -115,10 +107,8 @@ public:
|
|||||||
//! \brief Set external function that will be executed after every \a run()
|
//! \brief Set external function that will be executed after every \a run()
|
||||||
void setSlot(ThreadFunc func) {ret_func = func;}
|
void setSlot(ThreadFunc func) {ret_func = func;}
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
//! \brief Set external function that will be executed after every \a run()
|
//! \brief Set external function that will be executed after every \a run()
|
||||||
void setSlot(std::function<void()> func) {ret_func = [func](void*){func();};}
|
void setSlot(std::function<void()> func) {ret_func = [func](void*){func();};}
|
||||||
#endif
|
|
||||||
|
|
||||||
//! \brief Set priority of thread
|
//! \brief Set priority of thread
|
||||||
void setPriority(PIThread::Priority prior);
|
void setPriority(PIThread::Priority prior);
|
||||||
@@ -161,11 +151,9 @@ public:
|
|||||||
//! and automatically delete it on function finish
|
//! and automatically delete it on function finish
|
||||||
static void runOnce(PIObject * object, const char * handler, const PIString & name = PIString());
|
static void runOnce(PIObject * object, const char * handler, const PIString & name = PIString());
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
//! \brief Start function \"func\" in separate thread with name \"name\"
|
//! \brief Start function \"func\" in separate thread with name \"name\"
|
||||||
//! and automatically delete it on function finish
|
//! and automatically delete it on function finish
|
||||||
static void runOnce(std::function<void()> func, const PIString & name = PIString());
|
static void runOnce(std::function<void()> func, const PIString & name = PIString());
|
||||||
#endif
|
|
||||||
|
|
||||||
//! \handlers
|
//! \handlers
|
||||||
//! \{
|
//! \{
|
||||||
|
|||||||
@@ -479,7 +479,6 @@ PITimer::PITimer(TimerEvent slot, void * data, PITimer::TimerImplementation ti):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
PITimer::PITimer(std::function<void ()> slot, PITimer::TimerImplementation ti) {
|
PITimer::PITimer(std::function<void ()> slot, PITimer::TimerImplementation ti) {
|
||||||
imp_mode = ti;
|
imp_mode = ti;
|
||||||
initFirst();
|
initFirst();
|
||||||
@@ -493,7 +492,7 @@ PITimer::PITimer(std::function<void (void *)> slot, void * data, PITimer::TimerI
|
|||||||
data_t = data;
|
data_t = data;
|
||||||
ret_func = [slot](void *d, int){slot(d);};
|
ret_func = [slot](void *d, int){slot(d);};
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
PITimer::~PITimer() {
|
PITimer::~PITimer() {
|
||||||
destroy();
|
destroy();
|
||||||
|
|||||||
@@ -26,11 +26,7 @@
|
|||||||
#include "pithread.h"
|
#include "pithread.h"
|
||||||
#include "pitime.h"
|
#include "pitime.h"
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
typedef std::function<void(void *, int)> TimerEvent;
|
typedef std::function<void(void *, int)> TimerEvent;
|
||||||
#else
|
|
||||||
typedef void (*TimerEvent)(void *, int);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class PITimer;
|
class PITimer;
|
||||||
|
|
||||||
@@ -97,13 +93,11 @@ public:
|
|||||||
//! \brief Constructs timer with "slot" slot void(void *,int), "data" data and "ti" implementation
|
//! \brief Constructs timer with "slot" slot void(void *,int), "data" data and "ti" implementation
|
||||||
explicit PITimer(TimerEvent slot, void * data = 0, TimerImplementation ti = Thread);
|
explicit PITimer(TimerEvent slot, void * data = 0, TimerImplementation ti = Thread);
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
//! \brief Constructs timer with "slot" slot void(), and "ti" implementation
|
//! \brief Constructs timer with "slot" slot void(), and "ti" implementation
|
||||||
explicit PITimer(std::function<void ()> slot, TimerImplementation ti = Thread);
|
explicit PITimer(std::function<void ()> slot, TimerImplementation ti = Thread);
|
||||||
|
|
||||||
//! \brief Constructs timer with "slot" slot void(void *), "data" data and "ti" implementation
|
//! \brief Constructs timer with "slot" slot void(void *), "data" data and "ti" implementation
|
||||||
explicit PITimer(std::function<void (void *)> slot, void * data, TimerImplementation ti = Thread);
|
explicit PITimer(std::function<void (void *)> slot, void * data, TimerImplementation ti = Thread);
|
||||||
#endif
|
|
||||||
|
|
||||||
virtual ~PITimer();
|
virtual ~PITimer();
|
||||||
|
|
||||||
@@ -160,13 +154,11 @@ public:
|
|||||||
//! \brief Set timer tick function
|
//! \brief Set timer tick function
|
||||||
void setSlot(TimerEvent slot) {ret_func = slot;}
|
void setSlot(TimerEvent slot) {ret_func = slot;}
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
//! \brief Set timer tick function
|
//! \brief Set timer tick function
|
||||||
void setSlot(std::function<void ()> slot) {ret_func = [slot](void *, int){slot();};}
|
void setSlot(std::function<void ()> slot) {ret_func = [slot](void *, int){slot();};}
|
||||||
|
|
||||||
//! \brief Set timer tick function
|
//! \brief Set timer tick function
|
||||||
void setSlot(std::function<void (void *)> slot) {ret_func = [slot](void *d, int){slot(d);};}
|
void setSlot(std::function<void (void *)> slot) {ret_func = [slot](void *d, int){slot(d);};}
|
||||||
#endif
|
|
||||||
|
|
||||||
//! \brief Returns common data passed to tick functions
|
//! \brief Returns common data passed to tick functions
|
||||||
void * data() const {return data_t;}
|
void * data() const {return data_t;}
|
||||||
@@ -186,13 +178,11 @@ public:
|
|||||||
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||||
void addDelimiter(int delim, TimerEvent slot = 0) {delims << Delimiter(slot, delim);}
|
void addDelimiter(int delim, TimerEvent slot = 0) {delims << Delimiter(slot, delim);}
|
||||||
|
|
||||||
#ifdef PIP_CXX11_SUPPORT
|
|
||||||
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||||
void addDelimiter(int delim, std::function<void ()> slot) {delims << Delimiter([slot](void *, int){slot();}, delim);}
|
void addDelimiter(int delim, std::function<void ()> slot) {delims << Delimiter([slot](void *, int){slot();}, delim);}
|
||||||
|
|
||||||
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||||
void addDelimiter(int delim, std::function<void (void *)> slot) {delims << Delimiter([slot](void *d, int){slot(d);}, delim);}
|
void addDelimiter(int delim, std::function<void (void *)> slot) {delims << Delimiter([slot](void *d, int){slot(d);}, delim);}
|
||||||
#endif
|
|
||||||
|
|
||||||
//! \brief Remove all frequency delimiters \b delim.
|
//! \brief Remove all frequency delimiters \b delim.
|
||||||
void removeDelimiter(int delim) {for (int i = 0; i < delims.size_s(); ++i) if (delims[i].delim == delim) {delims.remove(i); i--;}}
|
void removeDelimiter(int delim) {for (int i = 0; i < delims.size_s(); ++i) if (delims[i].delim == delim) {delims.remove(i); i--;}}
|
||||||
|
|||||||
Reference in New Issue
Block a user