moved CResponse and CWaitForResponse implementation from .h to .cpp
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 9 Dec 2013 15:31:04 +0000 (16:31 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 9 Dec 2013 15:31:04 +0000 (16:31 +0100)
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h

index 4358324db468a2c4e95c03f931319c02964585fd..c9699d8f96f6f46dcf3ce1d54cce543e646ae2af 100644 (file)
@@ -61,6 +61,75 @@ using namespace PLATFORM;
 #define LIB_CEC     m_processor->GetLib()
 #define ToString(p) CCECTypeUtils::ToString(p)
 
+CResponse::CResponse(cec_opcode opcode) :
+    m_opcode(opcode)
+{
+}
+
+CResponse::~CResponse(void)
+{
+  Broadcast();
+}
+
+bool CResponse::Wait(uint32_t iTimeout)
+{
+  return m_event.Wait(iTimeout);
+}
+
+void CResponse::Broadcast(void)
+{
+  m_event.Broadcast();
+}
+
+CWaitForResponse::CWaitForResponse(void)
+{
+}
+
+CWaitForResponse::~CWaitForResponse(void)
+{
+  Clear();
+}
+
+void CWaitForResponse::Clear()
+{
+  PLATFORM::CLockObject lock(m_mutex);
+  for (std::map<cec_opcode, CResponse*>::iterator it = m_waitingFor.begin(); it != m_waitingFor.end(); it++)
+    it->second->Broadcast();
+  m_waitingFor.clear();
+}
+
+bool CWaitForResponse::Wait(cec_opcode opcode, uint32_t iTimeout)
+{
+  CResponse *response = GetEvent(opcode);
+  return response ? response->Wait(iTimeout) : false;
+}
+
+void CWaitForResponse::Received(cec_opcode opcode)
+{
+  CResponse *response = GetEvent(opcode);
+  if (response)
+    response->Broadcast();
+}
+
+CResponse* CWaitForResponse::GetEvent(cec_opcode opcode)
+{
+  CResponse *retVal(NULL);
+  {
+    PLATFORM::CLockObject lock(m_mutex);
+    std::map<cec_opcode, CResponse*>::iterator it = m_waitingFor.find(opcode);
+    if (it != m_waitingFor.end())
+    {
+      retVal = it->second;
+    }
+    else
+    {
+      retVal = new CResponse(opcode);
+      m_waitingFor[opcode] = retVal;
+    }
+    return retVal;
+  }
+}
+
 CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress /* = CEC_INVALID_PHYSICAL_ADDRESS */) :
   m_type                  (CEC_DEVICE_TYPE_RESERVED),
   m_iPhysicalAddress      (iPhysicalAddress),
index 8a80f48673a7b179223f89c472f442a7045b82af..d227c0312749611f7bc753a51abab5de3542a1df 100644 (file)
@@ -50,22 +50,11 @@ namespace CEC
   class CResponse
   {
   public:
-    CResponse(cec_opcode opcode) :
-        m_opcode(opcode){}
-    ~CResponse(void)
-    {
-      Broadcast();
-    }
-
-    bool Wait(uint32_t iTimeout)
-    {
-      return m_event.Wait(iTimeout);
-    }
-
-    void Broadcast(void)
-    {
-      m_event.Broadcast();
-    }
+    CResponse(cec_opcode opcode);
+    ~CResponse(void);
+
+    bool Wait(uint32_t iTimeout);
+    void Broadcast(void);
 
   private:
     cec_opcode       m_opcode;
@@ -75,52 +64,15 @@ namespace CEC
   class CWaitForResponse
   {
   public:
-    CWaitForResponse(void) {}
-    ~CWaitForResponse(void)
-    {
-      Clear();
-    }
-
-    void Clear()
-    {
-      PLATFORM::CLockObject lock(m_mutex);
-      for (std::map<cec_opcode, CResponse*>::iterator it = m_waitingFor.begin(); it != m_waitingFor.end(); it++)
-        it->second->Broadcast();
-      m_waitingFor.clear();
-    }
-
-    bool Wait(cec_opcode opcode, uint32_t iTimeout = CEC_DEFAULT_TRANSMIT_WAIT)
-    {
-      CResponse *response = GetEvent(opcode);
-      return response ? response->Wait(iTimeout) : false;
-    }
-
-    void Received(cec_opcode opcode)
-    {
-      CResponse *response = GetEvent(opcode);
-      if (response)
-        response->Broadcast();
-    }
+    CWaitForResponse(void);
+    ~CWaitForResponse(void);
+
+    void Clear();
+    bool Wait(cec_opcode opcode, uint32_t iTimeout = CEC_DEFAULT_TRANSMIT_WAIT);
+    void Received(cec_opcode opcode);
 
   private:
-    CResponse *GetEvent(cec_opcode opcode)
-    {
-      CResponse *retVal(NULL);
-      {
-        PLATFORM::CLockObject lock(m_mutex);
-        std::map<cec_opcode, CResponse*>::iterator it = m_waitingFor.find(opcode);
-        if (it != m_waitingFor.end())
-        {
-          retVal = it->second;
-        }
-        else
-        {
-          retVal = new CResponse(opcode);
-          m_waitingFor[opcode] = retVal;
-        }
-        return retVal;
-      }
-    }
+    CResponse *GetEvent(cec_opcode opcode);
 
     PLATFORM::CMutex                 m_mutex;
     std::map<cec_opcode, CResponse*> m_waitingFor;