Add support for inter-service communication in SocketManager 99/41799/8
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Wed, 17 Jun 2015 11:12:39 +0000 (13:12 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 26 Jun 2015 11:42:21 +0000 (04:42 -0700)
[Feature] Inter-service communication development.
[Solution] Add CommunicationManager basing on existing messages to
SocketManager. Set communication manager in services.

[Verification] Successfull compilation. Run ckm-tests --output.

Change-Id: Ic22b3496f7f40a424cec4794513cec9211a752d1

src/manager/main/generic-socket-manager.h
src/manager/main/socket-manager.cpp
src/manager/main/socket-manager.h
src/manager/main/thread-service.h

index 4108c3b..bec21c6 100644 (file)
@@ -36,6 +36,7 @@
 #include <dpl/raw-buffer.h>
 #include <ckm/ckm-type.h>
 #include <credentials.h>
+#include <service-messages.h>
 
 extern "C" {
 struct msghdr;
@@ -100,6 +101,9 @@ struct GenericSocketService {
     virtual void SetSocketManager(GenericSocketManager *manager) {
         m_serviceManager = manager;
     }
+    virtual void SetCommManager(CommMgr *manager) {
+        m_commMgr = manager;
+    }
 
     virtual ServiceDescriptionVector GetServiceDescription() = 0;
     virtual void Event(const AcceptEvent &event) = 0;
@@ -110,10 +114,11 @@ struct GenericSocketService {
     virtual void Start() = 0;
     virtual void Stop() = 0;
 
-    GenericSocketService() : m_serviceManager(NULL) {}
+    GenericSocketService() : m_serviceManager(NULL), m_commMgr(NULL) {}
     virtual ~GenericSocketService(){}
 protected:
     GenericSocketManager *m_serviceManager;
+    CommMgr *m_commMgr;
 };
 
 struct GenericSocketManager {
index 4a5e147..44a7d3c 100644 (file)
@@ -94,10 +94,10 @@ struct DummyService : public GenericSocketService {
     void Start() {}
     void Stop() {}
 
-    void Event(const AcceptEvent &event) { (void)event; }
-    void Event(const WriteEvent &event) { (void)event; }
-    void Event(const ReadEvent &event) { (void)event; }
-    void Event(const CloseEvent &event) { (void)event; }
+    void Event(const AcceptEvent &) {}
+    void Event(const WriteEvent &) {}
+    void Event(const ReadEvent &) {}
+    void Event(const CloseEvent &) {}
 };
 
 struct SignalService : public GenericSocketService {
@@ -118,9 +118,9 @@ struct SignalService : public GenericSocketService {
     void Start() {}
     void Stop() {}
 
-    void Event(const AcceptEvent &event) { (void)event; } // not supported
-    void Event(const WriteEvent &event) { (void)event; }  // not supported
-    void Event(const CloseEvent &event) { (void)event; }  // not supported
+    void Event(const AcceptEvent &) {} // not supported
+    void Event(const WriteEvent &) {}  // not supported
+    void Event(const CloseEvent &) {}  // not supported
 
     void Event(const ReadEvent &event) {
         LogDebug("Get signal information");
@@ -564,6 +564,7 @@ void SocketManager::CreateDomainSocket(
 
 void SocketManager::RegisterSocketService(GenericSocketService *service) {
     service->SetSocketManager(this);
+    service->SetCommManager(&m_commMgr);
     auto serviceVector = service->GetServiceDescription();
     Try {
         for (auto iter = serviceVector.begin(); iter != serviceVector.end(); ++iter)
index 978dbee..5dbffdc 100644 (file)
@@ -35,6 +35,7 @@
 #include <dpl/exception.h>
 
 #include <generic-socket-manager.h>
+#include <service-messages.h>
 
 namespace CKM {
 
@@ -119,6 +120,7 @@ protected:
     int m_notifyMe[2];
     int m_counter;
     std::priority_queue<Timeout> m_timeoutQueue;
+    CommMgr m_commMgr;
 };
 
 } // namespace CKM
index 2a4cadb..e8f0ac6 100644 (file)
@@ -43,11 +43,12 @@ public:
 protected:
     virtual bool ProcessOne(const ConnectionID &conn,
                             ConnectionInfo &info) = 0;
-private:
+
     template <typename E>
     void ThreadEvent(const E& event) {
         CreateEvent([this, event]() { this->Handle(event); });
     }
+private:
 
     void Handle(const AcceptEvent &event);
     void Handle(const WriteEvent &event);