git-svn-id: svn://db.shs.com.ru/pip@816 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -250,13 +250,24 @@ endif()
|
||||
|
||||
|
||||
# Check if PIP should be built with introspection
|
||||
set(_PIP_DEFS "")
|
||||
if(INTROSPECTION)
|
||||
message(STATUS "Building PIP with introspection")
|
||||
message(STATUS "Warning: Introspection reduces the performance!")
|
||||
add_definitions(-DPIP_INTROSPECTION)
|
||||
set(_PIP_DEFS "PIP_INTROSPECTION")
|
||||
else()
|
||||
message(STATUS "Building PIP without introspection")
|
||||
endif()
|
||||
if ((NOT _PIP_SAVED_DEFS) OR (NOT "x${_PIP_SAVED_DEFS}" STREQUAL "x${_PIP_DEFS}"))
|
||||
set(_PIP_SAVED_DEFS "${_PIP_DEFS}" CACHE STRING "pip_defs" FORCE)
|
||||
file(WRITE "${PIP_SRC_MAIN}/pip_defs.h" "// This file was generated by PIP CMake, don`t edit it!\n")
|
||||
if (NOT "x${_PIP_DEFS}" STREQUAL "x")
|
||||
file(APPEND "${PIP_SRC_MAIN}/pip_defs.h" "#define ${_PIP_DEFS}\n")
|
||||
endif()
|
||||
endif()
|
||||
list(APPEND HDRS "${PIP_SRC_MAIN}/pip_defs.h")
|
||||
#message("${_PIP_DEFS_CHANGED}")
|
||||
|
||||
|
||||
# Check if RT timers exists
|
||||
|
||||
@@ -179,6 +179,12 @@ PIString s("0123456789");
|
||||
piCout << s.reversed(); // s = "9876543210"
|
||||
piCout << s; // s = "0123456789"
|
||||
//! [PIString::reversed]
|
||||
//! [PIString::elided]
|
||||
piCout << PIString("123456789ABCDEF").elided(8, PIString::ElideLeft); // ..ABCDEF
|
||||
piCout << PIString("123456789ABCDEF").elided(8, PIString::ElideCenter); // 123..DEF
|
||||
piCout << PIString("123456789ABCDEF").elided(8, PIString::ElideRight); // 123456..
|
||||
piCout << PIString("123456789ABCDEF").elided(8, 0.25); // 12..CDEF
|
||||
//! [PIString::elided]
|
||||
//! [PIString::lengthAscii]
|
||||
piCout << PIString("0123456789").lengthAscii(); // 10
|
||||
piCout << PIString("№1").lengthAscii(); // 3
|
||||
|
||||
@@ -33,13 +33,13 @@ class PIP_EXPORT PIList: public std::list<Type, Allocator> {
|
||||
typedef PIList<Type, Allocator> _CList;
|
||||
typedef std::list<Type, Allocator> _stlc;
|
||||
public:
|
||||
PIList() {piMonitor.containers++;}
|
||||
PIList(const Type & value) {piMonitor.containers++; _stlc::resize(1, value);}
|
||||
PIList(const Type & v0, const Type & v1) {piMonitor.containers++; _stlc::push_back(v0); _stlc::push_back(v1);}
|
||||
PIList(const Type & v0, const Type & v1, const Type & v2) {piMonitor.containers++; _stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2);}
|
||||
PIList(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {piMonitor.containers++; _stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2); _stlc::push_back(v3);}
|
||||
PIList(uint size, const Type & value = Type()) {piMonitor.containers++; _stlc::resize(size, value);}
|
||||
virtual ~PIList() {piMonitor.containers--;}
|
||||
PIList() {}
|
||||
PIList(const Type & value) {_stlc::resize(1, value);}
|
||||
PIList(const Type & v0, const Type & v1) {_stlc::push_back(v0); _stlc::push_back(v1);}
|
||||
PIList(const Type & v0, const Type & v1, const Type & v2) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2);}
|
||||
PIList(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2); _stlc::push_back(v3);}
|
||||
PIList(uint size, const Type & value = Type()) {_stlc::resize(size, value);}
|
||||
virtual ~PIList() {}
|
||||
Type & operator [](uint index) {return (*this)[index];}
|
||||
Type & operator [](uint index) const {return (*this)[index];}
|
||||
const Type * data(uint index = 0) const {return &(*this)[index];}
|
||||
|
||||
@@ -437,9 +437,9 @@ class PIP_EXPORT PIVector: public vector<T, Allocator> {
|
||||
typedef vector<T, Allocator> _stlc;
|
||||
public:
|
||||
|
||||
PIVector() {piMonitor.containers++;}
|
||||
PIVector(uint size, const T & value = T()) {piMonitor.containers++; _stlc::resize(size, value);}
|
||||
~PIVector() {piMonitor.containers--;}
|
||||
PIVector() {}
|
||||
PIVector(uint size, const T & value = T()) {_stlc::resize(size, value);}
|
||||
~PIVector() {}
|
||||
|
||||
const T & at(uint index) const {return (*this)[index];}
|
||||
T & at(uint index) {return (*this)[index];}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "piversion.h"
|
||||
#include "piplatform.h"
|
||||
#include "pip_export.h"
|
||||
#include "pip_defs.h"
|
||||
|
||||
//! Version of PIP in hex - 0x##(Major)##(Minor)##(Revision)
|
||||
#define PIP_VERSION ((PIP_VERSION_MAJOR << 16) | (PIP_VERSION_MINOR < 8) | PIP_VERSION_REVISION)
|
||||
|
||||
@@ -22,14 +22,11 @@
|
||||
|
||||
#include "pibase.h"
|
||||
#include "piflags.h"
|
||||
#include "pimonitor.h"
|
||||
#include <sys/types.h>
|
||||
#ifdef PIP_STD_IOSTREAM
|
||||
# include <iostream>
|
||||
#endif
|
||||
|
||||
extern PIMonitor piMonitor;
|
||||
|
||||
class PIObject;
|
||||
class PIMutex;
|
||||
class PIString;
|
||||
|
||||
@@ -77,7 +77,6 @@ PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__),
|
||||
setName(name);
|
||||
setDebug(true);
|
||||
mutexObjects().lock();
|
||||
piMonitor.objects++;
|
||||
objects() << this;
|
||||
mutexObjects().unlock();
|
||||
//piCout << "new" << this;
|
||||
@@ -87,7 +86,6 @@ PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__),
|
||||
PIObject::~PIObject() {
|
||||
//piCout << "delete" << this;
|
||||
mutexObjects().lock();
|
||||
piMonitor.objects--;
|
||||
objects().removeAll(this);
|
||||
mutexObjects().unlock();
|
||||
piDisconnect(this);
|
||||
|
||||
@@ -86,6 +86,10 @@ const int PIString::fromBaseN[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
|
||||
|
||||
const float PIString::ElideLeft = 0.f;
|
||||
const float PIString::ElideCenter = .5f;
|
||||
const float PIString::ElideRight = 1.f;
|
||||
|
||||
|
||||
#ifndef CC_VC
|
||||
# define pisprintf(f, v) char ch[256]; memset(ch, 0, 256); sprintf(ch, f, v);
|
||||
@@ -629,6 +633,21 @@ PIString & PIString::insert(int index, const PIString & str) {
|
||||
}
|
||||
|
||||
|
||||
PIString & PIString::elide(int size, float pos) {
|
||||
if (length() <= size) return *this;
|
||||
if (length() <= 2) {
|
||||
fill(".");
|
||||
return *this;
|
||||
}
|
||||
pos = piClampf(pos, 0.f, 1.f);
|
||||
int ns = size - 2;
|
||||
int ls = piRoundf(ns * pos);
|
||||
remove(ls, length() - ns);
|
||||
insert(ls, "..");
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
PIStringList PIString::split(const PIString & delim) const {
|
||||
PIStringList sl;
|
||||
if (isEmpty() || delim.isEmpty()) return sl;
|
||||
|
||||
@@ -39,6 +39,10 @@ public:
|
||||
//! Contructs an empty string
|
||||
PIString(): PIDeque<PIChar>() {}
|
||||
|
||||
static const float ElideLeft ;
|
||||
static const float ElideCenter;
|
||||
static const float ElideRight ;
|
||||
|
||||
//inline PIString & operator +=(const char c) {push_back(c); return *this;}
|
||||
PIString & operator +=(const PIChar & c) {push_back(c); return *this;}
|
||||
PIString & operator +=(const char * str);
|
||||
@@ -354,7 +358,7 @@ public:
|
||||
PIString quoted(PIChar c = PIChar('"')) {return PIString(*this).quote(c);}
|
||||
|
||||
/*! \brief Reverse string and return this string
|
||||
* \details Example: \snippet pistring.cpp PIString::reverse
|
||||
* \details Example: \snippet pistring.cpp PIString::reverse
|
||||
* \sa \a reversed() */
|
||||
PIString & reverse() {PIString str(*this); clear(); piForeachR (const PIChar & c, str) push_back(c); return *this;}
|
||||
|
||||
@@ -362,6 +366,15 @@ public:
|
||||
* \details Example: \snippet pistring.cpp PIString::reversed
|
||||
* \sa \a reverse() */
|
||||
PIString reversed() const {PIString str(*this); str.reverse(); return str;}
|
||||
|
||||
/*! \brief Elide string to maximum size \"size\" and return this string
|
||||
* \sa \a elided() */
|
||||
PIString & elide(int size, float pos = ElideCenter);
|
||||
|
||||
/*! \brief Elide copy of this string to maximum size \"size\" and return it
|
||||
* \details Example: \snippet pistring.cpp PIString::elided
|
||||
* \sa \a elide() */
|
||||
PIString elided(int size, float pos = ElideCenter) const {PIString str(*this); str.elide(size, pos); return str;}
|
||||
|
||||
|
||||
/*! \brief Take a part of string from symbol at index "start" and maximum length "len" and return it
|
||||
|
||||
@@ -246,7 +246,6 @@ PIEthernet::~PIEthernet() {
|
||||
//piCout << "~PIEthernet" << uint(this);
|
||||
stop();
|
||||
closeDevice();
|
||||
piMonitor.ethernets--;
|
||||
//piCoutObj << "~PIEthernet done";
|
||||
}
|
||||
|
||||
@@ -254,7 +253,6 @@ PIEthernet::~PIEthernet() {
|
||||
void PIEthernet::construct() {
|
||||
//piCout << " PIEthernet" << uint(this);
|
||||
setOption(BlockingWrite);
|
||||
piMonitor.ethernets++;
|
||||
connected_ = connecting_ = listen_threaded = server_bounded = false;
|
||||
sock = sock_s = -1;
|
||||
setReadTimeout(10000.);
|
||||
|
||||
@@ -164,7 +164,6 @@ PISerial::PISerial(const PIString & device_, PISerial::Speed speed_, PIFlags<PIS
|
||||
|
||||
PISerial::~PISerial() {
|
||||
closeDevice();
|
||||
piMonitor.serials--;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +172,6 @@ void PISerial::construct() {
|
||||
PRIVATE->hCom = 0;
|
||||
#endif
|
||||
fd = -1;
|
||||
piMonitor.serials++;
|
||||
setPriority(piHigh);
|
||||
vtime = 10;
|
||||
sending = false;
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Counter of some PIP types
|
||||
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pimonitor.h"
|
||||
|
||||
PIMonitor piMonitor;
|
||||
|
||||
PIMonitor::PIMonitor() {
|
||||
containers = strings = threads = timers = serials = ethernets = files = objects = 0;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Counter of some PIP types
|
||||
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIMONITOR_H
|
||||
#define PIMONITOR_H
|
||||
|
||||
#include "pip_export.h"
|
||||
|
||||
#if defined(DOXYGEN) || defined(__GNUC__)
|
||||
# undef PIP_EXPORT
|
||||
# define PIP_EXPORT
|
||||
#endif
|
||||
|
||||
class PIP_EXPORT PIMonitor
|
||||
{
|
||||
public:
|
||||
PIMonitor();
|
||||
|
||||
int containers, strings, threads, timers, serials, ethernets, files, objects;
|
||||
|
||||
};
|
||||
|
||||
#endif // PIMONITOR_H
|
||||
@@ -20,7 +20,6 @@
|
||||
#ifndef PISYSTEMMODULE_H
|
||||
#define PISYSTEMMODULE_H
|
||||
|
||||
#include "pimonitor.h"
|
||||
#include "picodec.h"
|
||||
#include "pisignals.h"
|
||||
#include "pilibrary.h"
|
||||
|
||||
@@ -161,7 +161,6 @@ PRIVATE_DEFINITION_END(PIThread)
|
||||
|
||||
PIThread::PIThread(void * data, ThreadFunc func, bool startNow, int timer_delay): PIObject() {
|
||||
PIINTROSPECTION_THREAD_NEW(this);
|
||||
piMonitor.threads++;
|
||||
tid_ = -1;
|
||||
PRIVATE->thread = 0;
|
||||
data_ = data;
|
||||
@@ -175,7 +174,6 @@ PIThread::PIThread(void * data, ThreadFunc func, bool startNow, int timer_delay)
|
||||
|
||||
PIThread::PIThread(bool startNow, int timer_delay): PIObject() {
|
||||
PIINTROSPECTION_THREAD_NEW(this);
|
||||
piMonitor.threads++;
|
||||
tid_ = -1;
|
||||
PRIVATE->thread = 0;
|
||||
ret_func = 0;
|
||||
@@ -188,7 +186,6 @@ PIThread::PIThread(bool startNow, int timer_delay): PIObject() {
|
||||
|
||||
PIThread::~PIThread() {
|
||||
PIINTROSPECTION_THREAD_DELETE(this);
|
||||
piMonitor.threads--;
|
||||
if (!running_ || PRIVATE->thread == 0) return;
|
||||
#ifdef FREERTOS
|
||||
//void * ret(0);
|
||||
|
||||
@@ -458,7 +458,6 @@ bool _PITimerImp_Pool::stopTimer(bool wait) {
|
||||
|
||||
|
||||
PITimer::PITimer(): PIObject() {
|
||||
piMonitor.timers++;
|
||||
#ifdef FREERTOS
|
||||
imp_mode = PITimer::Thread;
|
||||
#else
|
||||
@@ -469,14 +468,12 @@ PITimer::PITimer(): PIObject() {
|
||||
|
||||
|
||||
PITimer::PITimer(PITimer::TimerImplementation ti): PIObject() {
|
||||
piMonitor.timers++;
|
||||
imp_mode = ti;
|
||||
initFirst();
|
||||
}
|
||||
|
||||
|
||||
PITimer::PITimer(TimerEvent slot, void * data, PITimer::TimerImplementation ti): PIObject() {
|
||||
piMonitor.timers++;
|
||||
imp_mode = ti;
|
||||
initFirst();
|
||||
data_t = data;
|
||||
@@ -485,7 +482,6 @@ PITimer::PITimer(TimerEvent slot, void * data, PITimer::TimerImplementation ti):
|
||||
|
||||
|
||||
//PITimer::PITimer(const PITimer & other): PIObject() {
|
||||
// piMonitor.timers++;
|
||||
// imp_mode = other.imp_mode;
|
||||
// initFirst();
|
||||
// data_t = other.data_t;
|
||||
@@ -494,7 +490,6 @@ PITimer::PITimer(TimerEvent slot, void * data, PITimer::TimerImplementation ti):
|
||||
|
||||
|
||||
PITimer::~PITimer() {
|
||||
piMonitor.timers--;
|
||||
destroy();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user