[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
#include <dpl/raw-buffer.h>
#include <ckm/ckm-type.h>
#include <credentials.h>
#include <dpl/raw-buffer.h>
#include <ckm/ckm-type.h>
#include <credentials.h>
+#include <service-messages.h>
extern "C" {
struct msghdr;
extern "C" {
struct msghdr;
virtual void SetSocketManager(GenericSocketManager *manager) {
m_serviceManager = manager;
}
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;
virtual ServiceDescriptionVector GetServiceDescription() = 0;
virtual void Event(const AcceptEvent &event) = 0;
virtual void Start() = 0;
virtual void Stop() = 0;
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;
virtual ~GenericSocketService(){}
protected:
GenericSocketManager *m_serviceManager;
};
struct GenericSocketManager {
};
struct GenericSocketManager {
void Start() {}
void Stop() {}
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 {
};
struct SignalService : public GenericSocketService {
void Start() {}
void Stop() {}
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");
void Event(const ReadEvent &event) {
LogDebug("Get signal information");
void SocketManager::RegisterSocketService(GenericSocketService *service) {
service->SetSocketManager(this);
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)
auto serviceVector = service->GetServiceDescription();
Try {
for (auto iter = serviceVector.begin(); iter != serviceVector.end(); ++iter)
#include <dpl/exception.h>
#include <generic-socket-manager.h>
#include <dpl/exception.h>
#include <generic-socket-manager.h>
+#include <service-messages.h>
int m_notifyMe[2];
int m_counter;
std::priority_queue<Timeout> m_timeoutQueue;
int m_notifyMe[2];
int m_counter;
std::priority_queue<Timeout> m_timeoutQueue;
protected:
virtual bool ProcessOne(const ConnectionID &conn,
ConnectionInfo &info) = 0;
protected:
virtual bool ProcessOne(const ConnectionID &conn,
ConnectionInfo &info) = 0;
template <typename E>
void ThreadEvent(const E& event) {
CreateEvent([this, event]() { this->Handle(event); });
}
template <typename E>
void ThreadEvent(const E& event) {
CreateEvent([this, event]() { this->Handle(event); });
}
void Handle(const AcceptEvent &event);
void Handle(const WriteEvent &event);
void Handle(const AcceptEvent &event);
void Handle(const WriteEvent &event);