23 #ifndef SUBSCRIPTION20110412H 24 #define SUBSCRIPTION20110412H 26 #include <boost/function.hpp> 27 #include <boost/shared_ptr.hpp> 28 #include <google/protobuf/descriptor.h> 29 #include <google/protobuf/dynamic_message.h> 40 virtual void post(
const std::string& body) = 0;
42 virtual const std::string& type_name()
const = 0;
43 virtual const std::string& group()
const = 0;
44 virtual bool has_valid_handler()
const = 0;
53 typedef boost::function<void(const ProtoBufMessage&)> HandlerType;
55 Subscription(HandlerType& handler,
const std::string& type_name,
const std::string& group =
"")
56 : handler_(handler), type_name_(type_name), group_(group)
62 void post(
const std::string& body)
64 newest_msg_.ParseFromString(body);
66 handler_(newest_msg_);
71 const std::string& type_name()
const {
return type_name_; }
72 const std::string& group()
const {
return group_; }
73 bool has_valid_handler()
const {
return handler_; }
77 ProtoBufMessage newest_msg_;
78 const std::string type_name_;
79 const std::string group_;
The global namespace for the Goby project.