Go to the documentation of this file.
17 #ifndef IGNITION_MSGS_FACTORY_HH_
18 #define IGNITION_MSGS_FACTORY_HH_
22 #pragma warning(disable: 4100 4512 4127 4068 4244 4267 4251 4146)
24 #include <google/protobuf/message.h>
57 public:
static void Register(
const std::string &_msgType,
64 public:
template<
typename T>
68 static_cast<T*
>(New(_msgType).release()));
76 public:
template<
typename T>
81 static_cast<T*
>(New(_msgType, _args).release()));
106 public:
static void LoadDescriptors(
const std::string &_paths);
117 #define IGN_REGISTER_STATIC_MSG(_msgtype, _classname) \
118 IGNITION_MSGS_VISIBLE \
119 std::unique_ptr<google::protobuf::Message> New##_classname() \
121 return std::unique_ptr<ignition::msgs::_classname>(\
122 new ignition::msgs::_classname); \
124 class IGNITION_MSGS_VISIBLE IgnMsg##_classname \
126 public: IgnMsg##_classname() \
128 ignition::msgs::Factory::Register(_msgtype, New##_classname);\
131 static IgnMsg##_classname IgnitionMessagesInitializer;
static void Register(const std::string &_msgType, FactoryFn _factoryfn)
Register a message.
static void Types(std::vector< std::string > &_types)
Get all the message types.
std::unique_ptr< google::protobuf::Message >(* FactoryFn)()
Prototype for message factory generation.
Definition: Factory.hh:46
A factory that generates protobuf message based on a string type. This class will also try to load al...
Definition: Factory.hh:52
static std::unique_ptr< T > New(const std::string &_msgType)
Create a new instance of a message.
Definition: Factory.hh:65
static void LoadDescriptors(const std::string &_paths)
Load a collection of descriptor .desc files.
#define IGNITION_MSGS_VERSION_NAMESPACE
Definition: config.hh:11
static std::unique_ptr< T > New(const std::string &_msgType, const std::string &_args)
Create a new instance of a message.
Definition: Factory.hh:77