git-svn-id: svn://db.shs.com.ru/pip@467 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2017-04-24 15:34:37 +00:00
parent c92ea2ad6e
commit 0051d4cde9
9 changed files with 108 additions and 78 deletions

View File

@@ -143,9 +143,12 @@ namespace PIScreenTypes {
} }
inline PIByteArray & operator <<(PIByteArray & s, const PIScreenTypes::Cell & v) {s << v.symbol << v.format.raw_format; return s;} //inline PIByteArray & operator <<(PIByteArray & s, const PIScreenTypes::Cell & v) {s << v.symbol << v.format.raw_format; return s;}
inline PIByteArray & operator >>(PIByteArray & s, PIScreenTypes::Cell & v) {s >> v.symbol >> v.format.raw_format; return s;} //inline PIByteArray & operator >>(PIByteArray & s, PIScreenTypes::Cell & v) {s >> v.symbol >> v.format.raw_format; return s;}
__PICONTAINERS_SIMPLE_TYPE__(PIScreenTypes::Cell)
__PIBYTEARRAY_SIMPLE_TYPE__(PIScreenTypes::Cell)
#endif // PISCREENTYPES_H #endif // PISCREENTYPES_H

View File

@@ -23,18 +23,22 @@
#ifndef PIBYTEARRAY_H #ifndef PIBYTEARRAY_H
#define PIBYTEARRAY_H #define PIBYTEARRAY_H
#ifdef DOXYGEN
//! This macro allow stream template operators for write and read any type from byte array. Use it with attention!
# define PIP_BYTEARRAY_STREAM_ANY_TYPE
#endif
#include "pichar.h" #include "pichar.h"
#include "pibitarray.h" #include "pibitarray.h"
#include "pimap.h" #include "pimap.h"
__PICONTAINERS_SIMPLE_TYPE__(PIChar) __PICONTAINERS_SIMPLE_TYPE__(PIChar)
#define __PIBYTEARRAY_SIMPLE_TYPE__(T) \
template<> \
inline PIByteArray & operator <<(PIByteArray & s, const PIVector<T> & v) {s << int(v.size_s()); int os = s.size_s(); s.enlarge(v.size_s()*sizeof(T)); memcpy(s.data(os), v.data(), v.size_s()*sizeof(T)); return s;} \
template<> \
inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {assert(s.size_s() >= 4); int sz; s >> sz; v.resize(sz); if (sz > 0) memcpy(v.data(), s.data(), sz*sizeof(T)); s.remove(0, sz*sizeof(T)); return s;} \
template<> \
inline PIByteArray & operator <<(PIByteArray & s, const PIDeque<T> & v) {s << int(v.size_s()); int os = s.size_s(); s.enlarge(v.size_s()*sizeof(T)); memcpy(s.data(os), v.data(), v.size_s()*sizeof(T)); return s;} \
template<> \
inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {assert(s.size_s() >= 4); int sz; s >> sz; v.resize(sz); if (sz > 0) memcpy(v.data(), s.data(), sz*sizeof(T)); s.remove(0, sz*sizeof(T)); return s;}
class PIString; class PIString;
class PIByteArray; class PIByteArray;
@@ -258,22 +262,31 @@ inline PIByteArray & operator >>(PIByteArray & s, PIMap<Key, T> & v) {
return s; return s;
} }
#ifdef PIP_BYTEARRAY_STREAM_ANY_TYPE
template<typename T> template<typename T>
inline PIByteArray & operator <<(PIByteArray & s, const T & v) {PBA_OPERATOR_TO return s;} inline PIByteArray & operator <<(PIByteArray & s, const T & ) {piCout << "[PIByteArray] Warning: using undeclared operator <<!"; return s;}
#endif
#ifdef PIP_BYTEARRAY_STREAM_ANY_TYPE
template<typename T> template<typename T>
inline PIByteArray & operator >>(PIByteArray & s, T & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;} inline PIByteArray & operator >>(PIByteArray & s, T & ) {piCout << "[PIByteArray] Warning: using undeclared operator >>!"; return s;}
#endif
#undef PBA_OPERATOR_FROM
//! \relatesalso PIByteArray \brief Byte arrays compare operator //! \relatesalso PIByteArray \brief Byte arrays compare operator
inline bool operator ==(PIByteArray & f, PIByteArray & s) {if (f.size_s() != s.size_s()) return false; for (int i = 0; i < f.size_s(); ++i) if (f[i] != s[i]) return false; return true;} inline bool operator ==(PIByteArray & f, PIByteArray & s) {if (f.size_s() != s.size_s()) return false; for (int i = 0; i < f.size_s(); ++i) if (f[i] != s[i]) return false; return true;}
//! \relatesalso PIByteArray \brief Byte arrays compare operator //! \relatesalso PIByteArray \brief Byte arrays compare operator
inline bool operator !=(PIByteArray & f, PIByteArray & s) {if (f.size_s() != s.size_s()) return true; for (int i = 0; i < f.size_s(); ++i) if (f[i] != s[i]) return true; return false;} inline bool operator !=(PIByteArray & f, PIByteArray & s) {if (f.size_s() != s.size_s()) return true; for (int i = 0; i < f.size_s(); ++i) if (f[i] != s[i]) return true; return false;}
__PIBYTEARRAY_SIMPLE_TYPE__(bool)
__PIBYTEARRAY_SIMPLE_TYPE__(char)
//__PIBYTEARRAY_SIMPLE_TYPE__(uchar)
__PIBYTEARRAY_SIMPLE_TYPE__(short)
__PIBYTEARRAY_SIMPLE_TYPE__(ushort)
__PIBYTEARRAY_SIMPLE_TYPE__(int)
__PIBYTEARRAY_SIMPLE_TYPE__(uint)
__PIBYTEARRAY_SIMPLE_TYPE__(long)
__PIBYTEARRAY_SIMPLE_TYPE__(ulong)
__PIBYTEARRAY_SIMPLE_TYPE__(llong)
__PIBYTEARRAY_SIMPLE_TYPE__(ullong)
__PIBYTEARRAY_SIMPLE_TYPE__(float)
__PIBYTEARRAY_SIMPLE_TYPE__(double)
__PIBYTEARRAY_SIMPLE_TYPE__(ldouble)
__PIBYTEARRAY_SIMPLE_TYPE__(PIChar)
#endif // PIBYTEARRAY_H #endif // PIBYTEARRAY_H

View File

@@ -142,10 +142,16 @@ PIStringList PIObject::events() {
} }
*/ */
PIStringList PIObject::methodsEH() { PIStringList PIObject::scopeList() const {
PIMutexLocker ml(__eh_mutex()); PIMutexLocker ml(__meta_mutex());
return __meta_data()[className()].scope_list;
}
PIStringList PIObject::methodsEH() const {
PIMutexLocker ml(__meta_mutex());
PIStringList ret; PIStringList ret;
__EHData & ehd(__eh_data()[className()]); __MetaData & ehd(__meta_data()[className()]);
piForeachC (__EHPair & eh, ehd.eh_func) piForeachC (__EHPair & eh, ehd.eh_func)
ret << eh.second.fullFormat(); ret << eh.second.fullFormat();
return ret; return ret;
@@ -153,8 +159,8 @@ PIStringList PIObject::methodsEH() {
bool PIObject::isMethodEHContains(const PIString & name) const { bool PIObject::isMethodEHContains(const PIString & name) const {
PIMutexLocker ml(__eh_mutex()); PIMutexLocker ml(__meta_mutex());
__EHData & ehd(__eh_data()[className()]); __MetaData & ehd(__meta_data()[className()]);
piForeachC (__EHPair & eh, ehd.eh_func) piForeachC (__EHPair & eh, ehd.eh_func)
if (eh.second.func_name == name) if (eh.second.func_name == name)
return true; return true;
@@ -163,8 +169,8 @@ bool PIObject::isMethodEHContains(const PIString & name) const {
PIString PIObject::methodEHArguments(const PIString & name) const { PIString PIObject::methodEHArguments(const PIString & name) const {
PIMutexLocker ml(__eh_mutex()); PIMutexLocker ml(__meta_mutex());
__EHData & ehd(__eh_data()[className()]); __MetaData & ehd(__meta_data()[className()]);
piForeachC (__EHPair & eh, ehd.eh_func) piForeachC (__EHPair & eh, ehd.eh_func)
if (eh.second.func_name == name) if (eh.second.func_name == name)
return eh.second.arguments(); return eh.second.arguments();
@@ -173,8 +179,8 @@ PIString PIObject::methodEHArguments(const PIString & name) const {
PIString PIObject::methodEHFullFormat(const PIString & name) const { PIString PIObject::methodEHFullFormat(const PIString & name) const {
PIMutexLocker ml(__eh_mutex()); PIMutexLocker ml(__meta_mutex());
__EHData & ehd(__eh_data()[className()]); __MetaData & ehd(__meta_data()[className()]);
piForeachC (__EHPair & eh, ehd.eh_func) piForeachC (__EHPair & eh, ehd.eh_func)
if (eh.second.func_name == name) if (eh.second.func_name == name)
return eh.second.fullFormat(); return eh.second.fullFormat();
@@ -189,7 +195,7 @@ PIString PIObject::methodEHFromAddr(const void * addr) const {
PIVector<PIObject::__EHFunc> PIObject::findEH(const PIString & name) const { PIVector<PIObject::__EHFunc> PIObject::findEH(const PIString & name) const {
PIVector<__EHFunc> ret; PIVector<__EHFunc> ret;
__EHData & ehd(__eh_data()[className()]); __MetaData & ehd(__meta_data()[className()]);
piForeachC (__EHPair & eh, ehd.eh_func) piForeachC (__EHPair & eh, ehd.eh_func)
if (eh.second.func_name == name) if (eh.second.func_name == name)
ret << eh.second; ret << eh.second;
@@ -198,8 +204,8 @@ PIVector<PIObject::__EHFunc> PIObject::findEH(const PIString & name) const {
PIObject::__EHFunc PIObject::methodEH(const void * addr) const { PIObject::__EHFunc PIObject::methodEH(const void * addr) const {
PIMutexLocker ml(__eh_mutex()); PIMutexLocker ml(__meta_mutex());
return __eh_data()[className()].eh_func.value(addr); return __meta_data()[className()].eh_func.value(addr);
} }
@@ -229,7 +235,7 @@ bool PIObject::piConnectU(PIObject * src, const PIString & ename, PIObject * des
piCout << "[piConnectU] \"" << ename << "\" -> \"" << hname << "\" error: destination object is not PIObject! (" << loc << ")"; piCout << "[piConnectU] \"" << ename << "\" -> \"" << hname << "\" error: destination object is not PIObject! (" << loc << ")";
return false; return false;
} }
PIMutexLocker ml(__eh_mutex()); PIMutexLocker ml(__meta_mutex());
PIMutexLocker mls(src->mutex_connect); PIMutexLocker mls(src->mutex_connect);
PIMutexLocker mld(dest_o->mutex_connect, src != dest_o); PIMutexLocker mld(dest_o->mutex_connect, src != dest_o);
PIVector<__EHFunc> m_src = src->findEH(ename), m_dest = dest_o->findEH(hname); PIVector<__EHFunc> m_src = src->findEH(ename), m_dest = dest_o->findEH(hname);
@@ -348,14 +354,14 @@ void PIObject::updateConnectors() {
} }
PIMutex & PIObject::__eh_mutex() { PIMutex & PIObject::__meta_mutex() {
static PIMutex ret; static PIMutex ret;
return ret; return ret;
} }
PIMap<PIString, PIObject::__EHData> & PIObject::__eh_data() { PIMap<PIString, PIObject::__MetaData> & PIObject::__meta_data() {
static PIMap<PIString, PIObject::__EHData> ret; static PIMap<PIString, PIObject::__MetaData> ret;
return ret; return ret;
} }
@@ -427,7 +433,7 @@ void PIObject::dump(const PIString & line_prefix) const {
//printf("dump %d properties ok\n", properties_.size()); //printf("dump %d properties ok\n", properties_.size());
PICout(PICoutManipulators::AddNewLine) << line_prefix << " }"; PICout(PICoutManipulators::AddNewLine) << line_prefix << " }";
PICout(PICoutManipulators::AddNewLine) << line_prefix << " methodsEH {"; PICout(PICoutManipulators::AddNewLine) << line_prefix << " methodsEH {";
__EHData & ehd(__eh_data()[className()]); __MetaData & ehd(__meta_data()[className()]);
PICout(PICoutManipulators::AddNewLine) << line_prefix << " count: " << ehd.eh_func.size_s(); PICout(PICoutManipulators::AddNewLine) << line_prefix << " count: " << ehd.eh_func.size_s();
//printf("dump %d methods\n", ehd.eh_func.size()); //printf("dump %d methods\n", ehd.eh_func.size());
piForeachC (__EHPair & eh, ehd.eh_func) { piForeachC (__EHPair & eh, ehd.eh_func) {

View File

@@ -37,7 +37,7 @@
/// \relatesalso PIObject \brief you should use this macro after class declaration to use EVENT and EVENT_HANDLER and correct piCoutObj output /// \relatesalso PIObject \brief you should use this macro after class declaration to use EVENT and EVENT_HANDLER and correct piCoutObj output
#define PIOBJECT(name) #define PIOBJECT(name)
/// \relatesalso PIObject \brief you should use this macro after class declaration to use EVENT and EVENT_HANDLER of parent class /// \relatesalso PIObject \brief you should use this macro after class declaration to use EVENT and EVENT_HANDLER of parent class, and \a scopeList()
#define PIOBJECT_SUBCLASS(name, parent) #define PIOBJECT_SUBCLASS(name, parent)
@@ -196,19 +196,22 @@
__##name##_ParentInitializer__() { \ __##name##_ParentInitializer__() { \
PIString pn(name::__classNameS()); \ PIString pn(name::__classNameS()); \
if (pn.isEmpty()) return; \ if (pn.isEmpty()) return; \
PIMutexLocker ml(__eh_mutex()); \ PIMutexLocker ml(__meta_mutex()); \
if (__eh_data().contains(__classNameS())) return; \ if (__meta_data().contains(__classNameS())) return; \
__eh_data()[pn]; \ __meta_data()[pn]; \
__eh_data()[__classNameS()]; \ __meta_data()[__classNameS()]; \
__EHData & ehp(__eh_data()[pn]); \ __MetaData & ehp(__meta_data()[pn]); \
__EHData & eh(__eh_data()[__classNameS()]); \ __MetaData & eh(__meta_data()[__classNameS()]); \
eh.eh_set << ehp.eh_set; \ eh.eh_set << ehp.eh_set; \
eh.eh_func << ehp.eh_func; \ eh.eh_func << ehp.eh_func; \
eh.scope_list = ehp.scope_list; \
eh.addScope(__classNameS()); \
} \ } \
}; \ }; \
__##name##_ParentInitializer__ __##name##_parent_init__; \ __##name##_ParentInitializer__ __##name##_parent_init__; \
public: \ public: \
virtual const char * superClassName() const {return #name;} \ virtual const char * parentClassName() const {return #name;} \
typedef name __Parent__; \
private: private:
#define PIOBJECT_SUBCLASS(name, parent) PIOBJECT(name) PIOBJECT_PARENT(parent) #define PIOBJECT_SUBCLASS(name, parent) PIOBJECT(name) PIOBJECT_PARENT(parent)
@@ -218,8 +221,8 @@
class __##name##0_Initializer__ { \ class __##name##0_Initializer__ { \
public: \ public: \
__##name##0_Initializer__() { \ __##name##0_Initializer__() { \
PIMutexLocker ml(__eh_mutex()); \ PIMutexLocker ml(__meta_mutex()); \
__EHData & eh(__eh_data()[__classNameS()]); \ __MetaData & eh(__meta_data()[__classNameS()]); \
void * fp = (void*)(ret(*)(void*))__stat_eh_##name##__; \ void * fp = (void*)(ret(*)(void*))__stat_eh_##name##__; \
if (eh.eh_set[fp]) return; \ if (eh.eh_set[fp]) return; \
eh.eh_set << fp; \ eh.eh_set << fp; \
@@ -236,8 +239,8 @@
class __##name##1##n0##_Initializer__ { \ class __##name##1##n0##_Initializer__ { \
public: \ public: \
__##name##1##n0##_Initializer__() { \ __##name##1##n0##_Initializer__() { \
PIMutexLocker ml(__eh_mutex()); \ PIMutexLocker ml(__meta_mutex()); \
__EHData & eh(__eh_data()[__classNameS()]); \ __MetaData & eh(__meta_data()[__classNameS()]); \
void * fp = (void*)(ret(*)(void*, a0))__stat_eh_##name##__; \ void * fp = (void*)(ret(*)(void*, a0))__stat_eh_##name##__; \
if (eh.eh_set[fp]) return; \ if (eh.eh_set[fp]) return; \
eh.eh_set << fp; \ eh.eh_set << fp; \
@@ -256,8 +259,8 @@
class __##name##2##n0##n1##_Initializer__ { \ class __##name##2##n0##n1##_Initializer__ { \
public: \ public: \
__##name##2##n0##n1##_Initializer__() { \ __##name##2##n0##n1##_Initializer__() { \
PIMutexLocker ml(__eh_mutex()); \ PIMutexLocker ml(__meta_mutex()); \
__EHData & eh(__eh_data()[__classNameS()]); \ __MetaData & eh(__meta_data()[__classNameS()]); \
void * fp = (void*)(ret(*)(void*, a0, a1))__stat_eh_##name##__; \ void * fp = (void*)(ret(*)(void*, a0, a1))__stat_eh_##name##__; \
if (eh.eh_set[fp]) return; \ if (eh.eh_set[fp]) return; \
eh.eh_set << fp; \ eh.eh_set << fp; \
@@ -276,8 +279,8 @@
class __##name##3##n0##n1##n2##_Initializer__ { \ class __##name##3##n0##n1##n2##_Initializer__ { \
public: \ public: \
__##name##3##n0##n1##n2##_Initializer__() { \ __##name##3##n0##n1##n2##_Initializer__() { \
PIMutexLocker ml(__eh_mutex()); \ PIMutexLocker ml(__meta_mutex()); \
__EHData & eh(__eh_data()[__classNameS()]); \ __MetaData & eh(__meta_data()[__classNameS()]); \
void * fp = (void*)(ret(*)(void*, a0, a1, a2))__stat_eh_##name##__; \ void * fp = (void*)(ret(*)(void*, a0, a1, a2))__stat_eh_##name##__; \
if (eh.eh_set[fp]) return; \ if (eh.eh_set[fp]) return; \
eh.eh_set << fp; \ eh.eh_set << fp; \
@@ -296,8 +299,8 @@
class __##name##4##n0##n1##n2##n3##_Initializer__ { \ class __##name##4##n0##n1##n2##n3##_Initializer__ { \
public: \ public: \
__##name##4##n0##n1##n2##n3##_Initializer__() { \ __##name##4##n0##n1##n2##n3##_Initializer__() { \
PIMutexLocker ml(__eh_mutex()); \ PIMutexLocker ml(__meta_mutex()); \
__EHData & eh(__eh_data()[__classNameS()]); \ __MetaData & eh(__meta_data()[__classNameS()]); \
void * fp = (void*)(ret(*)(void*, a0, a1, a2, a3))__stat_eh_##name##__; \ void * fp = (void*)(ret(*)(void*, a0, a1, a2, a3))__stat_eh_##name##__; \
if (eh.eh_set[fp]) return; \ if (eh.eh_set[fp]) return; \
eh.eh_set << fp; \ eh.eh_set << fp; \
@@ -419,6 +422,7 @@ class PIP_EXPORT PIObject
friend class PIObjectManager; friend class PIObjectManager;
friend void dumpApplication(); friend void dumpApplication();
typedef PIObject __PIObject__; typedef PIObject __PIObject__;
typedef void __Parent__;
public: public:
//! Contructs PIObject with name "name" //! Contructs PIObject with name "name"
@@ -440,10 +444,13 @@ public:
//! Returns object class name //! Returns object class name
virtual const char * className() const {return "PIObject";} virtual const char * className() const {return "PIObject";}
static const PIString __classNameS() {return PIStringAscii("PIObject");}
//! Returns object superclass name //! Returns parent object class name
virtual const char * superClassName() const {return "";} virtual const char * parentClassName() const {return "";}
//! Return if debug of this object is active //! Return if debug of this object is active
bool debug() const {return property(PIStringAscii("debug")).toBool();} bool debug() const {return property(PIStringAscii("debug")).toBool();}
@@ -479,7 +486,8 @@ public:
void dump(const PIString & line_prefix = PIString()) const; void dump(const PIString & line_prefix = PIString()) const;
PIStringList methodsEH(); PIStringList scopeList() const;
PIStringList methodsEH() const;
bool isMethodEHContains(const PIString & name) const; bool isMethodEHContains(const PIString & name) const;
PIString methodEHArguments(const PIString & name) const; PIString methodEHArguments(const PIString & name) const;
PIString methodEHFullFormat(const PIString & name) const; PIString methodEHFullFormat(const PIString & name) const;
@@ -672,7 +680,7 @@ public:
bool isTypeOf() const { bool isTypeOf() const {
if (!this) return false; if (!this) return false;
if (!isPIObject()) return false; if (!isPIObject()) return false;
return (PIStringAscii(className()) == T::__classNameS()); return scopeList().contains(T::__classNameS());
} }
template<typename T> template<typename T>
T * cast() const { T * cast() const {
@@ -692,24 +700,28 @@ public:
static PIString simplifyType(const char * a); static PIString simplifyType(const char * a);
struct __EHFunc { struct __EHFunc {
__EHFunc(): addr(0) {;} __EHFunc(): addr(0), addrV(0) {;}
bool isNull() const {return addr == 0;} bool isNull() const {return addr == 0;}
PIString arguments() const; PIString arguments() const;
PIString fullFormat() const; PIString fullFormat() const;
void * addr; void * addr;
void * addrV;
PIString func_name; PIString func_name;
PIString type_ret; PIString type_ret;
PIString scope; PIString scope;
PIStringList types; PIStringList types;
PIStringList names; PIStringList names;
}; };
struct __EHData { struct __MetaData {
__MetaData() {scope_list << PIStringAscii("PIObject");}
void addScope(const PIString & s) {if (!scope_list.contains(s)) scope_list << s;}
PIStringList scope_list;
PISet<const void * > eh_set; PISet<const void * > eh_set;
PIMap<const void * , __EHFunc> eh_func; PIMap<const void * , __EHFunc> eh_func;
}; };
typedef PIPair<const void * , __EHFunc> __EHPair; typedef PIPair<const void * , __EHFunc> __EHPair;
static PIMutex & __eh_mutex(); static PIMutex & __meta_mutex();
static PIMap<PIString, __EHData> & __eh_data(); static PIMap<PIString, __MetaData> & __meta_data(); // [classname]=__MetaData
protected: protected:
@@ -720,8 +732,6 @@ protected:
virtual void propertyChanged(const PIString & name) {} virtual void propertyChanged(const PIString & name) {}
static const PIString __classNameS() {return PIStringAscii("PIObject");}
EVENT(deleted) EVENT(deleted)
//! \events //! \events

View File

@@ -237,7 +237,7 @@ public:
EVENT_HANDLER(bool, open) {if (!init_) init(); opened_ = openDevice(); if (opened_) opened(); return opened_;} EVENT_HANDLER(bool, open) {if (!init_) init(); opened_ = openDevice(); if (opened_) opened(); return opened_;}
EVENT_HANDLER1(bool, open, const PIString &, _path) {setPath(_path); if (!init_) init(); opened_ = openDevice(); if (opened_) opened(); return opened_;} EVENT_HANDLER1(bool, open, const PIString &, _path) {setPath(_path); if (!init_) init(); opened_ = openDevice(); if (opened_) opened(); return opened_;}
EVENT_HANDLER1(bool, open, const DeviceMode &, _mode) {mode_ = _mode; if (!init_) init(); opened_ = openDevice(); if (opened_) opened(); return opened_;} bool open(const DeviceMode & _mode) {mode_ = _mode; if (!init_) init(); opened_ = openDevice(); if (opened_) opened(); return opened_;}
EVENT_HANDLER2(bool, open, const PIString &, _path, const DeviceMode &, _mode) {setPath(_path); mode_ = _mode; if (!init_) init(); opened_ = openDevice(); if (opened_) opened(); return opened_;} EVENT_HANDLER2(bool, open, const PIString &, _path, const DeviceMode &, _mode) {setPath(_path); mode_ = _mode; if (!init_) init(); opened_ = openDevice(); if (opened_) opened(); return opened_;}
EVENT_HANDLER(bool, close) {opened_ = !closeDevice(); if (!opened_) closed(); return !opened_;} EVENT_HANDLER(bool, close) {opened_ = !closeDevice(); if (!opened_) closed(); return !opened_;}

View File

@@ -27,6 +27,10 @@ __PICONTAINERS_SIMPLE_TYPE__(complexi)
__PICONTAINERS_SIMPLE_TYPE__(complexf) __PICONTAINERS_SIMPLE_TYPE__(complexf)
__PICONTAINERS_SIMPLE_TYPE__(complexd) __PICONTAINERS_SIMPLE_TYPE__(complexd)
__PICONTAINERS_SIMPLE_TYPE__(complexld) __PICONTAINERS_SIMPLE_TYPE__(complexld)
__PIBYTEARRAY_SIMPLE_TYPE__(complexi)
__PIBYTEARRAY_SIMPLE_TYPE__(complexf)
__PIBYTEARRAY_SIMPLE_TYPE__(complexd)
__PIBYTEARRAY_SIMPLE_TYPE__(complexld)
inline complexd sign(const complexd & x) {return complexd(sign(x.real()), sign(x.imag()));} inline complexd sign(const complexd & x) {return complexd(sign(x.real()), sign(x.imag()));}

View File

@@ -5,6 +5,6 @@
#define PIP_VERSION_MAJOR 1 #define PIP_VERSION_MAJOR 1
#define PIP_VERSION_MINOR 0 #define PIP_VERSION_MINOR 0
#define PIP_VERSION_REVISION 0 #define PIP_VERSION_REVISION 0
#define PIP_VERSION_SUFFIX "_beta2" #define PIP_VERSION_SUFFIX "_rc1"
#endif // PIVERSION_H #endif // PIVERSION_H

View File

@@ -60,8 +60,8 @@ public:
EVENT_HANDLER0(bool, start) {return start(-1);} EVENT_HANDLER0(bool, start) {return start(-1);}
EVENT_HANDLER1(bool, start, int, timer_delay); EVENT_HANDLER1(bool, start, int, timer_delay);
EVENT_HANDLER1(bool, start, ThreadFunc, func) {ret_func = func; return start(-1);} bool start(ThreadFunc func) {ret_func = func; return start(-1);}
EVENT_HANDLER2(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);}
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);}
@@ -119,12 +119,6 @@ public:
* *
* \return \c false if thread already started or can`t start thread */ * \return \c false if thread already started or can`t start thread */
/** \fn bool start(ThreadFunc func, int timer_delay = -1)
* \brief Start thread
* \details Overloaded function. Set external function "func" before start
*
* \return \c false if thread already started or can`t start thread */
/** \fn bool startOnce() /** \fn bool startOnce()
* \brief Start thread without internal loop * \brief Start thread without internal loop
* \details Start execution of \a run() once. Thread also exec * \details Start execution of \a run() once. Thread also exec

View File

@@ -115,13 +115,13 @@ public:
bool isStopped() const {return !imp->running_;} bool isStopped() const {return !imp->running_;}
EVENT_HANDLER0(bool, start) {return imp->start();} EVENT_HANDLER0(bool, start) {return imp->start();}
EVENT_HANDLER1(bool, start, int, interval_ms_i) {setInterval(double(interval_ms_i)); return imp->start(double(interval_ms_i));}
EVENT_HANDLER1(bool, start, double, interval_ms_d) {setInterval(interval_ms_d); return imp->start(interval_ms_d);} EVENT_HANDLER1(bool, start, double, interval_ms_d) {setInterval(interval_ms_d); return imp->start(interval_ms_d);}
bool start(int interval_ms_i) {setInterval(double(interval_ms_i)); return imp->start(double(interval_ms_i));}
EVENT_HANDLER0(bool, restart) {imp->stop(); return imp->start();} EVENT_HANDLER0(bool, restart) {imp->stop(); return imp->start();}
EVENT_HANDLER1(void, startDeferred, double, delay_ms) {imp->startDeferred(delay_ms);} void startDeferred(double delay_ms) {imp->startDeferred(delay_ms);}
EVENT_HANDLER2(void, startDeferred, double, interval_ms, double, delay_ms) {imp->startDeferred(interval_ms, delay_ms);} void startDeferred(double interval_ms, double delay_ms) {imp->startDeferred(interval_ms, delay_ms);}
EVENT_HANDLER1(void, startDeferred, PIDateTime, start_datetime) {startDeferred(imp->interval_, start_datetime);} void startDeferred(PIDateTime start_datetime) {startDeferred(imp->interval_, start_datetime);}
EVENT_HANDLER2(void, startDeferred, double, interval_ms, PIDateTime, start_datetime) {imp->startDeferred(interval_ms, start_datetime);} void startDeferred(double interval_ms, PIDateTime start_datetime) {imp->startDeferred(interval_ms, start_datetime);}
EVENT_HANDLER0(bool, stop) {return imp->stop();} EVENT_HANDLER0(bool, stop) {return imp->stop();}
bool waitForFinish() {return waitForFinish(-1);} bool waitForFinish() {return waitForFinish(-1);}