18 #ifndef _MSGFACTORY_HH_
19 #define _MSGFACTORY_HH_
24 #include <google/protobuf/message.h>
25 #include <boost/shared_ptr.hpp>
33 typedef boost::shared_ptr<google::protobuf::Message> (*MsgFactoryFn) ();
45 public:
static void RegisterMsg(
const std::string &_msgType,
52 public:
static boost::shared_ptr<google::protobuf::Message>
NewMsg(
53 const std::string &_msgType);
57 public:
static void GetMsgTypes(std::vector<std::string> &_types);
60 private:
static std::map<std::string, MsgFactoryFn> *msgMap;
69 #define GZ_REGISTER_STATIC_MSG(_msgtype, _classname) \
70 boost::shared_ptr<google::protobuf::Message> New##_classname() \
72 return boost::shared_ptr<gazebo::msgs::_classname>(\
73 new gazebo::msgs::_classname); \
75 class Msg##_classname \
77 public: Msg##_classname() \
79 gazebo::msgs::MsgFactory::RegisterMsg(_msgtype, New##_classname);\
82 static Msg##_classname GzMsgInitializer;