mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +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;
|
||||
}
|
||||
|
||||
bool
|
||||
DevMgr::forgetDevice( DevIDRelay devid )
|
||||
int
|
||||
DevMgr::forgetDevices( vector<DevIDRelay>& devids )
|
||||
{
|
||||
int count = 0;
|
||||
MutexLock ml( &m_mapLock );
|
||||
map<DevIDRelay,UDPAddrRec>::iterator iter = m_devAddrMap.find( devid );
|
||||
bool found = m_devAddrMap.end() != iter;
|
||||
if ( found ) {
|
||||
m_devAddrMap.erase( iter );
|
||||
if ( 0 == devids.size() ) {
|
||||
count = m_devAddrMap.size();
|
||||
m_devAddrMap.clear();
|
||||
} 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
|
||||
|
|
|
@ -36,7 +36,7 @@ class DevMgr {
|
|||
|
||||
/* Called from ctrl port */
|
||||
void printDevices( string& str, vector<DevIDRelay> devids /* empty means all */ );
|
||||
bool forgetDevice( DevIDRelay devid );
|
||||
int forgetDevices( vector<DevIDRelay>& devids );
|
||||
void getKnownDevices( vector<DevIDRelay>& devids );
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue