added CCECDeviceMap::GetChildrenOf()
[deb_libcec.git] / src / lib / devices / CECDeviceMap.cpp
index 3c70603a541092ce56eadde795b899fbf3d84e75..23e7a6fad980e89b60b357608a35adb280a6360a 100644 (file)
  *     http://www.pulse-eight.net/
  */
 
+#include "env.h"
 #include "CECDeviceMap.h"
+
 #include "CECAudioSystem.h"
 #include "CECPlaybackDevice.h"
 #include "CECRecordingDevice.h"
 #include "CECTuner.h"
 #include "CECTV.h"
-#include "../CECProcessor.h"
+#include "lib/CECProcessor.h"
+#include "lib/CECTypeUtils.h"
 
 using namespace std;
 using namespace CEC;
@@ -264,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);
+  }
+}