git-svn-id: svn://db.shs.com.ru/pip@371 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -756,8 +756,6 @@ void PIConsole::addVariable(const PIString & name, const PIProtocol * ptr, int c
|
|||||||
addVariable("Integral Frequency, Hz", ptr->integralFrequency_ptr(), col, format);
|
addVariable("Integral Frequency, Hz", ptr->integralFrequency_ptr(), col, format);
|
||||||
addVariable("Receive speed", ptr->receiveSpeed_ptr(), col, format);
|
addVariable("Receive speed", ptr->receiveSpeed_ptr(), col, format);
|
||||||
addVariable("Send speed", ptr->sendSpeed_ptr(), col, format);
|
addVariable("Send speed", ptr->sendSpeed_ptr(), col, format);
|
||||||
addVariable("Receiver history size", ptr->receiverHistorySize_ptr(), col, format);
|
|
||||||
addVariable("Sender history size", ptr->senderHistorySize_ptr(), col, format);
|
|
||||||
addVariable("Disconnect Timeout, s", ptr->disconnectTimeout_ptr(), col, format);
|
addVariable("Disconnect Timeout, s", ptr->disconnectTimeout_ptr(), col, format);
|
||||||
addVariable("Quality", ptr->quality_ptr(), col, format);
|
addVariable("Quality", ptr->quality_ptr(), col, format);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,12 @@ PRIVATE_DEFINITION_START(PIKbdListener)
|
|||||||
#else
|
#else
|
||||||
struct termios sterm, tterm;
|
struct termios sterm, tterm;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef WINDOWS
|
||||||
|
DWORD
|
||||||
|
#else
|
||||||
|
int
|
||||||
|
#endif
|
||||||
|
ret;
|
||||||
PRIVATE_DEFINITION_END(PIKbdListener)
|
PRIVATE_DEFINITION_END(PIKbdListener)
|
||||||
|
|
||||||
|
|
||||||
@@ -174,7 +180,7 @@ void PIKbdListener::readKeyboard() {
|
|||||||
memset(rc, 0, 8);
|
memset(rc, 0, 8);
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
INPUT_RECORD ir;
|
INPUT_RECORD ir;
|
||||||
ReadConsoleInput(PRIVATE->hIn, &ir, 1, &ret);
|
ReadConsoleInput(PRIVATE->hIn, &ir, 1, &(PRIVATE->ret));
|
||||||
if (ir.EventType == KEY_EVENT) {
|
if (ir.EventType == KEY_EVENT) {
|
||||||
KEY_EVENT_RECORD ker = ir.Event.KeyEvent;
|
KEY_EVENT_RECORD ker = ir.Event.KeyEvent;
|
||||||
if (ker.bKeyDown) {
|
if (ker.bKeyDown) {
|
||||||
@@ -188,35 +194,35 @@ void PIKbdListener::readKeyboard() {
|
|||||||
if (ker.dwControlKeyState & CAPSLOCK_ON) shift = !shift;
|
if (ker.dwControlKeyState & CAPSLOCK_ON) shift = !shift;
|
||||||
//piCout << "key" << int(ker.wVirtualKeyCode) << int(ker.uChar.AsciiChar);
|
//piCout << "key" << int(ker.wVirtualKeyCode) << int(ker.uChar.AsciiChar);
|
||||||
switch (ker.wVirtualKeyCode) {
|
switch (ker.wVirtualKeyCode) {
|
||||||
case 8: ret = 1; ke.key = Backspace; break;
|
case 8: PRIVATE->ret = 1; ke.key = Backspace; break;
|
||||||
case 33: ret = 1; ke.key = PageUp; break;
|
case 33: PRIVATE->ret = 1; ke.key = PageUp; break;
|
||||||
case 34: ret = 1; ke.key = PageDown; break;
|
case 34: PRIVATE->ret = 1; ke.key = PageDown; break;
|
||||||
case 35: ret = 1; ke.key = End; break;
|
case 35: PRIVATE->ret = 1; ke.key = End; break;
|
||||||
case 36: ret = 1; ke.key = Home; break;
|
case 36: PRIVATE->ret = 1; ke.key = Home; break;
|
||||||
case 37: ret = 1; ke.key = LeftArrow; break;
|
case 37: PRIVATE->ret = 1; ke.key = LeftArrow; break;
|
||||||
case 38: ret = 1; ke.key = UpArrow; break;
|
case 38: PRIVATE->ret = 1; ke.key = UpArrow; break;
|
||||||
case 39: ret = 1; ke.key = RightArrow; break;
|
case 39: PRIVATE->ret = 1; ke.key = RightArrow; break;
|
||||||
case 40: ret = 1; ke.key = DownArrow; break;
|
case 40: PRIVATE->ret = 1; ke.key = DownArrow; break;
|
||||||
case 45: ret = 1; ke.key = Insert; break;
|
case 45: PRIVATE->ret = 1; ke.key = Insert; break;
|
||||||
case 46: ret = 1; ke.key = Delete; break;
|
case 46: PRIVATE->ret = 1; ke.key = Delete; break;
|
||||||
case '\r':
|
case '\r':
|
||||||
case '\n': ret = 1; ke.key = Return; break;
|
case '\n': PRIVATE->ret = 1; ke.key = Return; break;
|
||||||
case ' ': ret = 1; ke.key = Space; break;
|
case ' ': PRIVATE->ret = 1; ke.key = Space; break;
|
||||||
case '\t': ret = 1; ke.key = Tab; break;
|
case '\t': PRIVATE->ret = 1; ke.key = Tab; break;
|
||||||
case 112: ret = 1; ke.key = F1; break;
|
case 112: PRIVATE->ret = 1; ke.key = F1; break;
|
||||||
case 113: ret = 1; ke.key = F2; break;
|
case 113: PRIVATE->ret = 1; ke.key = F2; break;
|
||||||
case 114: ret = 1; ke.key = F3; break;
|
case 114: PRIVATE->ret = 1; ke.key = F3; break;
|
||||||
case 115: ret = 1; ke.key = F4; break;
|
case 115: PRIVATE->ret = 1; ke.key = F4; break;
|
||||||
case 116: ret = 1; ke.key = F5; break;
|
case 116: PRIVATE->ret = 1; ke.key = F5; break;
|
||||||
case 117: ret = 1; ke.key = F6; break;
|
case 117: PRIVATE->ret = 1; ke.key = F6; break;
|
||||||
case 118: ret = 1; ke.key = F7; break;
|
case 118: PRIVATE->ret = 1; ke.key = F7; break;
|
||||||
case 119: ret = 1; ke.key = F8; break;
|
case 119: PRIVATE->ret = 1; ke.key = F8; break;
|
||||||
case 120: ret = 1; ke.key = F9; break;
|
case 120: PRIVATE->ret = 1; ke.key = F9; break;
|
||||||
case 121: ret = 1; ke.key = F10; break;
|
case 121: PRIVATE->ret = 1; ke.key = F10; break;
|
||||||
case 122: ret = 1; ke.key = F11; break;
|
case 122: PRIVATE->ret = 1; ke.key = F11; break;
|
||||||
case 123: ret = 1; ke.key = F12; break;
|
case 123: PRIVATE->ret = 1; ke.key = F12; break;
|
||||||
default:
|
default:
|
||||||
ret = 1;
|
PRIVATE->ret = 1;
|
||||||
rc[0] = 1;
|
rc[0] = 1;
|
||||||
{
|
{
|
||||||
PIChar ch = PIChar::fromConsole(ker.uChar.AsciiChar);
|
PIChar ch = PIChar::fromConsole(ker.uChar.AsciiChar);
|
||||||
@@ -229,28 +235,28 @@ void PIKbdListener::readKeyboard() {
|
|||||||
} else {piMSleep(10); return;}
|
} else {piMSleep(10); return;}
|
||||||
} else {piMSleep(10); return;}
|
} else {piMSleep(10); return;}
|
||||||
/*if (lc == 0) {
|
/*if (lc == 0) {
|
||||||
ReadConsole(hIn, &rc, 1, &ret, 0);
|
ReadConsole(hIn, &rc, 1, &(PRIVATE->ret), 0);
|
||||||
//cout << "read console" << endl;
|
//cout << "read console" << endl;
|
||||||
lc = char(rc);
|
lc = char(rc);
|
||||||
}*/
|
}*/
|
||||||
/*if (ret < 0 || ret > 3) return;
|
/*if (PRIVATE->ret < 0 || PRIVATE->ret > 3) return;
|
||||||
lc = char(((uchar * )&rc)[ret - 1]);
|
lc = char(((uchar * )&rc)[PRIVATE->ret - 1]);
|
||||||
for (int i = 0; i < ret; ++i)
|
for (int i = 0; i < PRIVATE->ret; ++i)
|
||||||
cout << std::hex << int(((uchar * )&rc)[i]) << ' ';
|
cout << std::hex << int(((uchar * )&rc)[i]) << ' ';
|
||||||
cout << endl << std::hex << rc << endl;*/
|
cout << endl << std::hex << rc << endl;*/
|
||||||
#else
|
#else
|
||||||
tcsetattr(0, TCSANOW, &PRIVATE->tterm);
|
tcsetattr(0, TCSANOW, &PRIVATE->tterm);
|
||||||
ret = read(0, rc, 8);
|
PRIVATE->ret = read(0, rc, 8);
|
||||||
//piCout << "key" << PIString(rc).replaceAll("\e", "\\e");
|
//piCout << "key" << PIString(rc).replaceAll("\e", "\\e");
|
||||||
/*for (int i = 0; i < ret; ++i)
|
/*for (int i = 0; i < PRIVATE->ret; ++i)
|
||||||
cout << std::hex << int(((uchar * )&rc)[i]) << ' ';
|
cout << std::hex << int(((uchar * )&rc)[i]) << ' ';
|
||||||
cout << endl;
|
cout << endl;
|
||||||
for (int i = 0; i < ret; ++i)
|
for (int i = 0; i < PRIVATE->ret; ++i)
|
||||||
cout << "'" << (char)(rc[i]) << "' ";
|
cout << "'" << (char)(rc[i]) << "' ";
|
||||||
cout << endl;*/
|
cout << endl;*/
|
||||||
if (rc[0] == 0) {piMSleep(10); return;}
|
if (rc[0] == 0) {piMSleep(10); return;}
|
||||||
if (ret < 0 || ret > 7) {piMSleep(10); return;}
|
if (PRIVATE->ret < 0 || PRIVATE->ret > 7) {piMSleep(10); return;}
|
||||||
if (ret == 1) ke.key = PIChar::fromConsole(rc[0]).unicode16Code();
|
if (PRIVATE->ret == 1) ke.key = PIChar::fromConsole(rc[0]).unicode16Code();
|
||||||
int mod(0);
|
int mod(0);
|
||||||
// 2 - shift 1
|
// 2 - shift 1
|
||||||
// 3 - alt 2
|
// 3 - alt 2
|
||||||
@@ -258,14 +264,14 @@ void PIKbdListener::readKeyboard() {
|
|||||||
// 5 - ctrl 4
|
// 5 - ctrl 4
|
||||||
// 8 - ctrl+alt+shift 7
|
// 8 - ctrl+alt+shift 7
|
||||||
if (rc[0] == '\e') { // search for Alt
|
if (rc[0] == '\e') { // search for Alt
|
||||||
if (ret == 2) {
|
if (PRIVATE->ret == 2) {
|
||||||
mod = 2;
|
mod = 2;
|
||||||
ke.key = PIChar::fromConsole(rc[1]).unicode16Code();
|
ke.key = PIChar::fromConsole(rc[1]).unicode16Code();
|
||||||
} else {// escape-seq
|
} else {// escape-seq
|
||||||
if (rc[1] == '\e') { // search for Alt
|
if (rc[1] == '\e') { // search for Alt
|
||||||
for (int i = 1; i < 7; ++i) rc[i] = rc[i + 1];
|
for (int i = 1; i < 7; ++i) rc[i] = rc[i + 1];
|
||||||
mod = 2;
|
mod = 2;
|
||||||
ret--;
|
PRIVATE->ret--;
|
||||||
}
|
}
|
||||||
if (rc[1] == '[') {
|
if (rc[1] == '[') {
|
||||||
for (int i = 2; i < 7; ++i) // search for modifier
|
for (int i = 2; i < 7; ++i) // search for modifier
|
||||||
@@ -273,16 +279,16 @@ void PIKbdListener::readKeyboard() {
|
|||||||
mod |= rc[i + 1] - '0' - 1;
|
mod |= rc[i + 1] - '0' - 1;
|
||||||
for (int j = i; j < 6; ++j) rc[j] = rc[j + 2];
|
for (int j = i; j < 6; ++j) rc[j] = rc[j + 2];
|
||||||
rc[6] = rc[7] = 0;
|
rc[6] = rc[7] = 0;
|
||||||
ret -= 2;
|
PRIVATE->ret -= 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret >= 3 && rc[1] == 'O') { // search for modifier (F1-F4)
|
if (PRIVATE->ret >= 3 && rc[1] == 'O') { // search for modifier (F1-F4)
|
||||||
if (rc[2] >= '1' && rc[2] <= '8') {
|
if (rc[2] >= '1' && rc[2] <= '8') {
|
||||||
mod |= rc[2] - '0' - 1;
|
mod |= rc[2] - '0' - 1;
|
||||||
for (int j = 2; j < 6; ++j) rc[j] = rc[j + 1];
|
for (int j = 2; j < 6; ++j) rc[j] = rc[j + 1];
|
||||||
rc[7] = 0;
|
rc[7] = 0;
|
||||||
ret--;
|
PRIVATE->ret--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; ; ++i) {
|
for (int i = 0; ; ++i) {
|
||||||
@@ -302,20 +308,20 @@ void PIKbdListener::readKeyboard() {
|
|||||||
//if (mod & 0x8) ke.modifiers |= Meta;
|
//if (mod & 0x8) ke.modifiers |= Meta;
|
||||||
}
|
}
|
||||||
/*cout << "wo mods (" << mod << ")\n";
|
/*cout << "wo mods (" << mod << ")\n";
|
||||||
for (int i = 0; i < ret; ++i)
|
for (int i = 0; i < PRIVATE->ret; ++i)
|
||||||
cout << "'" << (char)(rc[i]) << "' ";
|
cout << "'" << (char)(rc[i]) << "' ";
|
||||||
cout << endl;*/
|
cout << endl;*/
|
||||||
}
|
}
|
||||||
if (ke.key == 0 && ret > 1)
|
if (ke.key == 0 && PRIVATE->ret > 1)
|
||||||
ke.key = PIChar(rc).unicode16Code();
|
ke.key = PIChar(rc).unicode16Code();
|
||||||
#endif
|
#endif
|
||||||
if ((rc[0] == '\n' || rc[0] == '\r') && ret == 1)
|
if ((rc[0] == '\n' || rc[0] == '\r') && PRIVATE->ret == 1)
|
||||||
ke.key = Return;
|
ke.key = Return;
|
||||||
if (exit_enabled && ke.key == exit_key) {
|
if (exit_enabled && ke.key == exit_key) {
|
||||||
PIKbdListener::exiting = true;
|
PIKbdListener::exiting = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ret > 0) {
|
if (PRIVATE->ret > 0) {
|
||||||
keyPressed(ke, kbddata_);
|
keyPressed(ke, kbddata_);
|
||||||
if (ret_func != 0) ret_func(ke, kbddata_);
|
if (ret_func != 0) ret_func(ke, kbddata_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,12 +176,6 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
PRIVATE_DECLARATION
|
PRIVATE_DECLARATION
|
||||||
#ifdef WINDOWS
|
|
||||||
DWORD
|
|
||||||
#else
|
|
||||||
int
|
|
||||||
#endif
|
|
||||||
ret;
|
|
||||||
KBFunc ret_func;
|
KBFunc ret_func;
|
||||||
int exit_key;
|
int exit_key;
|
||||||
bool exit_enabled, is_active;
|
bool exit_enabled, is_active;
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ void PIScreen::SystemConsole::print() {
|
|||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
#define FOREGROUND_MASK (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
|
#define FOREGROUND_MASK (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
|
||||||
#define BACKGROUND_MASK (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
|
#define BACKGROUND_MASK (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
|
||||||
WORD PIScreen::SystemConsole::attributes(const PIScreenTypes::Cell & c) {
|
ushort PIScreen::SystemConsole::attributes(const PIScreenTypes::Cell & c) {
|
||||||
WORD attr = PRIVATE->dattr;
|
WORD attr = PRIVATE->dattr;
|
||||||
if (c.format.flags & Bold) attr |= FOREGROUND_INTENSITY;
|
if (c.format.flags & Bold) attr |= FOREGROUND_INTENSITY;
|
||||||
else attr &= ~FOREGROUND_INTENSITY;
|
else attr &= ~FOREGROUND_INTENSITY;
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ private:
|
|||||||
void newLine();
|
void newLine();
|
||||||
void hideCursor();
|
void hideCursor();
|
||||||
void showCursor();
|
void showCursor();
|
||||||
WORD attributes(const PIScreenTypes::Cell & c);
|
ushort attributes(const PIScreenTypes::Cell & c);
|
||||||
#else
|
#else
|
||||||
void toUpperLeft() {printf("\e[H");}
|
void toUpperLeft() {printf("\e[H");}
|
||||||
void moveTo(int x = 0, int y = 0) {printf("\e[%d;%dH", y + 1, x + 1);}
|
void moveTo(int x = 0, int y = 0) {printf("\e[%d;%dH", y + 1, x + 1);}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <new>
|
||||||
#ifndef PIP_MEMALIGN_BYTES
|
#ifndef PIP_MEMALIGN_BYTES
|
||||||
# define PIP_MEMALIGN_BYTES (sizeof(void*)*4)
|
# define PIP_MEMALIGN_BYTES (sizeof(void*)*4)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -21,12 +21,12 @@
|
|||||||
#include "piconsole.h"
|
#include "piconsole.h"
|
||||||
#include "pibytearray.h"
|
#include "pibytearray.h"
|
||||||
#include "pistack.h"
|
#include "pistack.h"
|
||||||
|
#include "pistring_std.h"
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <wincon.h>
|
# include <wincon.h>
|
||||||
# define COMMON_LVB_UNDERSCORE 0x8000
|
# define COMMON_LVB_UNDERSCORE 0x8000
|
||||||
#endif
|
#endif
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
/*! \class PICout
|
/*! \class PICout
|
||||||
* \brief Class for formatted output similar std::cout
|
* \brief Class for formatted output similar std::cout
|
||||||
@@ -195,7 +195,7 @@ PICout PICout::operator <<(const PICoutAction v) {
|
|||||||
|
|
||||||
PICout PICout::operator <<(const char * v) {if (v[0] == '\0') return *this; space(); quote(); PICOUTTOTARGET(v) quote(); return *this;}
|
PICout PICout::operator <<(const char * v) {if (v[0] == '\0') return *this; space(); quote(); PICOUTTOTARGET(v) quote(); return *this;}
|
||||||
|
|
||||||
PICout PICout::operator <<(const std::string & v) {space(); quote(); PICOUTTOTARGET(v) quote(); return *this;}
|
PICout PICout::operator <<(const std::string & v) {space(); quote(); if (PICout::buffer_) __PICout_string__ << StdString2PIString(v); else std::cout << (v); quote(); return *this;}
|
||||||
|
|
||||||
PICout PICout::operator <<(const bool v) {space(); if (v) PICOUTTOTARGET("true") else PICOUTTOTARGET("false") return *this;}
|
PICout PICout::operator <<(const bool v) {space(); if (v) PICOUTTOTARGET("true") else PICOUTTOTARGET("false") return *this;}
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "piincludes.h"
|
#include "piincludes.h"
|
||||||
#ifdef WINDOWS
|
#include "piincludes_p.h"
|
||||||
# include <windef.h>
|
|
||||||
# include <winbase.h>
|
|
||||||
#endif
|
|
||||||
#include "piconsole.h"
|
#include "piconsole.h"
|
||||||
#include "pitime.h"
|
#include "pitime.h"
|
||||||
#ifndef QNX
|
#ifndef QNX
|
||||||
|
|||||||
@@ -18,14 +18,19 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef PIINCLUDES_P_H
|
#ifndef PIINCLUDES_P_H
|
||||||
#define PIINCLUDES_P_H
|
#define PIINCLUDES_P_H
|
||||||
|
|
||||||
|
|
||||||
#include "pibase.h"
|
#include "pibase.h"
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
# include <windef.h>
|
# include <windef.h>
|
||||||
# include <winbase.h>
|
# include <winbase.h>
|
||||||
|
typedef void(*PINtSetTimerResolution)(ULONG, BOOLEAN, PULONG);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CC_GCC
|
#ifdef CC_GCC
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
#endif // PIINCLUDES_P_H
|
#endif // PIINCLUDES_P_H
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ handler A: event to event
|
|||||||
|
|
||||||
|
|
||||||
PIVector<PIObject * > PIObject::objects;
|
PIVector<PIObject * > PIObject::objects;
|
||||||
PIMutex PIObject::__eh_mutex;
|
|
||||||
PIMap<PIString, PIObject::__EHData> PIObject::__eh_data;
|
PIMap<PIString, PIObject::__EHData> PIObject::__eh_data;
|
||||||
|
|
||||||
|
|
||||||
@@ -147,7 +146,7 @@ PIStringList PIObject::events() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
PIStringList PIObject::methodsEH() {
|
PIStringList PIObject::methodsEH() {
|
||||||
PIMutexLocker ml(__eh_mutex);
|
PIMutexLocker ml(__eh_mutex());
|
||||||
PIStringList ret;
|
PIStringList ret;
|
||||||
__EHData & ehd(__eh_data[className()]);
|
__EHData & ehd(__eh_data[className()]);
|
||||||
piForeachC (__EHPair & eh, ehd.eh_func)
|
piForeachC (__EHPair & eh, ehd.eh_func)
|
||||||
@@ -157,7 +156,7 @@ PIStringList PIObject::methodsEH() {
|
|||||||
|
|
||||||
|
|
||||||
bool PIObject::isMethodEHContains(const PIString & name) const {
|
bool PIObject::isMethodEHContains(const PIString & name) const {
|
||||||
PIMutexLocker ml(__eh_mutex);
|
PIMutexLocker ml(__eh_mutex());
|
||||||
__EHData & ehd(__eh_data[className()]);
|
__EHData & ehd(__eh_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)
|
||||||
@@ -167,7 +166,7 @@ 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(__eh_mutex());
|
||||||
__EHData & ehd(__eh_data[className()]);
|
__EHData & ehd(__eh_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)
|
||||||
@@ -177,7 +176,7 @@ 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(__eh_mutex());
|
||||||
__EHData & ehd(__eh_data[className()]);
|
__EHData & ehd(__eh_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)
|
||||||
@@ -202,7 +201,7 @@ 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(__eh_mutex());
|
||||||
return __eh_data[className()].eh_func.value(addr);
|
return __eh_data[className()].eh_func.value(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +232,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(__eh_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);
|
||||||
@@ -352,6 +351,12 @@ void PIObject::updateConnectors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIMutex & PIObject::__eh_mutex() {
|
||||||
|
static PIMutex ret;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PIString PIObject::simplifyType(const char * a) {
|
PIString PIObject::simplifyType(const char * a) {
|
||||||
PIString ret = PIStringAscii(a).trim();
|
PIString ret = PIStringAscii(a).trim();
|
||||||
int white = -1;
|
int white = -1;
|
||||||
|
|||||||
@@ -196,7 +196,7 @@
|
|||||||
__##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(__eh_mutex()); \
|
||||||
if (__eh_data.contains(__classNameS())) return; \
|
if (__eh_data.contains(__classNameS())) return; \
|
||||||
__eh_data[pn]; \
|
__eh_data[pn]; \
|
||||||
__eh_data[__classNameS()]; \
|
__eh_data[__classNameS()]; \
|
||||||
@@ -218,7 +218,7 @@
|
|||||||
class __##name##0_Initializer__ { \
|
class __##name##0_Initializer__ { \
|
||||||
public: \
|
public: \
|
||||||
__##name##0_Initializer__() { \
|
__##name##0_Initializer__() { \
|
||||||
PIMutexLocker ml(__eh_mutex); \
|
PIMutexLocker ml(__eh_mutex()); \
|
||||||
__EHData & eh(__eh_data[__classNameS()]); \
|
__EHData & eh(__eh_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; \
|
||||||
@@ -236,7 +236,7 @@
|
|||||||
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(__eh_mutex()); \
|
||||||
__EHData & eh(__eh_data[__classNameS()]); \
|
__EHData & eh(__eh_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; \
|
||||||
@@ -256,7 +256,7 @@
|
|||||||
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(__eh_mutex()); \
|
||||||
__EHData & eh(__eh_data[__classNameS()]); \
|
__EHData & eh(__eh_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; \
|
||||||
@@ -276,7 +276,7 @@
|
|||||||
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(__eh_mutex()); \
|
||||||
__EHData & eh(__eh_data[__classNameS()]); \
|
__EHData & eh(__eh_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; \
|
||||||
@@ -296,7 +296,7 @@
|
|||||||
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(__eh_mutex()); \
|
||||||
__EHData & eh(__eh_data[__classNameS()]); \
|
__EHData & eh(__eh_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; \
|
||||||
@@ -665,7 +665,7 @@ public:
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool isPIObject() const {return isPIObject(this);}
|
bool isPIObject() const {return isPIObject(this);}
|
||||||
bool execute(const PIString & method);
|
bool execute(const PIString & method);
|
||||||
@@ -675,6 +675,8 @@ public:
|
|||||||
static bool execute(void * o, const PIString & method) {return ((PIObject*)o)->execute(method);}
|
static bool execute(void * o, const PIString & method) {return ((PIObject*)o)->execute(method);}
|
||||||
static PIString simplifyType(const char * a);
|
static PIString simplifyType(const char * a);
|
||||||
|
|
||||||
|
static PIMutex & __eh_mutex();
|
||||||
|
|
||||||
struct __EHFunc {
|
struct __EHFunc {
|
||||||
__EHFunc(): addr(0) {;}
|
__EHFunc(): addr(0) {;}
|
||||||
bool isNull() const {return addr == 0;}
|
bool isNull() const {return addr == 0;}
|
||||||
@@ -693,7 +695,6 @@ public:
|
|||||||
};
|
};
|
||||||
typedef PIPair<const void * , __EHFunc> __EHPair;
|
typedef PIPair<const void * , __EHFunc> __EHPair;
|
||||||
static PIMap<PIString, __EHData> __eh_data;
|
static PIMap<PIString, __EHData> __eh_data;
|
||||||
static PIMutex __eh_mutex;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -356,32 +356,11 @@ PIString & PIString::operator +=(const wchar_t * str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAS_LOCALE
|
|
||||||
PIString & PIString::operator +=(const wstring & str) {
|
|
||||||
uint l = str.size();
|
|
||||||
for (uint i = 0; i < l; ++i) push_back(str[i]);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
PIString & PIString::operator +=(const PIString & str) {
|
PIString & PIString::operator +=(const PIString & str) {
|
||||||
//uint l = str.size();
|
|
||||||
*((PIDeque<PIChar>*)this) << *((PIDeque<PIChar>*)&str);
|
*((PIDeque<PIChar>*)this) << *((PIDeque<PIChar>*)&str);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
#ifdef WINDOWS
|
|
||||||
PIString & PIString::operator +=(const WCHAR * str) {
|
|
||||||
int l = 0;
|
|
||||||
while (str[l] != 0) ++l;
|
|
||||||
for (int i = 0; i < l; ++i)
|
|
||||||
push_back(str[i]);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool PIString::operator ==(const PIString & str) const {
|
bool PIString::operator ==(const PIString & str) const {
|
||||||
uint l = str.size();
|
uint l = str.size();
|
||||||
@@ -429,12 +408,6 @@ bool PIString::operator >(const PIString & str) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIString &PIString::operator +=(const std::string & str) {
|
|
||||||
appendFromChars(str.c_str(), str.length());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PIString PIString::mid(const int start, const int len) const {
|
PIString PIString::mid(const int start, const int len) const {
|
||||||
//PIString str;
|
//PIString str;
|
||||||
int s = start, l = len;
|
int s = start, l = len;
|
||||||
@@ -844,39 +817,6 @@ PIString PIString::toLowerCase() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string PIString::convertToStd() const {
|
|
||||||
std::string s;
|
|
||||||
uint wc;
|
|
||||||
uchar tc;
|
|
||||||
if (size() > 0) {
|
|
||||||
for (int i = 0; i < length(); ++i) {
|
|
||||||
wc = uint(at(i).unicode16Code());
|
|
||||||
while (tc = wc & 0xFF, tc) {
|
|
||||||
s.push_back(char(tc));
|
|
||||||
wc >>= 8;
|
|
||||||
}
|
|
||||||
/*if (at(i).isAscii())
|
|
||||||
s.push_back(at(i).toAscii());
|
|
||||||
else {
|
|
||||||
s.push_back(at(i).toCharPtr()[0]);
|
|
||||||
s.push_back(at(i).toCharPtr()[1]);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAS_LOCALE
|
|
||||||
std::wstring PIString::convertToWString() const {
|
|
||||||
std::wstring s;
|
|
||||||
for (int i = 0; i < length(); ++i)
|
|
||||||
s.push_back(at(i).toWChar());
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
char PIString::toChar() const {
|
char PIString::toChar() const {
|
||||||
PIString s(toNativeDecimalPoints());
|
PIString s(toNativeDecimalPoints());
|
||||||
char v;
|
char v;
|
||||||
@@ -884,6 +824,21 @@ char PIString::toChar() const {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float PIString::toFloat() const {
|
||||||
|
return (float)atof(toNativeDecimalPoints().data());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double PIString::toDouble() const {
|
||||||
|
return atof(toNativeDecimalPoints().data());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ldouble PIString::toLDouble() const {
|
||||||
|
return atof(toNativeDecimalPoints().data());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
short PIString::toShort() const {
|
short PIString::toShort() const {
|
||||||
PIString s(trimmed().toLowerCase().toNativeDecimalPoints());
|
PIString s(trimmed().toLowerCase().toNativeDecimalPoints());
|
||||||
@@ -1002,13 +957,3 @@ PIStringList& PIStringList::removeDuplicates() {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostream &operator <<(std::ostream & s, const PIStringList & v) {
|
|
||||||
s << "{";
|
|
||||||
for (uint i = 0; i < v.size(); ++i) {
|
|
||||||
s << "\"" << v[i] << "\"";
|
|
||||||
if (i < v.size() - 1) s << ", ";
|
|
||||||
}
|
|
||||||
s << "}";
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -27,10 +27,7 @@
|
|||||||
|
|
||||||
#include "pibytearray.h"
|
#include "pibytearray.h"
|
||||||
#define PIStringAscii PIString::fromAscii
|
#define PIStringAscii PIString::fromAscii
|
||||||
#include <string>
|
|
||||||
#ifdef QNX
|
|
||||||
typedef std::basic_string<wchar_t> wstring;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class PIStringList;
|
class PIStringList;
|
||||||
|
|
||||||
@@ -45,12 +42,8 @@ public:
|
|||||||
PIString & operator +=(const PIChar & c) {push_back(c); return *this;}
|
PIString & operator +=(const PIChar & c) {push_back(c); return *this;}
|
||||||
PIString & operator +=(const char * str);
|
PIString & operator +=(const char * str);
|
||||||
PIString & operator +=(const wchar_t * str);
|
PIString & operator +=(const wchar_t * str);
|
||||||
PIString & operator +=(const std::string & str);
|
|
||||||
PIString & operator +=(const PIByteArray & ba) {appendFromChars((const char * )ba.data(), ba.size_s()); return *this;}
|
PIString & operator +=(const PIByteArray & ba) {appendFromChars((const char * )ba.data(), ba.size_s()); return *this;}
|
||||||
PIString & operator +=(const PIString & str);
|
PIString & operator +=(const PIString & str);
|
||||||
#ifdef HAS_LOCALE
|
|
||||||
PIString & operator +=(const std::wstring & str);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//PIString(const char c) {*this += c;}
|
//PIString(const char c) {*this += c;}
|
||||||
PIString(const PIString & o): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this += o;}
|
PIString(const PIString & o): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this += o;}
|
||||||
@@ -70,13 +63,6 @@ public:
|
|||||||
* Example: \snippet pistring.cpp PIString(wchar_t * ) */
|
* Example: \snippet pistring.cpp PIString(wchar_t * ) */
|
||||||
PIString(const wchar_t * str): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this += str;}
|
PIString(const wchar_t * str): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this += str;}
|
||||||
|
|
||||||
//! Contructs string from std::string "str"
|
|
||||||
PIString(const std::string & str): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this += str;}
|
|
||||||
|
|
||||||
#ifdef HAS_LOCALE
|
|
||||||
PIString(const wstring & str): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this += str;}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//! Contructs string from byte array "ba"
|
//! Contructs string from byte array "ba"
|
||||||
PIString(const PIByteArray & ba): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this += ba;}
|
PIString(const PIByteArray & ba): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this += ba;}
|
||||||
|
|
||||||
@@ -94,13 +80,7 @@ public:
|
|||||||
/*! \brief Contructs string as sequence of symbols "c" of buffer with length "len"
|
/*! \brief Contructs string as sequence of symbols "c" of buffer with length "len"
|
||||||
* \details Example: \snippet pistring.cpp PIString(int, PIChar) */
|
* \details Example: \snippet pistring.cpp PIString(int, PIChar) */
|
||||||
PIString(const int len, const PIChar & c): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; for (int i = 0; i < len; ++i) push_back(c);}
|
PIString(const int len, const PIChar & c): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; for (int i = 0; i < len; ++i) push_back(c);}
|
||||||
/*
|
|
||||||
#ifdef WINDOWS
|
|
||||||
PIString(const WCHAR * str): PIDeque<PIChar>() {piMonitor.strings++; piMonitor.containers--; *this += str;}
|
|
||||||
PIString & operator +=(const WCHAR * str);
|
|
||||||
PIString & operator <<(const WCHAR * str) {*this += str; return *this;}
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
PIString(const short & value): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this = fromNumber(value);}
|
PIString(const short & value): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this = fromNumber(value);}
|
||||||
PIString(const ushort & value): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this = fromNumber(value);}
|
PIString(const ushort & value): PIDeque<PIChar>() {/*reserve(4); */piMonitor.strings++; piMonitor.containers--; *this = fromNumber(value);}
|
||||||
@@ -126,9 +106,6 @@ public:
|
|||||||
* Example: \snippet pistring.cpp PIString::char* */
|
* Example: \snippet pistring.cpp PIString::char* */
|
||||||
operator const char*() {return data();}
|
operator const char*() {return data();}
|
||||||
|
|
||||||
//! Return std::string representation of string
|
|
||||||
//operator const std::string() {if (size() == 0) return std::string(); std::string s; for (int i = 0; i < length(); ++i) s.push_back(at(i).toAscii()); return s;}
|
|
||||||
|
|
||||||
//! Return symbol at index "pos"
|
//! Return symbol at index "pos"
|
||||||
PIChar operator [](const int pos) const {return at(pos);}
|
PIChar operator [](const int pos) const {return at(pos);}
|
||||||
|
|
||||||
@@ -145,10 +122,6 @@ public:
|
|||||||
//! Compare operator
|
//! Compare operator
|
||||||
bool operator ==(const char * str) const {return *this == PIString(str);}
|
bool operator ==(const char * str) const {return *this == PIString(str);}
|
||||||
|
|
||||||
//! Compare operator
|
|
||||||
bool operator ==(const std::string & str) const {return *this == PIString(str);}
|
|
||||||
|
|
||||||
|
|
||||||
//! Compare operator
|
//! Compare operator
|
||||||
bool operator !=(const PIString & str) const;
|
bool operator !=(const PIString & str) const;
|
||||||
|
|
||||||
@@ -159,10 +132,6 @@ public:
|
|||||||
//! Compare operator
|
//! Compare operator
|
||||||
bool operator !=(const char * str) const {return *this != PIString(str);}
|
bool operator !=(const char * str) const {return *this != PIString(str);}
|
||||||
|
|
||||||
//! Compare operator
|
|
||||||
bool operator !=(const std::string & str) const {return *this != PIString(str);}
|
|
||||||
|
|
||||||
|
|
||||||
//! Compare operator
|
//! Compare operator
|
||||||
bool operator <(const PIString & str) const;
|
bool operator <(const PIString & str) const;
|
||||||
|
|
||||||
@@ -173,10 +142,6 @@ public:
|
|||||||
//! Compare operator
|
//! Compare operator
|
||||||
bool operator <(const char * str) const {return *this < PIString(str);}
|
bool operator <(const char * str) const {return *this < PIString(str);}
|
||||||
|
|
||||||
//! Compare operator
|
|
||||||
bool operator <(const std::string & str) const {return *this < PIString(str);}
|
|
||||||
|
|
||||||
|
|
||||||
//! Compare operator
|
//! Compare operator
|
||||||
bool operator >(const PIString & str) const;
|
bool operator >(const PIString & str) const;
|
||||||
|
|
||||||
@@ -187,10 +152,6 @@ public:
|
|||||||
//! Compare operator
|
//! Compare operator
|
||||||
bool operator >(const char * str) const {return *this > PIString(str);}
|
bool operator >(const char * str) const {return *this > PIString(str);}
|
||||||
|
|
||||||
//! Compare operator
|
|
||||||
bool operator >(const std::string & str) const {return *this > PIString(str);}
|
|
||||||
|
|
||||||
|
|
||||||
//! Compare operator
|
//! Compare operator
|
||||||
bool operator <=(const PIString & str) const {return !(*this > str);}
|
bool operator <=(const PIString & str) const {return !(*this > str);}
|
||||||
|
|
||||||
@@ -201,10 +162,6 @@ public:
|
|||||||
//! Compare operator
|
//! Compare operator
|
||||||
bool operator <=(const char * str) const {return *this <= PIString(str);}
|
bool operator <=(const char * str) const {return *this <= PIString(str);}
|
||||||
|
|
||||||
//! Compare operator
|
|
||||||
bool operator <=(const std::string & str) const {return *this <= PIString(str);}
|
|
||||||
|
|
||||||
|
|
||||||
//! Compare operator
|
//! Compare operator
|
||||||
bool operator >=(const PIString & str) const {return !(*this < str);}
|
bool operator >=(const PIString & str) const {return !(*this < str);}
|
||||||
|
|
||||||
@@ -215,9 +172,6 @@ public:
|
|||||||
//! Compare operator
|
//! Compare operator
|
||||||
bool operator >=(const char * str) const {return *this >= PIString(str);}
|
bool operator >=(const char * str) const {return *this >= PIString(str);}
|
||||||
|
|
||||||
//! Compare operator
|
|
||||||
bool operator >=(const std::string & str) const {return *this >= PIString(str);}
|
|
||||||
|
|
||||||
|
|
||||||
operator bool() const {return toBool();}
|
operator bool() const {return toBool();}
|
||||||
operator short() const {return toShort();}
|
operator short() const {return toShort();}
|
||||||
@@ -249,9 +203,6 @@ public:
|
|||||||
* \details Example: \snippet pistring.cpp PIString::<<(wchar_t * ) */
|
* \details Example: \snippet pistring.cpp PIString::<<(wchar_t * ) */
|
||||||
PIString & operator <<(const wchar_t * str) {*this += str; return *this;}
|
PIString & operator <<(const wchar_t * str) {*this += str; return *this;}
|
||||||
|
|
||||||
//! Append std::string "str" at the end of string
|
|
||||||
PIString & operator <<(const std::string & str) {*this += str; return *this;}
|
|
||||||
|
|
||||||
/*! \brief Append string representation of "num" at the end of string
|
/*! \brief Append string representation of "num" at the end of string
|
||||||
* \details Example: \snippet pistring.cpp PIString::<<(int) */
|
* \details Example: \snippet pistring.cpp PIString::<<(int) */
|
||||||
PIString & operator <<(const int & num) {*this += PIString::fromNumber(num); return *this;}
|
PIString & operator <<(const int & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
@@ -497,12 +448,6 @@ public:
|
|||||||
* execution of this function.\n */
|
* execution of this function.\n */
|
||||||
const char * dataAscii() const;
|
const char * dataAscii() const;
|
||||||
|
|
||||||
//! \brief Return \c std::string representation of this string
|
|
||||||
std::string stdString() const {return convertToStd();}
|
|
||||||
|
|
||||||
#ifdef HAS_LOCALE
|
|
||||||
wstring stdWString() const {return convertToWString();}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//! \brief Return \a PIByteArray contains \a data() of this string without terminating null-char
|
//! \brief Return \a PIByteArray contains \a data() of this string without terminating null-char
|
||||||
PIByteArray toByteArray() const {buildData(); return data_.resized(data_.size_s() - 1);}
|
PIByteArray toByteArray() const {buildData(); return data_.resized(data_.size_s() - 1);}
|
||||||
@@ -619,15 +564,15 @@ public:
|
|||||||
|
|
||||||
//! \brief Return \c float numeric value of string
|
//! \brief Return \c float numeric value of string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toFloat
|
//! \details Example: \snippet pistring.cpp PIString::toFloat
|
||||||
float toFloat() const {return (float)atof(toNativeDecimalPoints().data());}
|
float toFloat() const;
|
||||||
|
|
||||||
//! \brief Return \c double numeric value of string
|
//! \brief Return \c double numeric value of string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toFloat
|
//! \details Example: \snippet pistring.cpp PIString::toFloat
|
||||||
double toDouble() const {return atof(toNativeDecimalPoints().data());}
|
double toDouble() const;
|
||||||
|
|
||||||
//! \brief Return \c ldouble numeric value of string
|
//! \brief Return \c ldouble numeric value of string
|
||||||
//! \details Example: \snippet pistring.cpp PIString::toFloat
|
//! \details Example: \snippet pistring.cpp PIString::toFloat
|
||||||
ldouble toLDouble() const {return atof(toNativeDecimalPoints().data());}
|
ldouble toLDouble() const;
|
||||||
|
|
||||||
//inline PIString & setNumber(const char value) {clear(); *this += itos(value); return *this;}
|
//inline PIString & setNumber(const char value) {clear(); *this += itos(value); return *this;}
|
||||||
|
|
||||||
@@ -838,24 +783,10 @@ private:
|
|||||||
void appendFromChars(const char * c, int s, const char * cp = 0);
|
void appendFromChars(const char * c, int s, const char * cp = 0);
|
||||||
void buildData(const char * cp = 0) const;
|
void buildData(const char * cp = 0) const;
|
||||||
void trimsubstr(int &st, int &fn) const;
|
void trimsubstr(int &st, int &fn) const;
|
||||||
std::string convertToStd() const;
|
|
||||||
#ifdef HAS_LOCALE
|
|
||||||
std::wstring convertToWString() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mutable PIByteArray data_;
|
mutable PIByteArray data_;
|
||||||
//string std_string;
|
|
||||||
//wstring std_wstring;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//! \relatesalso PIString \brief Output operator to std::ostream (cout)
|
|
||||||
inline std::ostream & operator <<(std::ostream & s, const PIString & v) {for (int i = 0; i < v.length(); ++i) s << v[i]; return s;}
|
|
||||||
|
|
||||||
//! \relatesalso PIString \brief Input operator from std::istream (cin)
|
|
||||||
inline std::istream & operator >>(std::istream & s, PIString & v) {std::string ss; s >> ss; v << PIString(ss); return s;}
|
|
||||||
|
|
||||||
//! \relatesalso PIString \relatesalso PICout \brief Output operator to PICout
|
//! \relatesalso PIString \relatesalso PICout \brief Output operator to PICout
|
||||||
PICout operator <<(PICout s, const PIString & v);
|
PICout operator <<(PICout s, const PIString & v);
|
||||||
|
|
||||||
@@ -875,17 +806,11 @@ inline PIString operator +(const PIString & str, const PIString & f) {PIString s
|
|||||||
//! \relatesalso PIString \brief Return concatenated string
|
//! \relatesalso PIString \brief Return concatenated string
|
||||||
inline PIString operator +(const PIString & f, const char * str) {PIString s(f); s += str; return s;}
|
inline PIString operator +(const PIString & f, const char * str) {PIString s(f); s += str; return s;}
|
||||||
|
|
||||||
//! \relatesalso PIString \brief Return concatenated string
|
|
||||||
inline PIString operator +(const PIString & f, const std::string & str) {PIString s(f); s += str; return s;}
|
|
||||||
|
|
||||||
//inline PIString operator +(const char c, const PIString & f) {return PIString(c) + f;}
|
//inline PIString operator +(const char c, const PIString & f) {return PIString(c) + f;}
|
||||||
|
|
||||||
//! \relatesalso PIString \brief Return concatenated string
|
//! \relatesalso PIString \brief Return concatenated string
|
||||||
inline PIString operator +(const char * str, const PIString & f) {return PIString(str) + f;}
|
inline PIString operator +(const char * str, const PIString & f) {return PIString(str) + f;}
|
||||||
|
|
||||||
//! \relatesalso PIString \brief Return concatenated string
|
|
||||||
inline PIString operator +(const std::string & str, const PIString & f) {return PIString(str) + f;}
|
|
||||||
|
|
||||||
inline char chrUpr(char c);
|
inline char chrUpr(char c);
|
||||||
inline char chrLwr(char c);
|
inline char chrLwr(char c);
|
||||||
|
|
||||||
@@ -951,7 +876,6 @@ public:
|
|||||||
PIStringList & operator <<(const PIStringList & sl) {piForeachC (PIString & i, sl) push_back(i); return *this;}
|
PIStringList & operator <<(const PIStringList & sl) {piForeachC (PIString & i, sl) push_back(i); return *this;}
|
||||||
//inline PIStringList & operator <<(const char c) {push_back(PIString(c)); return *this;}
|
//inline PIStringList & operator <<(const char c) {push_back(PIString(c)); return *this;}
|
||||||
PIStringList & operator <<(const char * str) {push_back(PIString(str)); return *this;}
|
PIStringList & operator <<(const char * str) {push_back(PIString(str)); return *this;}
|
||||||
PIStringList & operator <<(const std::string & str) {push_back(str); return *this;}
|
|
||||||
PIStringList & operator <<(const int & num) {push_back(PIString::fromNumber(num)); return *this;}
|
PIStringList & operator <<(const int & num) {push_back(PIString::fromNumber(num)); return *this;}
|
||||||
PIStringList & operator <<(const short & num) {push_back(PIString::fromNumber(num)); return *this;}
|
PIStringList & operator <<(const short & num) {push_back(PIString::fromNumber(num)); return *this;}
|
||||||
PIStringList & operator <<(const long & num) {push_back(PIString::fromNumber(num)); return *this;}
|
PIStringList & operator <<(const long & num) {push_back(PIString::fromNumber(num)); return *this;}
|
||||||
@@ -967,10 +891,6 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIStringList & v) {s <<
|
|||||||
//! \relatesalso PIStringList \relatesalso PIByteArray \brief Input operator from PIByteArray
|
//! \relatesalso PIStringList \relatesalso PIByteArray \brief Input operator from PIByteArray
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIStringList & v) {int sz; s >> sz; v.resize(sz); for (int i = 0; i < sz; ++i) s >> v[i]; return s;}
|
inline PIByteArray & operator >>(PIByteArray & s, PIStringList & v) {int sz; s >> sz; v.resize(sz); for (int i = 0; i < sz; ++i) s >> v[i]; return s;}
|
||||||
|
|
||||||
|
|
||||||
//! \relatesalso PIStringList \brief Output operator to std::ostream (cout)
|
|
||||||
std::ostream & operator <<(std::ostream & s, const PIStringList & v);
|
|
||||||
|
|
||||||
//! \relatesalso PIStringList \relatesalso PICout \brief Output operator to PICout
|
//! \relatesalso PIStringList \relatesalso PICout \brief Output operator to PICout
|
||||||
inline PICout operator <<(PICout s, const PIStringList & v) {s.space(); s.setControl(0, true); s << "{"; for (uint i = 0; i < v.size(); ++i) {s << "\"" << v[i] << "\""; if (i < v.size() - 1) s << ", ";} s << "}"; s.restoreControl(); return s;}
|
inline PICout operator <<(PICout s, const PIStringList & v) {s.space(); s.setControl(0, true); s << "{"; for (uint i = 0; i < v.size(); ++i) {s << "\"" << v[i] << "\""; if (i < v.size() - 1) s << ", ";} s << "}"; s.restoreControl(); return s;}
|
||||||
|
|
||||||
|
|||||||
81
src/core/pistring_std.h
Normal file
81
src/core/pistring_std.h
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
#ifndef PISTRING2STD_H
|
||||||
|
#define PISTRING2STD_H
|
||||||
|
#include <string>
|
||||||
|
#ifdef QNX
|
||||||
|
typedef std::basic_string<wchar_t> wstring;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "pistring.h"
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string PIString2StdString(const PIString & v) {
|
||||||
|
std::string s;
|
||||||
|
uint wc;
|
||||||
|
uchar tc;
|
||||||
|
if (v.size() > 0) {
|
||||||
|
for (int i = 0; i < v.length(); ++i) {
|
||||||
|
wc = uint(v.at(i).unicode16Code());
|
||||||
|
while (tc = wc & 0xFF, tc) {
|
||||||
|
s.push_back(char(tc));
|
||||||
|
wc >>= 8;
|
||||||
|
}
|
||||||
|
/*if (at(i).isAscii())
|
||||||
|
s.push_back(at(i).toAscii());
|
||||||
|
else {
|
||||||
|
s.push_back(at(i).toCharPtr()[0]);
|
||||||
|
s.push_back(at(i).toCharPtr()[1]);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline PIString StdString2PIString(const std::string & v) {
|
||||||
|
return PIString(v.c_str(), v.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LOCALE
|
||||||
|
inline std::wstring PIString2StdWString(const PIString & v) {
|
||||||
|
std::wstring s;
|
||||||
|
for (int i = 0; i < v.length(); ++i)
|
||||||
|
s.push_back(v.at(i).toWChar());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline PIString StdWString2PIString(const std::wstring & v) {
|
||||||
|
PIString s;
|
||||||
|
uint l = v.size();
|
||||||
|
for (uint i = 0; i < l; ++i) s.push_back(v[i]);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//! \relatesalso PIString \brief Return concatenated string
|
||||||
|
inline PIString operator +(const PIString & f, const std::string & str) {PIString s(f); s += StdString2PIString(str); return s;}
|
||||||
|
|
||||||
|
//! \relatesalso PIString \brief Return concatenated string
|
||||||
|
inline PIString operator +(const std::string & str, const PIString & f) {return StdString2PIString(str) + f;}
|
||||||
|
|
||||||
|
|
||||||
|
//! \relatesalso PIString \brief Output operator to std::ostream (cout)
|
||||||
|
inline std::ostream & operator <<(std::ostream & s, const PIString & v) {for (int i = 0; i < v.length(); ++i) s << v[i]; return s;}
|
||||||
|
|
||||||
|
//! \relatesalso PIString \brief Input operator from std::istream (cin)
|
||||||
|
inline std::istream & operator >>(std::istream & s, PIString & v) {std::string ss; s >> ss; v = StdString2PIString(ss); return s;}
|
||||||
|
|
||||||
|
|
||||||
|
//! \relatesalso PIStringList \brief Output operator to std::ostream (cout)
|
||||||
|
inline std::ostream & operator <<(std::ostream & s, const PIStringList & v) {
|
||||||
|
s << PIChar("{");
|
||||||
|
for (uint i = 0; i < v.size(); ++i) {
|
||||||
|
s << PIChar("\"") << v[i] << PIChar("\"");
|
||||||
|
if (i < v.size() - 1) s << PIStringAscii(", ");
|
||||||
|
}
|
||||||
|
s << PIChar("}");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PISTRING2STD_H
|
||||||
@@ -205,15 +205,6 @@ PIDateTime PIDateTime::current() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef WINDOWS
|
|
||||||
PISystemTime::PISystemTime(const FILETIME & t) {
|
|
||||||
ullong lt = ullong(t.dwHighDateTime) * 0x100000000U + ullong(t.dwLowDateTime);
|
|
||||||
seconds = lt / 10000000U;
|
|
||||||
nanoseconds = (lt % 10000000U) * 100U;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
PISystemTime PISystemTime::abs() const {
|
PISystemTime PISystemTime::abs() const {
|
||||||
if (seconds < 0)
|
if (seconds < 0)
|
||||||
return PISystemTime(piAbsl(seconds) - 1, 1000000000l - piAbsl(nanoseconds));
|
return PISystemTime(piAbsl(seconds) - 1, 1000000000l - piAbsl(nanoseconds));
|
||||||
@@ -312,56 +303,6 @@ PIString PIDateTime::toString(const PIString & format) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef WINDOWS
|
|
||||||
PIDateTime::PIDateTime(SYSTEMTIME t) {
|
|
||||||
year = t.wYear;
|
|
||||||
month = t.wMonth;
|
|
||||||
day = t.wDay;
|
|
||||||
hours = t.wHour;
|
|
||||||
minutes = t.wMinute;
|
|
||||||
seconds = t.wSecond;
|
|
||||||
milliseconds = t.wMilliseconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PIDateTime::PIDateTime(FILETIME t) {
|
|
||||||
FILETIME lt;
|
|
||||||
SYSTEMTIME st;
|
|
||||||
FileTimeToLocalFileTime(&t, <);
|
|
||||||
FileTimeToSystemTime(<, &st);
|
|
||||||
year = st.wYear;
|
|
||||||
month = st.wMonth;
|
|
||||||
day = st.wDay;
|
|
||||||
hours = st.wHour;
|
|
||||||
minutes = st.wMinute;
|
|
||||||
seconds = st.wSecond;
|
|
||||||
milliseconds = st.wMilliseconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SYSTEMTIME PIDateTime::toSYSTEMTIME() const {
|
|
||||||
SYSTEMTIME st;
|
|
||||||
st.wYear = year;
|
|
||||||
st.wMonth = month;
|
|
||||||
st.wDay = day;
|
|
||||||
st.wHour = hours;
|
|
||||||
st.wMinute = minutes;
|
|
||||||
st.wSecond = seconds;
|
|
||||||
st.wMilliseconds = milliseconds;
|
|
||||||
return st;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FILETIME PIDateTime::toFILETIME() const {
|
|
||||||
FILETIME lt, ret;
|
|
||||||
SYSTEMTIME st = toSYSTEMTIME();
|
|
||||||
SystemTimeToFileTime(&st, <);
|
|
||||||
LocalFileTimeToFileTime(<, &ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
time_t PIDateTime::toSecondSinceEpoch() const {
|
time_t PIDateTime::toSecondSinceEpoch() const {
|
||||||
tm pt;
|
tm pt;
|
||||||
memset(&pt, 0, sizeof(pt));
|
memset(&pt, 0, sizeof(pt));
|
||||||
|
|||||||
@@ -22,11 +22,9 @@
|
|||||||
|
|
||||||
#ifndef PITIME_H
|
#ifndef PITIME_H
|
||||||
#define PITIME_H
|
#define PITIME_H
|
||||||
|
|
||||||
|
|
||||||
#include "pistring.h"
|
#include "pistring.h"
|
||||||
#ifdef WINDOWS
|
|
||||||
# include <minwindef.h>
|
|
||||||
typedef void(*PINtSetTimerResolution)(ULONG, BOOLEAN, PULONG);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//! \brief Sleep for "msecs" milliseconds
|
//! \brief Sleep for "msecs" milliseconds
|
||||||
@@ -63,10 +61,6 @@ public:
|
|||||||
//! Contructs system time from another
|
//! Contructs system time from another
|
||||||
PISystemTime(const PISystemTime & t) {seconds = t.seconds; nanoseconds = t.nanoseconds;}
|
PISystemTime(const PISystemTime & t) {seconds = t.seconds; nanoseconds = t.nanoseconds;}
|
||||||
|
|
||||||
#ifdef WINDOWS
|
|
||||||
PISystemTime(const FILETIME & t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//! Returns stored system time value in seconds
|
//! Returns stored system time value in seconds
|
||||||
double toSeconds() const {return double(seconds) + nanoseconds / 1.e+9;}
|
double toSeconds() const {return double(seconds) + nanoseconds / 1.e+9;}
|
||||||
|
|
||||||
@@ -239,25 +233,6 @@ struct PIP_EXPORT PIDateTime {
|
|||||||
PIDateTime(const PITime & time) {year = month = day = 0; hours = time.hours; minutes = time.minutes; seconds = time.seconds; milliseconds = time.milliseconds;}
|
PIDateTime(const PITime & time) {year = month = day = 0; hours = time.hours; minutes = time.minutes; seconds = time.seconds; milliseconds = time.milliseconds;}
|
||||||
PIDateTime(const PIDate & date) {year = date.year; month = date.month; day = date.day; hours = minutes = seconds = milliseconds = 0;}
|
PIDateTime(const PIDate & date) {year = date.year; month = date.month; day = date.day; hours = minutes = seconds = milliseconds = 0;}
|
||||||
PIDateTime(const PIDate & date, const PITime & time) {year = date.year; month = date.month; day = date.day; hours = time.hours; minutes = time.minutes; seconds = time.seconds; milliseconds = time.milliseconds;}
|
PIDateTime(const PIDate & date, const PITime & time) {year = date.year; month = date.month; day = date.day; hours = time.hours; minutes = time.minutes; seconds = time.seconds; milliseconds = time.milliseconds;}
|
||||||
#ifdef WINDOWS
|
|
||||||
#ifndef _SYSTEMTIME_
|
|
||||||
#define _SYSTEMTIME_
|
|
||||||
typedef struct _SYSTEMTIME {
|
|
||||||
WORD wYear;
|
|
||||||
WORD wMonth;
|
|
||||||
WORD wDayOfWeek;
|
|
||||||
WORD wDay;
|
|
||||||
WORD wHour;
|
|
||||||
WORD wMinute;
|
|
||||||
WORD wSecond;
|
|
||||||
WORD wMilliseconds;
|
|
||||||
} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
|
|
||||||
#endif
|
|
||||||
PIDateTime(SYSTEMTIME t);
|
|
||||||
PIDateTime(FILETIME t);
|
|
||||||
SYSTEMTIME toSYSTEMTIME() const;
|
|
||||||
FILETIME toFILETIME() const;
|
|
||||||
#endif
|
|
||||||
int year;
|
int year;
|
||||||
int month;
|
int month;
|
||||||
int day;
|
int day;
|
||||||
@@ -298,17 +273,6 @@ PICout operator <<(PICout s, const PIDateTime & v);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
DEPRECATED inline PITime currentTime() {return PITime::current();} // obsolete, use PITime::current() instead
|
|
||||||
DEPRECATED inline PIDate currentDate() {return PIDate::current();} // obsolete, use PIDate::current() instead
|
|
||||||
DEPRECATED inline PIDateTime currentDateTime() {return PIDateTime::current();} // obsolete, use PIDateTime::current() instead
|
|
||||||
|
|
||||||
//! \brief Returns current system time \deprecated Use \a PISystemTime::current() instead
|
|
||||||
DEPRECATED inline PISystemTime currentSystemTime() {return PISystemTime::current();} // obsolete, use PISystemTime::current() instead
|
|
||||||
DEPRECATED PIP_EXPORT PIString time2string(const PITime & time, const PIString & format = "h:mm:ss"); // obsolete, use PITime.toString() instead
|
|
||||||
DEPRECATED PIP_EXPORT PIString date2string(const PIDate & date, const PIString & format = "d.MM.yyyy"); // obsolete, use PITime.toString() instead
|
|
||||||
DEPRECATED PIP_EXPORT PIString datetime2string(const PIDateTime & datetime, const PIString & format = "h:mm:ss d.MM.yyyy"); // obsolete, use PIDateTime.toString() instead
|
|
||||||
|
|
||||||
|
|
||||||
class PITimeMeasurer {
|
class PITimeMeasurer {
|
||||||
public:
|
public:
|
||||||
PITimeMeasurer();
|
PITimeMeasurer();
|
||||||
|
|||||||
69
src/core/pitime_win.h
Normal file
69
src/core/pitime_win.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#ifndef PITIME_WIN_H
|
||||||
|
#define PITIME_WIN_H
|
||||||
|
|
||||||
|
#include "pibase.h"
|
||||||
|
#ifdef WINDOWS
|
||||||
|
|
||||||
|
#include "pitime.h"
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
//inline PISystemTime SYSTEMTIME2PISystemTime(SYSTEMTIME &t) {
|
||||||
|
// PISystemTime st;
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
inline PISystemTime FILETIME2PISystemTime(const FILETIME &t) {
|
||||||
|
PISystemTime st;
|
||||||
|
ullong lt = ullong(t.dwHighDateTime) * 0x100000000U + ullong(t.dwLowDateTime);
|
||||||
|
st.seconds = lt / 10000000U;
|
||||||
|
st.nanoseconds = (lt % 10000000U) * 100U;
|
||||||
|
return st;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline PIDateTime SYSTEMTIME2PIDateTime(const SYSTEMTIME &t) {
|
||||||
|
PIDateTime dt;
|
||||||
|
dt.year = t.wYear;
|
||||||
|
dt.month = t.wMonth;
|
||||||
|
dt.day = t.wDay;
|
||||||
|
dt.hours = t.wHour;
|
||||||
|
dt.minutes = t.wMinute;
|
||||||
|
dt.seconds = t.wSecond;
|
||||||
|
dt.milliseconds = t.wMilliseconds;
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline PIDateTime FILETIME2PIDateTime(const FILETIME &t) {
|
||||||
|
FILETIME lt;
|
||||||
|
SYSTEMTIME st;
|
||||||
|
FileTimeToLocalFileTime(&t, <);
|
||||||
|
FileTimeToSystemTime(<, &st);
|
||||||
|
return SYSTEMTIME2PIDateTime(st);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SYSTEMTIME PIDateTime2SYSTEMTIME(const PIDateTime &dt) {
|
||||||
|
SYSTEMTIME st;
|
||||||
|
st.wYear = dt.year;
|
||||||
|
st.wMonth = dt.month;
|
||||||
|
st.wDay = dt.day;
|
||||||
|
st.wHour = dt.hours;
|
||||||
|
st.wMinute = dt.minutes;
|
||||||
|
st.wSecond = dt.seconds;
|
||||||
|
st.wMilliseconds = dt.milliseconds;
|
||||||
|
return st;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline FILETIME PIDateTime2FILETIME(const PIDateTime &dt) {
|
||||||
|
FILETIME lt, ret;
|
||||||
|
SYSTEMTIME st = PIDateTime2SYSTEMTIME(dt);
|
||||||
|
SystemTimeToFileTime(&st, <);
|
||||||
|
LocalFileTimeToFileTime(<, &ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // WINDOWS
|
||||||
|
#endif // PITIME_WIN_H
|
||||||
@@ -17,10 +17,11 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include "piconfig.h"
|
#include "piconfig.h"
|
||||||
#include "pifile.h"
|
#include "pifile.h"
|
||||||
#include "piiostring.h"
|
#include "piiostring.h"
|
||||||
#include <iostream>
|
#include "pistring_std.h"
|
||||||
|
|
||||||
/*! \class PIConfig
|
/*! \class PIConfig
|
||||||
* \brief Configuration file
|
* \brief Configuration file
|
||||||
@@ -812,3 +813,15 @@ void PIConfig::parse() {
|
|||||||
setEntryDelim(&root, delim);
|
setEntryDelim(&root, delim);
|
||||||
buildFullNames(&root);
|
buildFullNames(&root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream &operator <<(std::ostream & s, const PIConfig::Entry & v) {
|
||||||
|
s << v.value();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream &operator <<(std::ostream & s, const PIConfig::Branch & v) {
|
||||||
|
v.coutt(s, "");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|||||||
@@ -500,8 +500,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline std::ostream & operator <<(std::ostream & s, const PIConfig::Branch & v) {v.coutt(s, ""); return s;}
|
std::ostream & operator <<(std::ostream & s, const PIConfig::Branch & v);
|
||||||
inline std::ostream & operator <<(std::ostream & s, const PIConfig::Entry & v) {s << v.value(); return s;}
|
std::ostream & operator <<(std::ostream & s, const PIConfig::Entry & v);
|
||||||
inline PICout operator <<(PICout s, const PIConfig::Branch & v) {s.setControl(0, true); v.piCoutt(s, ""); s.restoreControl(); return s;}
|
inline PICout operator <<(PICout s, const PIConfig::Branch & v) {s.setControl(0, true); v.piCoutt(s, ""); s.restoreControl(); return s;}
|
||||||
inline PICout operator <<(PICout s, const PIConfig::Entry & v) {s << v.value(); return s;}
|
inline PICout operator <<(PICout s, const PIConfig::Entry & v) {s << v.value(); return s;}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "piincludes_p.h"
|
#include "piincludes_p.h"
|
||||||
#include "pifile.h"
|
#include "pifile.h"
|
||||||
#include "pidir.h"
|
#include "pidir.h"
|
||||||
|
#include "pitime_win.h"
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
# undef S_IFDIR
|
# undef S_IFDIR
|
||||||
# undef S_IFREG
|
# undef S_IFREG
|
||||||
@@ -378,15 +379,6 @@ int PIFile::writeDevice(const void * data, int max_size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIFile & PIFile::writeToBinLog(ushort id, const void * data, int size) { /// DEPRECATED
|
|
||||||
if (!isWriteable() || fd == 0) return *this;
|
|
||||||
writeBinary(id).writeBinary((ushort)size);
|
|
||||||
write(data, size);
|
|
||||||
flush();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PIFile &PIFile::operator <<(const PIString & v) {
|
PIFile &PIFile::operator <<(const PIString & v) {
|
||||||
if (canWrite() && fd != 0)
|
if (canWrite() && fd != 0)
|
||||||
*this << v.toCharset(defaultCharset());
|
*this << v.toCharset(defaultCharset());
|
||||||
@@ -454,8 +446,8 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) {
|
|||||||
ret.perm_user = FileInfo::Permissions(true, (attr & FILE_ATTRIBUTE_READONLY) != FILE_ATTRIBUTE_READONLY, ext == "bat" || ext == "exe");
|
ret.perm_user = FileInfo::Permissions(true, (attr & FILE_ATTRIBUTE_READONLY) != FILE_ATTRIBUTE_READONLY, ext == "bat" || ext == "exe");
|
||||||
ret.perm_group = ret.perm_other = ret.perm_user;
|
ret.perm_group = ret.perm_other = ret.perm_user;
|
||||||
ret.size = filesize.QuadPart;
|
ret.size = filesize.QuadPart;
|
||||||
ret.time_access = PIDateTime(fi.ftLastAccessTime);
|
ret.time_access = FILETIME2PIDateTime(fi.ftLastAccessTime);
|
||||||
ret.time_modification = PIDateTime(fi.ftLastWriteTime);
|
ret.time_modification = FILETIME2PIDateTime(fi.ftLastWriteTime);
|
||||||
/*PIByteArray sec;
|
/*PIByteArray sec;
|
||||||
DWORD sec_n(0);
|
DWORD sec_n(0);
|
||||||
//SECURITY_DESCRIPTOR sec;
|
//SECURITY_DESCRIPTOR sec;
|
||||||
@@ -539,7 +531,7 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
|
|||||||
hFile = CreateFile(path.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
hFile = CreateFile(path.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
||||||
}
|
}
|
||||||
if (!hFile) return false;
|
if (!hFile) return false;
|
||||||
FILETIME atime = info.time_access.toFILETIME(), mtime = info.time_modification.toFILETIME();
|
FILETIME atime = PIDateTime2FILETIME(info.time_access), mtime = PIDateTime2FILETIME(info.time_modification);
|
||||||
if (SetFileTime(hFile, 0, &atime, &mtime) == 0) {
|
if (SetFileTime(hFile, 0, &atime, &mtime) == 0) {
|
||||||
piCout << "[PIFile] applyFileInfo: \"SetFileTime\" error:" << errorString();
|
piCout << "[PIFile] applyFileInfo: \"SetFileTime\" error:" << errorString();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -152,9 +152,6 @@ public:
|
|||||||
void setPrecision(int prec);
|
void setPrecision(int prec);
|
||||||
|
|
||||||
|
|
||||||
PIFile & writeToBinLog(ushort id, const void * data, int size); /// DEPRECATED
|
|
||||||
|
|
||||||
|
|
||||||
//! Write to file binary content of "v"
|
//! Write to file binary content of "v"
|
||||||
PIFile & writeBinary(const char v) {write(&v, sizeof(v)); return *this;}
|
PIFile & writeBinary(const char v) {write(&v, sizeof(v)); return *this;}
|
||||||
//! Write to file binary content of "v"
|
//! Write to file binary content of "v"
|
||||||
|
|||||||
@@ -66,21 +66,6 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name_, void * r
|
|||||||
|
|
||||||
|
|
||||||
PIProtocol::~PIProtocol() {
|
PIProtocol::~PIProtocol() {
|
||||||
//cout << "prot " << protName << " delete\n";
|
|
||||||
if (history_write_rec) {
|
|
||||||
if (history_file_rec.isEmpty()) {
|
|
||||||
history_file_rec.close();
|
|
||||||
history_file_rec.remove();
|
|
||||||
}
|
|
||||||
history_file_rec.close();
|
|
||||||
}
|
|
||||||
if (history_write_send) {
|
|
||||||
if (history_file_send.isEmpty()) {
|
|
||||||
history_file_send.close();
|
|
||||||
history_file_send.remove();
|
|
||||||
}
|
|
||||||
history_file_send.close();
|
|
||||||
}
|
|
||||||
delete diagTimer;
|
delete diagTimer;
|
||||||
delete sendTimer;
|
delete sendTimer;
|
||||||
delete secTimer;
|
delete secTimer;
|
||||||
@@ -96,7 +81,7 @@ void PIProtocol::init() {
|
|||||||
packet_ext->setThreadedReadSlot(receiveEvent);
|
packet_ext->setThreadedReadSlot(receiveEvent);
|
||||||
packet_ext->setHeaderCheckSlot(headerValidateEvent);
|
packet_ext->setHeaderCheckSlot(headerValidateEvent);
|
||||||
packet_ext->setName("__S__PIProtocol::packet_ext");
|
packet_ext->setName("__S__PIProtocol::packet_ext");
|
||||||
work = new_mp_prot = history_write_rec = history_write_send = false;
|
work = new_mp_prot = false;
|
||||||
eth = 0;
|
eth = 0;
|
||||||
ser = 0;
|
ser = 0;
|
||||||
ret_func = 0;
|
ret_func = 0;
|
||||||
@@ -120,9 +105,6 @@ void PIProtocol::init() {
|
|||||||
type_rec = type_send = PIProtocol::None;
|
type_rec = type_send = PIProtocol::None;
|
||||||
devSenderState = devReceiverState = "Unknown";
|
devSenderState = devReceiverState = "Unknown";
|
||||||
devSenderName = devReceiverName = "no device";
|
devSenderName = devReceiverName = "no device";
|
||||||
history_rsize_rec = history_rsize_send = "no file";
|
|
||||||
history_file_rec.setName("__S__PIProtocol::history_file_rec");
|
|
||||||
history_file_send.setName("__S__PIProtocol::history_file_send");
|
|
||||||
secTimer->start(1000.);
|
secTimer->start(1000.);
|
||||||
/*addEvent("receiver started");
|
/*addEvent("receiver started");
|
||||||
addEvent("receiver stopped");
|
addEvent("receiver stopped");
|
||||||
@@ -265,27 +247,6 @@ void PIProtocol::init_sender(PIConfig::Entry & b, PIConfig::Entry & sb, const PI
|
|||||||
if (sendDataSize_ == 0)
|
if (sendDataSize_ == 0)
|
||||||
piCoutObj << "Warning: null send data size!";*/
|
piCoutObj << "Warning: null send data size!";*/
|
||||||
}
|
}
|
||||||
history_write_send = sb.getValue("writeHistory", false, &ok);
|
|
||||||
bool ghist = b.getValue("writeHistory", false, &gok);
|
|
||||||
if (ok || gok) {
|
|
||||||
if (gok && !ok) history_write_send = ghist;
|
|
||||||
if (gok && ok && (history_write_send != ghist)) {
|
|
||||||
piCoutObj << "Ambiguous sender history in \"" << config << "\"!";
|
|
||||||
devSenderState = "Config error";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (history_write_send) {
|
|
||||||
history_path_send = sb.getValue("historyFile", "./history_" + protName + "_send_" +
|
|
||||||
PIDate::current().toString("__dd_mm_yyyy_") +
|
|
||||||
PITime::current().toString("_hh_mm_ss_")).value();
|
|
||||||
history_id_send = sb.getValue("historyID", 0, &ok);
|
|
||||||
if (!ok) {
|
|
||||||
history_id_send = ushort(protName.toByteArray().checksumPlain32()) + 1;
|
|
||||||
piCoutObj << "Warning: no sender history ID defined, write with ID = " << history_id_send;
|
|
||||||
}
|
|
||||||
history_file_send.open(history_path_send, PIIODevice::WriteOnly);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
freq = sb.getValue("frequency", -1.f, &ok);
|
freq = sb.getValue("frequency", -1.f, &ok);
|
||||||
gfreq = b.getValue("frequency", -1.f, &gok);
|
gfreq = b.getValue("frequency", -1.f, &gok);
|
||||||
if (gok && !ok) freq = gfreq;
|
if (gok && !ok) freq = gfreq;
|
||||||
@@ -440,27 +401,6 @@ void PIProtocol::init_receiver(PIConfig::Entry & b, PIConfig::Entry & rb, const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
history_write_rec = rb.getValue("writeHistory", false, &ok);
|
|
||||||
bool ghist = b.getValue("writeHistory", false, &gok);
|
|
||||||
if (ok || gok) {
|
|
||||||
if (gok && !ok) history_write_rec = ghist;
|
|
||||||
if (gok && ok && (history_write_rec != ghist)) {
|
|
||||||
piCoutObj << "Ambiguous receiver history in \"" << config << "\"!";
|
|
||||||
devReceiverState = "Config error";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (history_write_rec) {
|
|
||||||
history_path_rec = rb.getValue("historyFile", "./history_" + protName + "_rec_" +
|
|
||||||
PIDate::current().toString("__dd_mm_yyyy_") +
|
|
||||||
PITime::current().toString("_hh_mm_ss_")).value();
|
|
||||||
history_id_rec = rb.getValue("historyID", 0, &ok);
|
|
||||||
if (!ok) {
|
|
||||||
history_id_rec = ushort(protName.toByteArray().checksumPlain32());
|
|
||||||
piCoutObj << "Warning: no receiver history ID defined, write with ID = " << history_id_rec;
|
|
||||||
}
|
|
||||||
history_file_rec.open(history_path_rec, PIIODevice::WriteOnly);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
freq = rb.getValue("frequency", -1.f, &ok);
|
freq = rb.getValue("frequency", -1.f, &ok);
|
||||||
gfreq = b.getValue("frequency", -1.f, &gok);
|
gfreq = b.getValue("frequency", -1.f, &gok);
|
||||||
if (gok && !ok) freq = gfreq;
|
if (gok && !ok) freq = gfreq;
|
||||||
@@ -625,10 +565,6 @@ bool PIProtocol::receiveEvent(void * t, uchar * data, int size) {
|
|||||||
p->work = true;
|
p->work = true;
|
||||||
//p->lock();
|
//p->lock();
|
||||||
if (p->validate()) {
|
if (p->validate()) {
|
||||||
if (p->history_write_rec) {
|
|
||||||
p->history_file_rec.writeToBinLog(p->history_id_rec, data, size);
|
|
||||||
p->history_rsize_rec.setReadableSize(p->history_file_rec.pos());
|
|
||||||
}
|
|
||||||
p->received(true);
|
p->received(true);
|
||||||
//p->unlock();
|
//p->unlock();
|
||||||
p->ifreq = p->diag_tm.elapsed_m();
|
p->ifreq = p->diag_tm.elapsed_m();
|
||||||
@@ -747,10 +683,6 @@ void PIProtocol::send(const void * data, int size, bool direct) {
|
|||||||
if (data == 0 || size == 0) return;
|
if (data == 0 || size == 0) return;
|
||||||
if (!aboutSend()) return;
|
if (!aboutSend()) return;
|
||||||
}
|
}
|
||||||
if (history_write_send) {
|
|
||||||
history_file_send.writeToBinLog(history_id_send, data, size);
|
|
||||||
history_rsize_send.setReadableSize(history_file_send.pos());
|
|
||||||
}
|
|
||||||
if (type_send == PIProtocol::Serial)
|
if (type_send == PIProtocol::Serial)
|
||||||
if (ser->send(data, size)) {
|
if (ser->send(data, size)) {
|
||||||
send_count++;
|
send_count++;
|
||||||
@@ -772,10 +704,6 @@ void PIProtocol::send() {
|
|||||||
//unlock();
|
//unlock();
|
||||||
if (!aboutSend()) return;
|
if (!aboutSend()) return;
|
||||||
if (sendDataPtr == 0 || sendDataSize == 0) return;
|
if (sendDataPtr == 0 || sendDataSize == 0) return;
|
||||||
if (history_write_send) {
|
|
||||||
history_file_send.writeToBinLog(history_id_send, sendDataPtr, sendDataSize);
|
|
||||||
history_rsize_send.setReadableSize(history_file_send.pos());
|
|
||||||
}
|
|
||||||
if (type_send == PIProtocol::Serial)
|
if (type_send == PIProtocol::Serial)
|
||||||
if (ser->send(sendDataPtr, sendDataSize)) {
|
if (ser->send(sendDataPtr, sendDataSize)) {
|
||||||
send_count++;
|
send_count++;
|
||||||
|
|||||||
@@ -162,14 +162,6 @@ public:
|
|||||||
const PIString * receiveSpeed_ptr() const {return &speedIn;}
|
const PIString * receiveSpeed_ptr() const {return &speedIn;}
|
||||||
PIString sendSpeed() const {return speedOut;}
|
PIString sendSpeed() const {return speedOut;}
|
||||||
const PIString * sendSpeed_ptr() const {return &speedOut;}
|
const PIString * sendSpeed_ptr() const {return &speedOut;}
|
||||||
PIString receiverHistorySize() const {return history_rsize_rec;}
|
|
||||||
const PIString * receiverHistorySize_ptr() const {return &history_rsize_rec;}
|
|
||||||
PIString senderHistorySize() const {return history_rsize_send;}
|
|
||||||
const PIString * senderHistorySize_ptr() const {return &history_rsize_send;}
|
|
||||||
bool writeReceiverHistory() const {return history_write_rec;}
|
|
||||||
const bool * writeReceiverHistory_ptr() const {return &history_write_rec;}
|
|
||||||
bool writeSenderHistory() const {return history_write_send;}
|
|
||||||
const bool * writeSenderHistory_ptr() const {return &history_write_send;}
|
|
||||||
|
|
||||||
void * receiveData() {return dataPtr;}
|
void * receiveData() {return dataPtr;}
|
||||||
void * sendData() {return sendDataPtr;}
|
void * sendData() {return sendDataPtr;}
|
||||||
@@ -235,10 +227,7 @@ private:
|
|||||||
PIDeque<float> last_freq;
|
PIDeque<float> last_freq;
|
||||||
PIDeque<char> last_packets;
|
PIDeque<char> last_packets;
|
||||||
PIString protName, devReceiverName, devReceiverState, devSenderName, devSenderState, speedIn, speedOut;
|
PIString protName, devReceiverName, devReceiverState, devSenderName, devSenderState, speedIn, speedOut;
|
||||||
PIString history_path_rec, history_path_send, history_rsize_rec, history_rsize_send;
|
bool work, new_mp_prot;
|
||||||
PIFile history_file_rec, history_file_send;
|
|
||||||
ushort history_id_rec, history_id_send;
|
|
||||||
bool work, new_mp_prot, history_write_rec, history_write_send;
|
|
||||||
float exp_freq, send_freq, ifreq, immediate_freq, integral_freq, timeout_;
|
float exp_freq, send_freq, ifreq, immediate_freq, integral_freq, timeout_;
|
||||||
int packets[2], pckt_cnt, pckt_cnt_max;
|
int packets[2], pckt_cnt, pckt_cnt_max;
|
||||||
char cur_pckt;
|
char cur_pckt;
|
||||||
|
|||||||
@@ -36,96 +36,76 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/// with align
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class PIFFTW_Private
|
class PIFFTW_Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PIFFTW_Private() {
|
explicit PIFFTW_Private() {
|
||||||
plan = 0;
|
plan = 0;
|
||||||
p_in = p_out = 0;
|
#ifndef PIP_FFTW
|
||||||
p_inr = 0;
|
|
||||||
#ifdef PIP_FFTW
|
|
||||||
// fftwf_m
|
|
||||||
#else
|
|
||||||
piCout << "[PIFFTW]" << "Warning: PIFFTW is disabled, to enable install libfftw3-dev library and build pip with -DFFTW=1";
|
piCout << "[PIFFTW]" << "Warning: PIFFTW is disabled, to enable install libfftw3-dev library and build pip with -DFFTW=1";
|
||||||
#endif
|
#endif
|
||||||
p_makeThreadSafe();
|
p_makeThreadSafe();
|
||||||
}
|
}
|
||||||
~PIFFTW_Private() {
|
~PIFFTW_Private() {p_destroyPlan(plan);}
|
||||||
p_destroyPlan(plan);
|
|
||||||
delVec(p_in);
|
|
||||||
delVec(p_out);
|
|
||||||
delVec(p_inr);
|
|
||||||
}
|
|
||||||
|
|
||||||
const PIVector<complex<T> > & calcFFT(const PIVector<complex<T> > & in) {
|
const PIVector<complex<T> > & calcFFT(const PIVector<complex<T> > & in) {
|
||||||
if (prepare != PlanParams(in.size(), fo_complex)) {
|
if (prepare != PlanParams(in.size(), fo_complex)) {
|
||||||
newVec(p_in, in.size());
|
p_out.resize(in.size());
|
||||||
newVec(p_out, in.size());
|
|
||||||
piCout << "[PIFFTW]" << "creating plan";
|
piCout << "[PIFFTW]" << "creating plan";
|
||||||
p_createPlan_c2c_1d(plan, in.size(), p_in, p_out, FFTW_FORWARD, FFTW_ESTIMATE);
|
p_createPlan_c2c_1d(plan, in.size(), in.data(), p_out.data(), FFTW_FORWARD, FFTW_ESTIMATE | FFTW_UNALIGNED);
|
||||||
v_out.resize(in.size());
|
|
||||||
prepare = PlanParams(in.size(), fo_complex);
|
prepare = PlanParams(in.size(), fo_complex);
|
||||||
}
|
}
|
||||||
memcpy(p_in, in.data(), sizeof(complex<T>) * in.size());
|
p_executePlan_c2c(plan, in.data(), p_out.data());
|
||||||
p_executePlan(plan);
|
return p_out;
|
||||||
memcpy(v_out.data(), p_out, sizeof(complex<T>) * v_out.size());
|
|
||||||
return v_out;
|
|
||||||
}
|
}
|
||||||
const PIVector<complex<T> > & calcFFT(const PIVector<T> & in) {
|
const PIVector<complex<T> > & calcFFT(const PIVector<T> & in) {
|
||||||
if (prepare != PlanParams(in.size(), fo_real)) {
|
if (prepare != PlanParams(in.size(), fo_real)) {
|
||||||
newVec(p_inr, in.size());
|
p_out.resize(in.size());
|
||||||
newVec(p_out, in.size());
|
|
||||||
piCout << "[PIFFTW]" << "creating plan";
|
piCout << "[PIFFTW]" << "creating plan";
|
||||||
p_createPlan_r2c_1d(plan, in.size(), p_inr, p_out, FFTW_ESTIMATE);
|
p_createPlan_r2c_1d(plan, in.size(), in.data(), p_out.data(), FFTW_ESTIMATE | FFTW_UNALIGNED);
|
||||||
v_out.resize(in.size());
|
|
||||||
prepare = PlanParams(in.size(), fo_real);
|
prepare = PlanParams(in.size(), fo_real);
|
||||||
}
|
}
|
||||||
memcpy(p_inr, in.data(), sizeof(T) * in.size());
|
p_executePlan_r2c(plan, in.data(), p_out.data());
|
||||||
p_executePlan(plan);
|
return p_out;
|
||||||
memcpy(v_out.data(), p_out, sizeof(complex<T>) * v_out.size());
|
|
||||||
return v_out;
|
|
||||||
}
|
}
|
||||||
const PIVector<complex<T> > & calcFFTinverse(const PIVector<complex<T> > & in) {
|
const PIVector<complex<T> > & calcFFTinverse(const PIVector<complex<T> > & in) {
|
||||||
if (prepare != PlanParams(in.size(), fo_inverse)) {
|
if (prepare != PlanParams(in.size(), fo_inverse)) {
|
||||||
newVec(p_in, in.size());
|
p_out.resize(in.size());
|
||||||
newVec(p_out, in.size());
|
|
||||||
piCout << "[PIFFTW]" << "creating plan";
|
piCout << "[PIFFTW]" << "creating plan";
|
||||||
p_createPlan_c2c_1d(plan, in.size(), p_in, p_out, FFTW_BACKWARD, FFTW_ESTIMATE);
|
p_createPlan_c2c_1d(plan, in.size(), in.data(), p_out.data(), FFTW_BACKWARD, FFTW_ESTIMATE | FFTW_UNALIGNED);
|
||||||
v_out.resize(in.size());
|
|
||||||
prepare = PlanParams(in.size(), fo_inverse);
|
prepare = PlanParams(in.size(), fo_inverse);
|
||||||
}
|
}
|
||||||
memcpy(p_in, in.data(), sizeof(complex<T>) * in.size());
|
p_executePlan_c2c(plan, in.data(), p_out.data());
|
||||||
p_executePlan(plan);
|
return p_out;
|
||||||
memcpy(v_out.data(), p_out, sizeof(complex<T>) * v_out.size());
|
|
||||||
return v_out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FFT_Operation {fo_real, fo_complex, fo_inverse};
|
enum FFT_Operation {fo_real, fo_complex, fo_inverse};
|
||||||
|
|
||||||
void preparePlan(int size, int op) {
|
void preparePlan(int size, int op) {
|
||||||
|
p_inr.clear();
|
||||||
|
p_in.clear();
|
||||||
|
p_out.clear();
|
||||||
switch ((FFT_Operation)op) {
|
switch ((FFT_Operation)op) {
|
||||||
case fo_real:
|
case fo_real:
|
||||||
newVec(p_inr, size);
|
p_inr.resize(size);
|
||||||
newVec(p_out, size);
|
p_out.resize(size);
|
||||||
p_createPlan_r2c_1d(plan, size, p_inr, p_out, FFTW_MEASURE);
|
p_createPlan_r2c_1d(plan, size, p_inr.data(), p_out.data(), FFTW_MEASURE | FFTW_UNALIGNED);
|
||||||
break;
|
break;
|
||||||
case fo_complex:
|
case fo_complex:
|
||||||
newVec(p_in, size);
|
p_in.resize(size);
|
||||||
newVec(p_out, size);
|
p_out.resize(size);
|
||||||
p_createPlan_c2c_1d(plan, size, p_in, p_out, FFTW_FORWARD, FFTW_MEASURE);
|
p_createPlan_c2c_1d(plan, size, p_in.data(), p_out.data(), FFTW_FORWARD, FFTW_MEASURE | FFTW_UNALIGNED);
|
||||||
break;
|
break;
|
||||||
case fo_inverse:
|
case fo_inverse:
|
||||||
newVec(p_in, size);
|
p_in.resize(size);
|
||||||
newVec(p_out, size);
|
p_out.resize(size);
|
||||||
p_createPlan_c2c_1d(plan, size, p_in, p_out, FFTW_BACKWARD, FFTW_MEASURE);
|
p_createPlan_c2c_1d(plan, size, p_in.data(), p_out.data(), FFTW_BACKWARD, FFTW_MEASURE | FFTW_UNALIGNED);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
size = 0;
|
size = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
v_out.resize(size);
|
|
||||||
prepare = PlanParams(size, (FFT_Operation)op);
|
prepare = PlanParams(size, (FFT_Operation)op);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,10 +116,6 @@ public:
|
|||||||
inline void p_executePlan_r2c(void * plan, const void * in, void * out) {}
|
inline void p_executePlan_r2c(void * plan, const void * in, void * out) {}
|
||||||
inline void p_destroyPlan(void *& plan) {}
|
inline void p_destroyPlan(void *& plan) {}
|
||||||
inline void p_makeThreadSafe() {}
|
inline void p_makeThreadSafe() {}
|
||||||
template <typename VT>
|
|
||||||
inline void newVec(VT *& v, int size) {delVec(v); v = (VT*)amalloc(sizeof(VT) * size);}
|
|
||||||
template <typename VT>
|
|
||||||
inline void delVec(VT *& v) {if (v) afree(v); v = 0;}
|
|
||||||
|
|
||||||
struct PlanParams {
|
struct PlanParams {
|
||||||
PlanParams() {size = 0; op = fo_complex;}
|
PlanParams() {size = 0; op = fo_complex;}
|
||||||
@@ -151,9 +127,9 @@ public:
|
|||||||
FFT_Operation op;
|
FFT_Operation op;
|
||||||
};
|
};
|
||||||
|
|
||||||
complex<T> * p_in, * p_out;
|
PIVector<complex<T> > p_in;
|
||||||
T * p_inr;
|
PIVector<T> p_inr;
|
||||||
PIVector<complex<T> > v_out;
|
PIVector<complex<T> > p_out;
|
||||||
void * plan;
|
void * plan;
|
||||||
PlanParams prepare;
|
PlanParams prepare;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#define PIP_VERSION_MAJOR 0
|
#define PIP_VERSION_MAJOR 0
|
||||||
#define PIP_VERSION_MINOR 9
|
#define PIP_VERSION_MINOR 9
|
||||||
#define PIP_VERSION_REVISION 2
|
#define PIP_VERSION_REVISION 4
|
||||||
#define PIP_VERSION_SUFFIX ""
|
#define PIP_VERSION_SUFFIX "alpha"
|
||||||
|
|
||||||
#endif // PIVERSION_H
|
#endif // PIVERSION_H
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "piincludes_p.h"
|
#include "piincludes_p.h"
|
||||||
#include "pisystemmonitor.h"
|
#include "pisystemmonitor.h"
|
||||||
#include "pisysteminfo.h"
|
#include "pisysteminfo.h"
|
||||||
|
#include "pitime_win.h"
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
# include <psapi.h>
|
# include <psapi.h>
|
||||||
# include <tlhelp32.h>
|
# include <tlhelp32.h>
|
||||||
@@ -179,7 +180,8 @@ void PISystemMonitor::run() {
|
|||||||
FILETIME ft0, ft1, ft_kernel, ft_user;
|
FILETIME ft0, ft1, ft_kernel, ft_user;
|
||||||
double el_s = PRIVATE->tm.elapsed_s() * cpu_count / 100.;
|
double el_s = PRIVATE->tm.elapsed_s() * cpu_count / 100.;
|
||||||
if (GetProcessTimes(PRIVATE->hProc, &ft0, &ft1, &ft_kernel, &ft_user) != 0) {
|
if (GetProcessTimes(PRIVATE->hProc, &ft0, &ft1, &ft_kernel, &ft_user) != 0) {
|
||||||
PISystemTime tm_kernel_c(ft_kernel), tm_user_c(ft_user);
|
PISystemTime tm_kernel_c = FILETIME2PISystemTime(ft_kernel);
|
||||||
|
PISystemTime tm_user_c = FILETIME2PISystemTime(ft_user);
|
||||||
if (cycle < 0) {
|
if (cycle < 0) {
|
||||||
PRIVATE->tm_kernel = tm_kernel_c;
|
PRIVATE->tm_kernel = tm_kernel_c;
|
||||||
PRIVATE->tm_user = tm_user_c;
|
PRIVATE->tm_user = tm_user_c;
|
||||||
|
|||||||
@@ -35,10 +35,7 @@
|
|||||||
* */
|
* */
|
||||||
|
|
||||||
#include "pimutex.h"
|
#include "pimutex.h"
|
||||||
#ifdef WINDOWS
|
#include "piincludes_p.h"
|
||||||
# include <windef.h>
|
|
||||||
# include <winbase.h>
|
|
||||||
#endif
|
|
||||||
#ifdef BLACKBERRY
|
#ifdef BLACKBERRY
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -55,6 +52,9 @@ PRIVATE_DEFINITION_END(PIMutex)
|
|||||||
|
|
||||||
|
|
||||||
PIMutex::PIMutex(): inited_(false) {
|
PIMutex::PIMutex(): inited_(false) {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
PRIVATE->mutex = 0;
|
||||||
|
#endif
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
extern PINtSetTimerResolution setTimerResolutionAddr;
|
extern PINtSetTimerResolution setTimerResolutionAddr;
|
||||||
void __PISetTimerResolution() {if (setTimerResolutionAddr == NULL) return; ULONG ret; setTimerResolutionAddr(1, TRUE, &ret);}
|
void __PISetTimerResolution() {if (setTimerResolutionAddr == NULL) return; ULONG ret; setTimerResolutionAddr(1, TRUE, &ret);}
|
||||||
#endif
|
#endif
|
||||||
#ifdef MAC_OS
|
#if defined(MAC_OS) || defined(BLACKBERRY)
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -80,10 +80,20 @@ end();
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
PRIVATE_DEFINITION_START(PIThread)
|
||||||
|
#ifndef WINDOWS
|
||||||
|
pthread_t thread;
|
||||||
|
sched_param sparam;
|
||||||
|
#else
|
||||||
|
void * thread;
|
||||||
|
#endif
|
||||||
|
PRIVATE_DEFINITION_END(PIThread)
|
||||||
|
|
||||||
|
|
||||||
PIThread::PIThread(void * data, ThreadFunc func, bool startNow, int timer_delay): PIObject() {
|
PIThread::PIThread(void * data, ThreadFunc func, bool startNow, int timer_delay): PIObject() {
|
||||||
piMonitor.threads++;
|
piMonitor.threads++;
|
||||||
tid_ = -1;
|
tid_ = -1;
|
||||||
thread = 0;
|
PRIVATE->thread = 0;
|
||||||
data_ = data;
|
data_ = data;
|
||||||
ret_func = func;
|
ret_func = func;
|
||||||
terminating = running_ = lockRun = false;
|
terminating = running_ = lockRun = false;
|
||||||
@@ -96,7 +106,7 @@ PIThread::PIThread(void * data, ThreadFunc func, bool startNow, int timer_delay)
|
|||||||
PIThread::PIThread(bool startNow, int timer_delay): PIObject() {
|
PIThread::PIThread(bool startNow, int timer_delay): PIObject() {
|
||||||
piMonitor.threads++;
|
piMonitor.threads++;
|
||||||
tid_ = -1;
|
tid_ = -1;
|
||||||
thread = 0;
|
PRIVATE->thread = 0;
|
||||||
ret_func = 0;
|
ret_func = 0;
|
||||||
terminating = running_ = lockRun = false;
|
terminating = running_ = lockRun = false;
|
||||||
priority_ = piNormal;
|
priority_ = piNormal;
|
||||||
@@ -107,16 +117,16 @@ PIThread::PIThread(bool startNow, int timer_delay): PIObject() {
|
|||||||
|
|
||||||
PIThread::~PIThread() {
|
PIThread::~PIThread() {
|
||||||
piMonitor.threads--;
|
piMonitor.threads--;
|
||||||
if (!running_ || thread == 0) return;
|
if (!running_ || PRIVATE->thread == 0) return;
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
# ifdef ANDROID
|
# ifdef ANDROID
|
||||||
pthread_kill(thread, SIGTERM);
|
pthread_kill(PRIVATE->thread, SIGTERM);
|
||||||
# else
|
# else
|
||||||
pthread_cancel(thread);
|
pthread_cancel(PRIVATE->thread);
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
TerminateThread(thread, 0);
|
TerminateThread(PRIVATE->thread, 0);
|
||||||
CloseHandle(thread);
|
CloseHandle(PRIVATE->thread);
|
||||||
#endif
|
#endif
|
||||||
terminating = running_ = false;
|
terminating = running_ = false;
|
||||||
}
|
}
|
||||||
@@ -130,29 +140,29 @@ bool PIThread::start(int timer_delay) {
|
|||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
# ifndef ANDROID
|
# ifndef ANDROID
|
||||||
//pthread_attr_setschedparam(&attr, &sparam);
|
//pthread_attr_setschedparam(&attr, &(PRIVATE->sparam));
|
||||||
# endif
|
# endif
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
int ret = pthread_create(&thread, &attr, thread_function, this);
|
int ret = pthread_create(&PRIVATE->thread, &attr, thread_function, this);
|
||||||
//piCout << "pthread_create" << thread;
|
//piCout << "pthread_create" << PRIVATE->thread;
|
||||||
pthread_attr_destroy(&attr);
|
pthread_attr_destroy(&attr);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
# ifdef MAC_OS
|
# ifdef MAC_OS
|
||||||
pthread_threadid_np(thread, (__uint64_t*)&tid_);
|
pthread_threadid_np(PRIVATE->thread, (__uint64_t*)&tid_);
|
||||||
# else
|
# else
|
||||||
tid_ = thread;
|
tid_ = PRIVATE->thread;
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
if (thread != 0) CloseHandle(thread);
|
if (PRIVATE->thread != 0) CloseHandle(PRIVATE->thread);
|
||||||
thread = (void *)_beginthreadex(0, 0, thread_function, this, 0, 0);
|
PRIVATE->thread = (void *)_beginthreadex(0, 0, thread_function, this, 0, 0);
|
||||||
// thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)thread_function, this, 0, 0);
|
// PRIVATE->thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)thread_function, this, 0, 0);
|
||||||
if (thread != 0) {
|
if (PRIVATE->thread != 0) {
|
||||||
#endif
|
#endif
|
||||||
setPriority(priority_);
|
setPriority(priority_);
|
||||||
running_ = true;
|
running_ = true;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
thread = 0;
|
PRIVATE->thread = 0;
|
||||||
piCoutObj << "Error: Can`t start new thread:" << errorString();
|
piCoutObj << "Error: Can`t start new thread:" << errorString();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -166,29 +176,29 @@ bool PIThread::startOnce() {
|
|||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
# ifndef ANDROID
|
# ifndef ANDROID
|
||||||
//pthread_attr_setschedparam(&attr, &sparam);
|
//pthread_attr_setschedparam(&attr, &(PRIVATE->sparam));
|
||||||
# endif
|
# endif
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
int ret = pthread_create(&thread, &attr, thread_function_once, this);
|
int ret = pthread_create(&(PRIVATE->thread), &attr, thread_function_once, this);
|
||||||
//piCout << "pthread_create" << thread;
|
//piCout << "pthread_create" << PRIVATE->thread;
|
||||||
pthread_attr_destroy(&attr);
|
pthread_attr_destroy(&attr);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
# ifdef MAC_OS
|
# ifdef MAC_OS
|
||||||
pthread_threadid_np(thread, (__uint64_t*)&tid_);
|
pthread_threadid_np(PRIVATE->thread, (__uint64_t*)&tid_);
|
||||||
# else
|
# else
|
||||||
tid_ = thread;
|
tid_ = PRIVATE->thread;
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
if (thread != 0) CloseHandle(thread);
|
if (PRIVATE->thread != 0) CloseHandle(PRIVATE->thread);
|
||||||
thread = (void *)_beginthreadex(0, 0, thread_function_once, this, 0, 0);
|
PRIVATE->thread = (void *)_beginthreadex(0, 0, thread_function_once, this, 0, 0);
|
||||||
// thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)thread_function_once, this, 0, 0);
|
// thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)thread_function_once, this, 0, 0);
|
||||||
if (thread != 0) {
|
if (PRIVATE->thread != 0) {
|
||||||
#endif
|
#endif
|
||||||
setPriority(priority_);
|
setPriority(priority_);
|
||||||
running_ = true;
|
running_ = true;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
thread = 0;
|
PRIVATE->thread = 0;
|
||||||
piCoutObj << "Error: Can`t start new thread:" << errorString();
|
piCoutObj << "Error: Can`t start new thread:" << errorString();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -196,25 +206,25 @@ bool PIThread::startOnce() {
|
|||||||
|
|
||||||
|
|
||||||
void PIThread::terminate() {
|
void PIThread::terminate() {
|
||||||
if (thread == 0) return;
|
if (PRIVATE->thread == 0) return;
|
||||||
PIINTROSPECTION_UNREGISTER_THREAD(tid());
|
PIINTROSPECTION_UNREGISTER_THREAD(tid());
|
||||||
terminating = running_ = false;
|
terminating = running_ = false;
|
||||||
tid_ = -1;
|
tid_ = -1;
|
||||||
//piCout << "terminate" << thread;
|
//piCout << "terminate" << thread;
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
# ifdef ANDROID
|
# ifdef ANDROID
|
||||||
pthread_kill(thread, SIGTERM);
|
pthread_kill(PRIVATE->thread, SIGTERM);
|
||||||
# else
|
# else
|
||||||
//pthread_kill(thread, SIGKILL);
|
//pthread_kill(PRIVATE->thread, SIGKILL);
|
||||||
//void * ret(0);
|
//void * ret(0);
|
||||||
pthread_cancel(thread);
|
pthread_cancel(PRIVATE->thread);
|
||||||
//pthread_join(thread, &ret);
|
//pthread_join(PRIVATE->thread, &ret);
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
TerminateThread(thread, 0);
|
TerminateThread(PRIVATE->thread, 0);
|
||||||
CloseHandle(thread);
|
CloseHandle(PRIVATE->thread);
|
||||||
#endif
|
#endif
|
||||||
thread = 0;
|
PRIVATE->thread = 0;
|
||||||
end();
|
end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,11 +275,11 @@ __THREAD_FUNC__ PIThread::thread_function(void * t) {
|
|||||||
ct.terminating = ct.running_ = false;
|
ct.terminating = ct.running_ = false;
|
||||||
ct.tid_ = -1;
|
ct.tid_ = -1;
|
||||||
//cout << "thread " << t << " exiting ... " << endl;
|
//cout << "thread " << t << " exiting ... " << endl;
|
||||||
//piCout << "pthread_exit" << ct.thread;
|
//piCout << "pthread_exit" << ct.PRIVATE->thread;
|
||||||
PIINTROSPECTION_UNREGISTER_THREAD(ct.tid());
|
PIINTROSPECTION_UNREGISTER_THREAD(ct.tid());
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
pthread_detach(ct.thread);
|
pthread_detach(ct.PRIVATE->thread);
|
||||||
ct.thread = 0;
|
ct.PRIVATE->thread = 0;
|
||||||
#endif
|
#endif
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
@@ -307,11 +317,11 @@ __THREAD_FUNC__ PIThread::thread_function_once(void * t) {
|
|||||||
ct.terminating = ct.running_ = false;
|
ct.terminating = ct.running_ = false;
|
||||||
ct.tid_ = -1;
|
ct.tid_ = -1;
|
||||||
//cout << "thread " << t << " exiting ... " << endl;
|
//cout << "thread " << t << " exiting ... " << endl;
|
||||||
//piCout << "pthread_exit" << ct.thread;
|
//piCout << "pthread_exit" << ct.PRIVATE->thread;
|
||||||
PIINTROSPECTION_UNREGISTER_THREAD(ct.tid());
|
PIINTROSPECTION_UNREGISTER_THREAD(ct.tid());
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
pthread_detach(ct.thread);
|
pthread_detach(ct.PRIVATE->thread);
|
||||||
ct.thread = 0;
|
ct.PRIVATE->thread = 0;
|
||||||
#endif
|
#endif
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
@@ -355,22 +365,22 @@ int PIThread::priority2System(PIThread::Priority p) {
|
|||||||
void PIThread::setPriority(PIThread::Priority prior) {
|
void PIThread::setPriority(PIThread::Priority prior) {
|
||||||
priority_ = prior;
|
priority_ = prior;
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
if (!running_ || (thread == 0)) return;
|
if (!running_ || (PRIVATE->thread == 0)) return;
|
||||||
//piCout << "setPriority" << thread;
|
//piCout << "setPriority" << PRIVATE->thread;
|
||||||
policy_ = 0;
|
policy_ = 0;
|
||||||
memset(&sparam, 0, sizeof(sparam));
|
memset(&(PRIVATE->sparam), 0, sizeof(PRIVATE->sparam));
|
||||||
pthread_getschedparam(thread, &policy_, &sparam);
|
pthread_getschedparam(PRIVATE->thread, &policy_, &(PRIVATE->sparam));
|
||||||
sparam.
|
PRIVATE->sparam.
|
||||||
# ifndef LINUX
|
# ifndef LINUX
|
||||||
sched_priority
|
sched_priority
|
||||||
# else
|
# else
|
||||||
__sched_priority
|
__sched_priority
|
||||||
# endif
|
# endif
|
||||||
= priority2System(priority_);
|
= priority2System(priority_);
|
||||||
pthread_setschedparam(thread, policy_, &sparam);
|
pthread_setschedparam(PRIVATE->thread, policy_, &(PRIVATE->sparam));
|
||||||
#else
|
#else
|
||||||
if (!running_ || (thread == 0)) return;
|
if (!running_ || (PRIVATE->thread == 0)) return;
|
||||||
SetThreadPriority(thread, priority2System(priority_));
|
SetThreadPriority(PRIVATE->thread, priority2System(priority_));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,6 @@
|
|||||||
#include "piinit.h"
|
#include "piinit.h"
|
||||||
#include "pimutex.h"
|
#include "pimutex.h"
|
||||||
#include "piobject.h"
|
#include "piobject.h"
|
||||||
#ifdef BLACKBERRY
|
|
||||||
# include <pthread.h>
|
|
||||||
#endif
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
# define __THREAD_FUNC__ uint __stdcall
|
# define __THREAD_FUNC__ uint __stdcall
|
||||||
#else
|
#else
|
||||||
@@ -207,13 +204,7 @@ protected:
|
|||||||
PITimeMeasurer tmf_, tms_, tmr_;
|
PITimeMeasurer tmf_, tms_, tmr_;
|
||||||
PIThread::Priority priority_;
|
PIThread::Priority priority_;
|
||||||
ThreadFunc ret_func;
|
ThreadFunc ret_func;
|
||||||
#ifndef WINDOWS
|
PRIVATE_DECLARATION
|
||||||
pthread_t thread;
|
|
||||||
sched_param sparam;
|
|
||||||
#else
|
|
||||||
void * thread;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PITHREAD_H
|
#endif // PITHREAD_H
|
||||||
|
|||||||
@@ -23,5 +23,7 @@
|
|||||||
#include "pimutex.h"
|
#include "pimutex.h"
|
||||||
#include "pithread.h"
|
#include "pithread.h"
|
||||||
#include "pitimer.h"
|
#include "pitimer.h"
|
||||||
|
#include "pipipelinethread.h"
|
||||||
|
#include "pigrabberbase.h"
|
||||||
|
|
||||||
#endif // PITHREADMODULE_H
|
#endif // PITHREADMODULE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user