From: Lars Op den Kamp Date: Thu, 18 Oct 2012 13:50:07 +0000 (+0200) Subject: added CCECDeviceMap::GetChildrenOf() X-Git-Tag: upstream/2.2.0~1^2~13^2~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1a1e2e6c67d1812527c14a2e5bbb359b63567476;p=deb_libcec.git added CCECDeviceMap::GetChildrenOf() --- diff --git a/src/lib/devices/CECDeviceMap.cpp b/src/lib/devices/CECDeviceMap.cpp index a21b2b4..23e7a6f 100644 --- a/src/lib/devices/CECDeviceMap.cpp +++ b/src/lib/devices/CECDeviceMap.cpp @@ -39,6 +39,7 @@ #include "CECTuner.h" #include "CECTV.h" #include "lib/CECProcessor.h" +#include "lib/CECTypeUtils.h" using namespace std; using namespace CEC; @@ -266,3 +267,19 @@ cec_logical_addresses CCECDeviceMap::ToLogicalAddresses(const CECDEVICEVEC &devi addresses.Set((*it)->GetLogicalAddress()); return addresses; } + +void CCECDeviceMap::GetChildrenOf(CECDEVICEVEC& devices, CCECBusDevice* device) const +{ + devices.clear(); + if (!device) + return; + + uint16_t iPA = device->GetCurrentPhysicalAddress(); + + for (CECDEVICEMAP::const_iterator it = m_busDevices.begin(); it != m_busDevices.end(); it++) + { + uint16_t iCurrentPA = it->second->GetCurrentPhysicalAddress(); + if (CCECTypeUtils::PhysicalAddressIsIncluded(iPA, iCurrentPA)) + devices.push_back(it->second); + } +} diff --git a/src/lib/devices/CECDeviceMap.h b/src/lib/devices/CECDeviceMap.h index d4af816..c27a2dd 100644 --- a/src/lib/devices/CECDeviceMap.h +++ b/src/lib/devices/CECDeviceMap.h @@ -62,6 +62,7 @@ namespace CEC void GetByLogicalAddresses(CECDEVICEVEC &devices, const cec_logical_addresses &addresses); void GetActive(CECDEVICEVEC &devices) const; void GetByType(const cec_device_type type, CECDEVICEVEC &devices) const; + void GetChildrenOf(CECDEVICEVEC& devices, CCECBusDevice* device) const; void GetPowerOffDevices(const libcec_configuration &configuration, CECDEVICEVEC &devices) const; void GetWakeDevices(const libcec_configuration &configuration, CECDEVICEVEC &devices) const;