added CCECDeviceMap::GetChildrenOf()
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 18 Oct 2012 13:50:07 +0000 (15:50 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 18 Oct 2012 15:31:57 +0000 (17:31 +0200)
src/lib/devices/CECDeviceMap.cpp
src/lib/devices/CECDeviceMap.h

index a21b2b43254149cf51408d43c90365a81bbe6a4a..23e7a6fad980e89b60b357608a35adb280a6360a 100644 (file)
@@ -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);
+  }
+}
index d4af816a076dad44c85eac3d582f9f42de490b44..c27a2dd57e533df3e631fa3b1e4c0b67b18c57c1 100644 (file)
@@ -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;