move most old PIMap iterators to new

Documentation of PIVector, PIMap and PIMapIterator
This commit is contained in:
2020-08-03 01:43:23 +03:00
parent df457a1602
commit 427e7411c1
8 changed files with 280 additions and 70 deletions

View File

@@ -388,8 +388,9 @@ bool PIConnection::removeDevice(const PIString & full_path) {
}
bounded_extractors.remove(dev);
channels_.remove(dev);
for (auto it = channels_.begin(); it != channels_.end(); it++)
it.value().removeAll(dev);
auto it = channels_.makeIterator();
while (it.next())
it.valueRef().removeAll(dev);
__device_pool__->lock();
if (diags_.value(dev, 0) != 0)
delete diags_.value(dev);
@@ -411,8 +412,9 @@ void PIConnection::removeAllDevices() {
s.value()->unlock();
}
channels_.remove(d);
for (PIMap<PIIODevice * , PIVector<PIIODevice * > >::iterator it = channels_.begin(); it != channels_.end(); ++it)
it.value().removeAll(d);
auto it = channels_.makeIterator();
while (it.next())
it.valueRef().removeAll(d);
if (diags_.value(d, 0) != 0)
delete diags_.value(d);
diags_.remove(d);
@@ -566,8 +568,9 @@ void PIConnection::removeAllFilters() {
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.value()->extractor);
auto it = channels_.makeIterator();
while (it.next())
it.valueRef().removeAll(i.value()->extractor);
if (diags_.value(i.value()->extractor, 0) != 0)
delete diags_.value(i.value()->extractor);
diags_.remove(i.value()->extractor);
@@ -658,8 +661,9 @@ bool PIConnection::removeChannel(const PIString & name0) {
if (pe0 != 0) dev0 = pe0;
if (dev0 == 0) return false;
channels_.remove(dev0);
for (PIMap<PIIODevice * , PIVector<PIIODevice * > >::iterator it = channels_.begin(); it != channels_.end(); ++it)
it.value().removeAll(dev0);
auto it = channels_.makeIterator();
while (it.next())
it.valueRef().removeAll(dev0);
return true;
}
@@ -1240,8 +1244,9 @@ void PIConnection::Sender::tick(void * , int) {
void PIConnection::unboundExtractor(PIPacketExtractor * pe) {
if (pe == 0) return;
channels_.remove(pe);
for (PIMap<PIIODevice * , PIVector<PIIODevice * > >::iterator it = channels_.begin(); it != channels_.end(); ++it)
it.value().removeAll(pe);
auto it = channels_.makeIterator();
while (it.next())
it.valueRef().removeAll(pe);
bounded_extractors.remove(pe);
PIVector<PIIODevice * > k = bounded_extractors.keys();
piForeach (PIIODevice * i, k) {