A factory that generates protobuf message based on a string type. This class will also try to load all Protobuf descriptors specified in the GZ_DESCRIPTOR_PATH environment variable on program start. More...
#include <gz/msgs.hh>
Static Public Member Functions | |
static void | LoadDescriptors (const std::string &_paths) |
Load a collection of descriptor .desc files. More... | |
template<typename T > | |
static std::unique_ptr< T > | New (const std::string &_msgType) |
Create a new instance of a message. More... | |
static std::unique_ptr< google::protobuf::Message > | New (const std::string &_msgType) |
Create a new instance of a message. More... | |
template<typename T > | |
static std::unique_ptr< T > | New (const std::string &_msgType, const std::string &_args) |
Create a new instance of a message. More... | |
static std::unique_ptr< google::protobuf::Message > | New (const std::string &_msgType, const std::string &_args) |
Create a new instance of a message. More... | |
static void | Register (const std::string &_msgType, FactoryFn _factoryfn) |
Register a message. More... | |
static void | Types (std::vector< std::string > &_types) |
Get all the message types. More... | |
Detailed Description
A factory that generates protobuf message based on a string type. This class will also try to load all Protobuf descriptors specified in the GZ_DESCRIPTOR_PATH environment variable on program start.
Member Function Documentation
◆ LoadDescriptors()
|
static |
Load a collection of descriptor .desc files.
- Parameters
-
[in] _paths A set of directories containing .desc decriptor files. Each directory should be separated by ":".
◆ New() [1/4]
|
inlinestatic |
Create a new instance of a message.
- Parameters
-
[in] _msgType Type of message to create.
- Returns
- Pointer to a google protobuf message. Null if the message type could not be handled.
References std::endl(), and string::replace().
Referenced by Factory::New().
◆ New() [2/4]
|
static |
Create a new instance of a message.
- Parameters
-
[in] _msgType Type of message to create.
- Returns
- Pointer to a google protobuf message. Null if the message type could not be handled.
◆ New() [3/4]
|
inlinestatic |
Create a new instance of a message.
- Parameters
-
[in] _msgType Type of message to create. [in] _args Message arguments. This will populate the message.
- Returns
- Pointer to a google protobuf message. Null if the message type could not be handled.
References std::endl(), Factory::New(), and string::replace().
◆ New() [4/4]
|
static |
Create a new instance of a message.
- Parameters
-
[in] _msgType Type of message to create. [in] _args Message arguments. This will populate the message.
- Returns
- Pointer to a google protobuf message. Null if the message type could not be handled.
◆ Register()
|
static |
Register a message.
- Parameters
-
[in] _msgType Type of message to register. [in] _factoryfn Function that generates the message.
◆ Types()
|
static |
Get all the message types.
- Parameters
-
[out] _types Vector of strings of the message types.
The documentation for this class was generated from the following file: