replace piForeach* to for(:)
another c++11 try ...
This commit is contained in:
@@ -375,20 +375,20 @@ bool PIConnection::removeDevice(const PIString & full_path) {
|
||||
PIStringList dntd(deviceNames(dev));
|
||||
piForeachC (PIString & n, dntd)
|
||||
device_names.removeOne(n);
|
||||
piForeachC (SPair & s, senders) {
|
||||
if (s.second == 0) continue;
|
||||
s.second->lock();
|
||||
s.second->devices.removeAll(dev);
|
||||
s.second->unlock();
|
||||
for (auto s = senders.constBegin(); s != senders.constEnd(); s++) {
|
||||
if (s.value() == 0) continue;
|
||||
s.value()->lock();
|
||||
s.value()->devices.removeAll(dev);
|
||||
s.value()->unlock();
|
||||
}
|
||||
device_modes.remove(dev);
|
||||
piForeachC (PEPair & i, extractors) {
|
||||
if (i.second == 0) continue;
|
||||
i.second->devices.removeAll(dev);
|
||||
for (auto i = extractors.constBegin(); i != extractors.constEnd(); i++) {
|
||||
if (i.value() == 0) continue;
|
||||
i.value()->devices.removeAll(dev);
|
||||
}
|
||||
bounded_extractors.remove(dev);
|
||||
channels_.remove(dev);
|
||||
for (PIMap<PIIODevice * , PIVector<PIIODevice * > >::iterator it = channels_.begin(); it != channels_.end(); ++it)
|
||||
for (auto it = channels_.begin(); it != channels_.end(); it++)
|
||||
it.value().removeAll(dev);
|
||||
__device_pool__->lock();
|
||||
if (diags_.value(dev, 0) != 0)
|
||||
@@ -404,11 +404,11 @@ void PIConnection::removeAllDevices() {
|
||||
PIVector<PIIODevice * > bdevs(__device_pool__->boundedDevices(this));
|
||||
__device_pool__->lock();
|
||||
piForeach (PIIODevice * d, bdevs) {
|
||||
piForeachC (SPair & s, senders) {
|
||||
if (s.second == 0) continue;
|
||||
s.second->lock();
|
||||
s.second->devices.removeAll(d);
|
||||
s.second->unlock();
|
||||
for (auto s = senders.constBegin(); s != senders.constEnd(); s++) {
|
||||
if (s.value() == 0) continue;
|
||||
s.value()->lock();
|
||||
s.value()->devices.removeAll(d);
|
||||
s.value()->unlock();
|
||||
}
|
||||
channels_.remove(d);
|
||||
for (PIMap<PIIODevice * , PIVector<PIIODevice * > >::iterator it = channels_.begin(); it != channels_.end(); ++it)
|
||||
@@ -421,9 +421,9 @@ void PIConnection::removeAllDevices() {
|
||||
__device_pool__->unlock();
|
||||
device_modes.clear();
|
||||
bounded_extractors.clear();
|
||||
piForeachC (PEPair & i, extractors) {
|
||||
if (i.second == 0) continue;
|
||||
i.second->devices.clear();
|
||||
for (auto i = extractors.constBegin(); i != extractors.constEnd(); i++) {
|
||||
if (i.value() == 0) continue;
|
||||
i.value()->devices.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,15 +563,15 @@ bool PIConnection::removeFilter(const PIString & name_) {
|
||||
|
||||
void PIConnection::removeAllFilters() {
|
||||
__device_pool__->lock();
|
||||
piForeachC (PEPair & i, extractors) {
|
||||
if (i.second == 0) continue;
|
||||
channels_.remove(i.second->extractor);
|
||||
for (auto i = extractors.constBegin(); i != extractors.constEnd(); i++) {
|
||||
if (i.value() == 0) continue;
|
||||
channels_.remove(i.value()->extractor);
|
||||
for (PIMap<PIIODevice * , PIVector<PIIODevice * > >::iterator it = channels_.begin(); it != channels_.end(); ++it)
|
||||
it.value().removeAll(i.second->extractor);
|
||||
if (diags_.value(i.second->extractor, 0) != 0)
|
||||
delete diags_.value(i.second->extractor);
|
||||
diags_.remove(i.second->extractor);
|
||||
delete i.second;
|
||||
it.value().removeAll(i.value()->extractor);
|
||||
if (diags_.value(i.value()->extractor, 0) != 0)
|
||||
delete diags_.value(i.value()->extractor);
|
||||
diags_.remove(i.value()->extractor);
|
||||
delete i.value();
|
||||
}
|
||||
extractors.clear();
|
||||
bounded_extractors.clear();
|
||||
@@ -581,28 +581,31 @@ void PIConnection::removeAllFilters() {
|
||||
|
||||
PIVector<PIPacketExtractor * > PIConnection::filters() const {
|
||||
PIVector<PIPacketExtractor * > ret;
|
||||
piForeachC (PEPair & i, extractors)
|
||||
if (i.second != 0)
|
||||
if (i.second->extractor != 0) ret << i.second->extractor;
|
||||
for (auto i = extractors.constBegin(); i != extractors.constEnd(); i++) {
|
||||
if (i.value() != 0)
|
||||
if (i.value()->extractor != 0) ret << i.value()->extractor;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIStringList PIConnection::filterNames() const {
|
||||
PIStringList ret;
|
||||
piForeachC (PEPair & i, extractors)
|
||||
if (i.second != 0)
|
||||
if (i.second->extractor != 0) ret << i.first;
|
||||
for (auto i = extractors.constBegin(); i != extractors.constEnd(); i++) {
|
||||
if (i.value() != 0)
|
||||
if (i.value()->extractor != 0) ret << i.key();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIPacketExtractor * PIConnection::filter(const PIString & name_) const {
|
||||
PIString fname_ = name_.trimmed();
|
||||
piForeachC (PEPair & i, extractors)
|
||||
if (i.second != 0)
|
||||
if (i.second->extractor != 0 && i.first == fname_)
|
||||
return i.second->extractor;
|
||||
for (auto i = extractors.constBegin(); i != extractors.constEnd(); i++) {
|
||||
if (i.value() != 0)
|
||||
if (i.value()->extractor != 0 && i.key() == fname_)
|
||||
return i.value()->extractor;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -784,9 +787,10 @@ float PIConnection::senderFrequency(const PIString & name) const {
|
||||
|
||||
|
||||
void PIConnection::removeAllSenders() {
|
||||
piForeachC (SPair & s, senders)
|
||||
if (s.second != 0)
|
||||
delete s.second;
|
||||
for (auto s = senders.constBegin(); s != senders.constEnd(); s++) {
|
||||
if (s.value() != 0)
|
||||
delete s.value();
|
||||
}
|
||||
senders.clear();
|
||||
}
|
||||
|
||||
@@ -802,8 +806,8 @@ void PIConnection::startThreadedRead(const PIString & full_path_name) {
|
||||
|
||||
|
||||
void PIConnection::startAllThreadedReads() {
|
||||
piForeachC (DevicePool::DDPair & d, __device_pool__->devices)
|
||||
startThreadedRead(d.first);
|
||||
for (auto d = __device_pool__->devices.constBegin(); d != __device_pool__->devices.constEnd(); d++)
|
||||
startThreadedRead(d.key());
|
||||
}
|
||||
|
||||
|
||||
@@ -816,10 +820,10 @@ void PIConnection::startSender(const PIString & name) {
|
||||
|
||||
|
||||
void PIConnection::startAllSenders() {
|
||||
piForeachC (SPair & s, senders) {
|
||||
if (s.second == 0) continue;
|
||||
if (!s.second->isRunning() && !__device_pool__->fake)
|
||||
s.second->start(s.second->int_);
|
||||
for (auto s = senders.constBegin(); s != senders.constEnd(); s++) {
|
||||
if (s.value() == 0) continue;
|
||||
if (!s.value()->isRunning() && !__device_pool__->fake)
|
||||
s.value()->start(s.value()->int_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -835,8 +839,8 @@ void PIConnection::stopThreadedRead(const PIString & full_path_name) {
|
||||
|
||||
|
||||
void PIConnection::stopAllThreadedReads() {
|
||||
piForeachC (DevicePool::DDPair & d, __device_pool__->devices)
|
||||
stopThreadedRead(d.first);
|
||||
for (auto d = __device_pool__->devices.constBegin(); d != __device_pool__->devices.constEnd(); d++)
|
||||
stopThreadedRead(d.key());
|
||||
}
|
||||
|
||||
|
||||
@@ -848,10 +852,10 @@ void PIConnection::stopSender(const PIString & name) {
|
||||
|
||||
|
||||
void PIConnection::stopAllSenders() {
|
||||
piForeachC (SPair & s, senders) {
|
||||
if (s.second == 0) continue;
|
||||
if (s.second->isRunning())
|
||||
s.second->stop();
|
||||
for (auto s = senders.constBegin(); s != senders.constEnd(); s++) {
|
||||
if (s.value() == 0) continue;
|
||||
if (s.value()->isRunning())
|
||||
s.value()->stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,14 +1016,14 @@ bool PIConnection::DevicePool::removeDevice(PIConnection * parent, const PIStrin
|
||||
|
||||
void PIConnection::DevicePool::unboundConnection(PIConnection * parent) {
|
||||
PIStringList rem;
|
||||
piForeachC (DDPair & i, devices) {
|
||||
if (i.second == 0) {
|
||||
rem << i.first;
|
||||
for (auto i = devices.constBegin(); i != devices.constEnd(); i++) {
|
||||
if (i.value() == 0) {
|
||||
rem << i.key();
|
||||
continue;
|
||||
}
|
||||
i.second->listeners.removeAll(parent);
|
||||
if (i.second->listeners.isEmpty())
|
||||
rem << i.first;
|
||||
i.value()->listeners.removeAll(parent);
|
||||
if (i.value()->listeners.isEmpty())
|
||||
rem << i.key();
|
||||
}
|
||||
piForeachC (PIString & i, rem) {
|
||||
DeviceData * dd = devices.value(i);
|
||||
@@ -1105,9 +1109,9 @@ PIConnection::DevicePool::DeviceData::~DeviceData() {
|
||||
void PIConnection::DevicePool::run() {
|
||||
PIVector<PIConnection * > conns(PIConnection::allConnections());
|
||||
piForeach (PIConnection * c, conns) {
|
||||
piForeachC (PIConnection::DPair & d, c->diags_) {
|
||||
if (d.second == 0) continue;
|
||||
d.second->tick(0, 1);
|
||||
for (auto d = c->diags_.constBegin(); d != c->diags_.constEnd(); d++) {
|
||||
if (d.value() == 0) continue;
|
||||
d.value()->tick(0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user