A factory that generates protobuf message based on a string type. This allows for global registration of messages via static initialization. If you don't need the singleton, consider using MessageFactory instead. More...
#include <gz/msgs.hh>
Public Types | |
using | FactoryFn = MessageFactory::FactoryFn |
Function that returns unique pointer to base message type. More... | |
using | FactoryFnCollection = MessageFactory::FactoryFnCollection |
A map of message types as strings to factory functions. More... | |
using | MessagePtr = MessageFactory::MessagePtr |
Unique pointer to base message type. More... | |
Public Member Functions | |
Factory (const Factory &)=delete | |
Deleted copy constructor. More... | |
Factory (Factory &&)=delete | |
Deleted move constructor. More... | |
void | operator= (const Factory &)=delete |
Deleted copy assignment. More... | |
void | operator= (Factory &&)=delete |
Deleted move assignment. More... | |
Static Public Member Functions | |
static MessageFactory & | Instance () |
Get the global MessageFactory instance. More... | |
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 MessagePtr | 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 MessagePtr | 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 allows for global registration of messages via static initialization. If you don't need the singleton, consider using MessageFactory instead.
Member Typedef Documentation
◆ FactoryFn
using FactoryFn = MessageFactory::FactoryFn |
Function that returns unique pointer to base message type.
◆ FactoryFnCollection
A map of message types as strings to factory functions.
◆ MessagePtr
using MessagePtr = MessageFactory::MessagePtr |
Unique pointer to base message type.
Constructor & Destructor Documentation
◆ Factory() [1/2]
◆ Factory() [2/2]
Member Function Documentation
◆ Instance()
|
static |
Get the global MessageFactory instance.
- Returns
- Reference to the global MessageFactory instance
Referenced by Factory::New().
◆ 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 Factory::Instance(), and MessageFactory::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 Factory::Instance(), and MessageFactory::New().
◆ 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.
◆ operator=() [1/2]
|
delete |
Deleted copy assignment.
◆ operator=() [2/2]
|
delete |
Deleted move assignment.
◆ 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: