18 #ifndef _MSGFACTORY_HH_
19 #define _MSGFACTORY_HH_
24 #include <google/protobuf/message.h>
25 #include <boost/shared_ptr.hpp>
34 typedef boost::shared_ptr<google::protobuf::Message> (*MsgFactoryFn) ();
46 public:
static void RegisterMsg(
const std::string &_msgType,
53 public:
static boost::shared_ptr<google::protobuf::Message> NewMsg(
54 const std::string &_msgType);
58 public:
static void GetMsgTypes(std::vector<std::string> &_types);
61 private:
static std::map<std::string, MsgFactoryFn> *msgMap;
70 #define GZ_REGISTER_STATIC_MSG(_msgtype, _classname) \
72 boost::shared_ptr<google::protobuf::Message> New##_classname() \
74 return boost::shared_ptr<gazebo::msgs::_classname>(\
75 new gazebo::msgs::_classname); \
77 class GAZEBO_VISIBLE Msg##_classname \
79 public: Msg##_classname() \
81 gazebo::msgs::MsgFactory::RegisterMsg(_msgtype, New##_classname);\
84 static Msg##_classname GzMsgInitializer;