Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: rosserial_mbed_lib mbed Servo
Diff: ros/service_server.h
- Revision:
- 0:06fc856e99ca
- Child:
- 1:098e75fd5ad2
diff -r 000000000000 -r 06fc856e99ca ros/service_server.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ros/service_server.h	Fri Aug 19 09:06:16 2011 +0000
@@ -0,0 +1,54 @@
+/*
+ * service_server.h
+ *
+ *  Created on: Aug 5, 2011
+ *      Author: astambler
+ */
+
+
+#ifndef SERVICE_SERVER_H_
+#define SERVICE_SERVER_H_
+
+
+#include "node_output.h"
+
+namespace ros{
+template<typename SrvRequest , typename SrvResponse>
+  class ServiceServer : MsgReceiver{
+  public:
+      typedef void(*CallbackT)(const SrvRequest&,  SrvResponse&);
+
+  private:
+      CallbackT cb_;
+
+  public:
+      ServiceServer(const char* topic_name, CallbackT cb){
+          this->topic_ = topic_name;
+          this->cb_ = cb;
+      }
+
+      ServiceServer(ServiceServer& srv){
+          this->topic_ = srv.topic_;
+          this->cb_ = srv.cb_;
+      }
+      virtual void receive(unsigned char * data){
+          req.deserialize(data);
+          this->cb_(req, resp);
+          no_->publish(id_, &resp);
+      }
+
+    virtual int _getType(){
+        return 3;
+    }
+    virtual const char * getMsgType(){
+        return req.getType();
+    }
+
+      SrvRequest req;
+      SrvResponse resp;
+      NodeOutput_ * no_;
+
+  };
+}
+
+#endif /* SERVICE_SERVER_H_ */