Pingable.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "config.h"
00031
00032 #include "Pingable.hpp"
00033
00034 #include <EntityDescription.hpp>
00035
00036 #include <iostream>
00037
00038
00039 using namespace mermaid::support::service;
00040
00041 void Pingable::attachToService (shared_ptr<Service> service)
00042 {
00043 std::string serviceInstanceName = service->getServiceInstanceDescription()->getServiceInstanceName();
00044 std::string entityName = service->getServiceInstanceDescription()->getEntityDescription()->getEntityName();
00045
00046 std::cerr << "Attaching default \"Pingable\" service type implementation to " << entityName << "::" << serviceInstanceName << std::endl;
00047
00048
00049 shared_ptr<ServiceInterfaceHandlerMethodBase> pingHandlerMethod (new ServiceInterfaceHandlerMethod<Pingable> (this, &Pingable::pingHandler));
00050 service->registerServiceInterfaceHandlerMethod ("ping", pingHandlerMethod);
00051
00052 }
00053
00054 void Pingable::pingHandler (shared_ptr<ServiceRequest> request, shared_ptr<ServiceReply> reply)
00055 {
00056 int number = request->getRequestDataBox()->getInteger ("number");
00057 reply->getReplyDataBox()->setInteger ("number", number);
00058 };