listener_helper.h
Go to the documentation of this file.
1 
23 #ifndef LISTENER_HELPER_H_
24 #define LISTENER_HELPER_H_
25 
26 #include <iostream>
27 #include <boost/function.hpp>
29 #include "micros_swarm/serialize.h"
30 
31 namespace micros_swarm{
32 
34  public:
35  virtual void call(const std::vector<uint8_t>& value_vec)=0;
36  };
37 
38  template<typename Type>
40  public:
41  ListenerHelperT(const std::string& key, const boost::function<void(const Type&)>& callback)
42  {
43  key_ = key;
44  callback_ = callback;
45  }
46 
47  virtual void call(const std::vector<uint8_t>& value_vec)
48  {
49  callback_(convertType(value_vec));
50  }
51 
52  Type convertType(const std::vector<uint8_t>& value_vec)
53  {
54  Type value = deserialize_ros<Type>(value_vec);
55  return value;
56  }
57 
58  private:
59  boost::function<void(const Type&)> callback_;
60  std::string key_;
61  };
62 };
63 #endif
Type convertType(const std::vector< uint8_t > &value_vec)
boost::function< void(const Type &)> callback_
virtual void call(const std::vector< uint8_t > &value_vec)
ListenerHelperT(const std::string &key, const boost::function< void(const Type &)> &callback)
virtual void call(const std::vector< uint8_t > &value_vec)=0


micros_swarm
Author(s):
autogenerated on Mon Jun 10 2019 14:02:06