mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
add ability to forget multiple devices
This commit is contained in:
parent
f6a91464ac
commit
07c9722433
2 changed files with 18 additions and 8 deletions
|
@ -102,16 +102,26 @@ DevMgr::get( DevIDRelay devid )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
int
|
||||||
DevMgr::forgetDevice( DevIDRelay devid )
|
DevMgr::forgetDevices( vector<DevIDRelay>& devids )
|
||||||
{
|
{
|
||||||
|
int count = 0;
|
||||||
MutexLock ml( &m_mapLock );
|
MutexLock ml( &m_mapLock );
|
||||||
map<DevIDRelay,UDPAddrRec>::iterator iter = m_devAddrMap.find( devid );
|
if ( 0 == devids.size() ) {
|
||||||
bool found = m_devAddrMap.end() != iter;
|
count = m_devAddrMap.size();
|
||||||
if ( found ) {
|
m_devAddrMap.clear();
|
||||||
m_devAddrMap.erase( iter );
|
} else {
|
||||||
|
vector<DevIDRelay>::const_iterator devidIter;
|
||||||
|
for ( devidIter = devids.begin(); devids.end() != devidIter; ++devidIter ) {
|
||||||
|
map<DevIDRelay,UDPAddrRec>::iterator iter =
|
||||||
|
m_devAddrMap.find( *devidIter );
|
||||||
|
if ( m_devAddrMap.end() != iter ) {
|
||||||
|
++count;
|
||||||
|
m_devAddrMap.erase( iter );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return found;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -36,7 +36,7 @@ class DevMgr {
|
||||||
|
|
||||||
/* Called from ctrl port */
|
/* Called from ctrl port */
|
||||||
void printDevices( string& str, vector<DevIDRelay> devids /* empty means all */ );
|
void printDevices( string& str, vector<DevIDRelay> devids /* empty means all */ );
|
||||||
bool forgetDevice( DevIDRelay devid );
|
int forgetDevices( vector<DevIDRelay>& devids );
|
||||||
void getKnownDevices( vector<DevIDRelay>& devids );
|
void getKnownDevices( vector<DevIDRelay>& devids );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue