This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial.

Dependencies:  

Dependents:   rosserial_mbed robot_S2

ros/service_server.h

Committer:
nucho
Date:
2011-08-19
Revision:
0:77afd7560544
Child:
1:ff0ec969dad1

File content as of revision 0:77afd7560544:

/*
 * 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_ */