refactor: rename PIP_NO_\* to PIP_HAS_\* with inverted logic
All feature flags now use positive naming (enabled by default): - PIP_HAS_FILESYSTEM, PIP_HAS_THREADS, PIP_HAS_SOCKET - PIP_HAS_PROCESS, PIP_HAS_DYNLIB, PIP_HAS_FFT, PIP_HAS_SERIAL Preprocessor guards inverted: - #ifndef PIP_NO_X → #ifdef PIP_HAS_X - #ifdef PIP_NO_X → #ifndef PIP_HAS_X CMake options default ON instead of OFF. Platform blocks set flags OFF to disable features. 85 files transformed via Python script + 2 manual fixes.
This commit is contained in:
@@ -29,7 +29,7 @@ const uint PIBaseTransfer::signature = 0x54424950;
|
||||
|
||||
PIBaseTransfer::PIBaseTransfer()
|
||||
: crc(standardCRC_16())
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
, diag(false)
|
||||
#endif
|
||||
{
|
||||
@@ -44,7 +44,7 @@ PIBaseTransfer::PIBaseTransfer()
|
||||
send_queue = 0;
|
||||
send_up = 0;
|
||||
timeout_ = 10.;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.setDisconnectTimeout(PISystemTime::fromSeconds(timeout_ / 10.));
|
||||
diag.setName("PIBaseTransfer");
|
||||
diag.start(20_Hz);
|
||||
@@ -60,7 +60,7 @@ PIBaseTransfer::PIBaseTransfer()
|
||||
|
||||
|
||||
PIBaseTransfer::~PIBaseTransfer() {
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.stopAndWait();
|
||||
#endif
|
||||
break_ = true;
|
||||
@@ -94,7 +94,7 @@ void PIBaseTransfer::setPause(bool pause_) {
|
||||
|
||||
void PIBaseTransfer::setTimeout(double sec) {
|
||||
timeout_ = sec;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.setDisconnectTimeout(PISystemTime::fromSeconds(sec));
|
||||
#endif
|
||||
}
|
||||
@@ -103,7 +103,7 @@ void PIBaseTransfer::setTimeout(double sec) {
|
||||
void PIBaseTransfer::received(PIByteArray data) {
|
||||
packet_header_size = sizeof(PacketHeader) + customHeader().size();
|
||||
if (data.size() < sizeof(PacketHeader)) {
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.received(data.size(), false);
|
||||
#endif
|
||||
return;
|
||||
@@ -113,12 +113,12 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
PacketType pt = (PacketType)h.type;
|
||||
if (!h.check_sig()) {
|
||||
piCoutObj << "invalid packet signature"_tr("PIBaseTransfer");
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.received(data.size(), false);
|
||||
#endif
|
||||
return;
|
||||
} else
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.received(data.size(), true);
|
||||
#endif
|
||||
// piCoutObj << "receive" << h.session_id << h.type << h.id;
|
||||
@@ -195,7 +195,9 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
replies.resize(sr.packets + 1);
|
||||
replies.fill(pt_Unknown);
|
||||
pm_string.resize(replies.size(), '-');
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.reset();
|
||||
#endif
|
||||
is_receiving = true;
|
||||
break_ = false;
|
||||
mutex_send.lock();
|
||||
@@ -277,7 +279,7 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
#endif
|
||||
case pt_Pause:
|
||||
mutex_header.lock();
|
||||
@@ -309,7 +311,7 @@ bool PIBaseTransfer::send_process() {
|
||||
mutex_session.lock();
|
||||
packet_header_size = sizeof(PacketHeader) + customHeader().size();
|
||||
break_ = false;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.reset();
|
||||
#endif
|
||||
sendStarted();
|
||||
@@ -359,7 +361,7 @@ bool PIBaseTransfer::send_process() {
|
||||
}
|
||||
stm.reset();
|
||||
ba = build_packet(i);
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.sended(ba.size_s());
|
||||
#endif
|
||||
sendRequest(ba);
|
||||
@@ -414,7 +416,7 @@ bool PIBaseTransfer::send_process() {
|
||||
continue;
|
||||
}
|
||||
ba = build_packet(chk - 1);
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.sended(ba.size_s());
|
||||
#endif
|
||||
sendRequest(ba);
|
||||
@@ -521,7 +523,7 @@ void PIBaseTransfer::sendReply(PacketType reply) {
|
||||
header.type = reply;
|
||||
PIByteArray ba;
|
||||
ba << header;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (is_sending || is_receiving) diag.sended(ba.size_s());
|
||||
#endif
|
||||
sendRequest(ba);
|
||||
@@ -542,7 +544,7 @@ bool PIBaseTransfer::getStartRequest() {
|
||||
state_string = "send request";
|
||||
PITimeMeasurer tm;
|
||||
while (tm.elapsed_s() < timeout_) {
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.sended(ba.size_s());
|
||||
#endif
|
||||
sendRequest(ba);
|
||||
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
//! \~russian Возвращает число байтов, уже обработанных в текущей сессии.
|
||||
llong bytesCur() const { return bytes_cur; }
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
//! \~english Get diagnostics object
|
||||
//! \~russian Получить объект диагностики
|
||||
//! \~\return
|
||||
@@ -348,7 +348,7 @@ private:
|
||||
CRC_16 crc;
|
||||
int send_queue;
|
||||
int send_up;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
PIDiagnostics diag;
|
||||
#endif
|
||||
PIMutex mutex_session;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
//! \~\brief
|
||||
//! \~english Multi-channel sender and receiver over multicast, broadcast and loopback endpoints.
|
||||
//! \~russian Многоканальный отправитель и приемник через multicast-, broadcast- и loopback-конечные точки.
|
||||
#ifndef PIP_NO_SOCKET
|
||||
#ifdef PIP_HAS_SOCKET
|
||||
class PIP_IO_UTILS_EXPORT PIBroadcast
|
||||
: public PIThread
|
||||
, public PIEthUtilBase {
|
||||
@@ -183,6 +183,6 @@ private:
|
||||
int lo_pcnt;
|
||||
bool _started, _send_only, _reinit;
|
||||
};
|
||||
#endif // PIP_NO_SOCKET
|
||||
#endif // PIP_HAS_SOCKET
|
||||
|
||||
#endif // PIBROADCAST_H
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "piliterals_time.h"
|
||||
#include "pitime.h"
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
# include "pitranslator.h"
|
||||
|
||||
/** \class PIConnection
|
||||
@@ -1312,4 +1312,4 @@ __DevicePoolContainer__::__DevicePoolContainer__() {
|
||||
__device_pool__ = new PIConnection::DevicePool();
|
||||
}
|
||||
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
|
||||
@@ -379,7 +379,7 @@ public:
|
||||
bool isEmpty() const { return device_modes.isEmpty(); }
|
||||
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
//! \~english Returns diagnostics object for device or filter "full_path_name".
|
||||
//! \~russian Возвращает объект диагностики для устройства или фильтра "full_path_name".
|
||||
PIDiagnostics * diagnostic(const PIString & full_path_name) const;
|
||||
@@ -417,7 +417,7 @@ public:
|
||||
//! \~russian Возвращает, работает ли общий пул устройств в режиме имитации.
|
||||
static bool isFakeMode();
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
class PIP_EXPORT DevicePool: public PIThread {
|
||||
PIOBJECT_SUBCLASS(DevicePool, PIThread);
|
||||
friend void __DevicePool_threadReadDP(void * ddp);
|
||||
@@ -459,7 +459,7 @@ public:
|
||||
PIMap<PIString, DeviceData *> devices;
|
||||
bool fake;
|
||||
};
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
|
||||
|
||||
//! \events
|
||||
@@ -475,7 +475,7 @@ public:
|
||||
//! \~russian Генерируется, когда фильтр "from" выдает пакет.
|
||||
EVENT2(packetReceivedEvent, const PIString &, from, const PIByteArray &, data);
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
//! \fn void qualityChanged(const PIIODevice * device, PIDiagnostics::Quality new_quality, PIDiagnostics::Quality old_quality)
|
||||
//! \~english Emitted when diagnostics quality of "device" changes.
|
||||
//! \~russian Генерируется при изменении качества диагностики устройства "device".
|
||||
@@ -502,7 +502,7 @@ private:
|
||||
void rawReceived(PIIODevice * dev, const PIString & from, const PIByteArray & data);
|
||||
void unboundExtractor(PIPacketExtractor * pe);
|
||||
EVENT_HANDLER2(void, packetExtractorReceived, const uchar *, data, int, size);
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
EVENT_HANDLER2(void, diagQualityChanged, PIDiagnostics::Quality, new_quality, PIDiagnostics::Quality, old_quality);
|
||||
#endif
|
||||
|
||||
@@ -517,7 +517,7 @@ private:
|
||||
PIVector<PIIODevice *> devices;
|
||||
};
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
class PIP_EXPORT Sender: public PITimer {
|
||||
PIOBJECT_SUBCLASS(Sender, PIObject);
|
||||
|
||||
@@ -533,21 +533,21 @@ private:
|
||||
#endif
|
||||
|
||||
PIMap<PIString, Extractor *> extractors;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
PIMap<PIString, Sender *> senders;
|
||||
#endif
|
||||
PIMap<PIString, PIIODevice *> device_names;
|
||||
PIMap<PIIODevice *, PIIODevice::DeviceMode> device_modes;
|
||||
PIMap<PIIODevice *, PIVector<PIPacketExtractor *>> bounded_extractors;
|
||||
PIMap<PIIODevice *, PIVector<PIIODevice *>> channels_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
PIMap<PIIODevice *, PIDiagnostics *> diags_;
|
||||
#endif
|
||||
|
||||
static PIVector<PIConnection *> _connections;
|
||||
};
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
void __DevicePool_threadReadDP(void * ddp);
|
||||
|
||||
extern PIP_EXPORT PIConnection::DevicePool * __device_pool__;
|
||||
@@ -559,7 +559,7 @@ public:
|
||||
};
|
||||
|
||||
static __DevicePoolContainer__ __device_pool_container__;
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
|
||||
|
||||
#endif // PICONNECTION_H
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "pidiagnostics.h"
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
|
||||
# include "piliterals_time.h"
|
||||
# include "pitranslator.h"
|
||||
@@ -253,4 +253,4 @@ void PIDiagnostics::changeDisconnectTimeout(PISystemTime disct) {
|
||||
mutex_state.unlock();
|
||||
}
|
||||
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "pitimer.h"
|
||||
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
//! \~\ingroup IO-Utils
|
||||
//! \brief
|
||||
//! \~english Connection diagnostics for packet frequency, throughput and receive quality
|
||||
@@ -236,6 +236,6 @@ inline bool operator!=(const PIDiagnostics::Entry & f, const PIDiagnostics::Entr
|
||||
inline bool operator<(const PIDiagnostics::Entry & f, const PIDiagnostics::Entry & s) {
|
||||
return f.bytes_ok < s.bytes_ok;
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
|
||||
#endif // PIDIAGNOSTICS_H
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#ifndef PIETHUTILBASE_H
|
||||
#define PIETHUTILBASE_H
|
||||
#ifndef PIP_NO_SOCKET
|
||||
#ifdef PIP_HAS_SOCKET
|
||||
|
||||
#include "pibytearray.h"
|
||||
#include "pip_io_utils_export.h"
|
||||
@@ -97,5 +97,5 @@ private:
|
||||
bool _crypt;
|
||||
};
|
||||
|
||||
#endif // PIP_NO_SOCKET
|
||||
#endif // PIP_HAS_SOCKET
|
||||
#endif // PIETHUTILBASE_H
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "pifiletransfer.h"
|
||||
|
||||
#ifndef PIP_NO_FILESYSTEM
|
||||
#ifdef PIP_HAS_FILESYSTEM
|
||||
const char PIFileTransfer::sign[] = {'P', 'F', 'T'};
|
||||
|
||||
PIFileTransfer::PIFileTransfer() {
|
||||
@@ -341,4 +341,4 @@ void PIFileTransfer::send_finished(bool ok) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // PIP_NO_FILESYSTEM
|
||||
#endif // PIP_HAS_FILESYSTEM
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "pibasetransfer.h"
|
||||
#include "pidir.h"
|
||||
|
||||
#ifndef PIP_NO_FILESYSTEM
|
||||
#ifdef PIP_HAS_FILESYSTEM
|
||||
# define __PIFILETRANSFER_VERSION 2
|
||||
|
||||
|
||||
@@ -263,6 +263,6 @@ inline PICout operator<<(PICout s, const PIFileTransfer::PFTFileInfo & v) {
|
||||
s.restoreControls();
|
||||
return s;
|
||||
}
|
||||
#endif // PIP_NO_FILESYSTEM
|
||||
#endif // PIP_HAS_FILESYSTEM
|
||||
|
||||
#endif // PIFILETRANSFER_H
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#ifndef pipackedtcp_H
|
||||
#define pipackedtcp_H
|
||||
#ifndef PIP_NO_SOCKET
|
||||
#ifdef PIP_HAS_SOCKET
|
||||
|
||||
#include "piiodevice.h"
|
||||
#include "pinetworkaddress.h"
|
||||
@@ -123,6 +123,6 @@ private:
|
||||
|
||||
REGISTER_DEVICE(PIPackedTCP)
|
||||
|
||||
#endif // PIP_NO_SOCKET
|
||||
#endif // PIP_HAS_SOCKET
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#ifndef PISTREAMPACKER_H
|
||||
#define PISTREAMPACKER_H
|
||||
#ifndef PIP_NO_SOCKET
|
||||
#ifdef PIP_HAS_SOCKET
|
||||
|
||||
#include "piethutilbase.h"
|
||||
#include "piobject.h"
|
||||
@@ -201,5 +201,5 @@ private:
|
||||
mutable PIMutex prog_s_mutex, prog_r_mutex;
|
||||
};
|
||||
|
||||
#endif // PIP_NO_SOCKET
|
||||
#endif // PIP_HAS_SOCKET
|
||||
#endif // PISTREAMPACKER_H
|
||||
|
||||
Reference in New Issue
Block a user