#include <messagefactory.h>
Public Member Functions | |
| MessageFactory (const std::string &name, const MachineInfo &machine, const std::string &desc="") | |
| Constructor. | |
| ~MessageFactory () | |
| Destructor. | |
| template<typename T> | |
| void | RegisterMessageType (const MessageType &type) |
| Function in which all supported message types will be registered. | |
| const std::string & | GetName () const |
| Gets the name of the factory. | |
| const std::string & | GetDescription () const |
| Gets the description of the factory. | |
| const MachineInfo & | GetMachineInfo () const |
| Gets the name of the factory. | |
| bool | IsMessageTypeSupported (const MessageType &msg) const |
| Tells is a message type is supported. | |
| void | GetSupportedMessageTypes (std::vector< const MessageType * > &vec) |
| Gets a list of supported types. | |
| const MessageType & | GetMessageTypeById (unsigned short id) const |
| Returns a MessageType for the corresponding id. | |
| const MessageType * | GetMessageTypeByName (const std::string &name) const |
| Returns a MessageType for the corresponding name. | |
| template<typename MessageClassName> | |
| void | CreateMessage (const MessageType &msgType, dtCore::RefPtr< MessageClassName > &result) |
| Creates a message from the factory and fills a passed in refptr. | |
| dtCore::RefPtr< Message > | CreateMessage (const MessageType &msgType) |
| Creates a message from the factory. | |
| dtCore::RefPtr< Message > | CloneMessage (const Message &msg) |
| Make a copy of a message. | |
Classes | |
| class | MessageFactoryException |
| dtGame::MessageFactory::MessageFactory | ( | const std::string & | name, | |
| const MachineInfo & | machine, | |||
| const std::string & | desc = "" | |||
| ) |
Constructor.
| dtGame::MessageFactory::~MessageFactory | ( | ) |
Destructor.
| void dtGame::MessageFactory::RegisterMessageType | ( | const MessageType & | type | ) | [inline] |
Function in which all supported message types will be registered.
| The | type to register |
| const std::string& dtGame::MessageFactory::GetName | ( | ) | const [inline] |
Gets the name of the factory.
| const std::string& dtGame::MessageFactory::GetDescription | ( | ) | const [inline] |
Gets the description of the factory.
| const MachineInfo& dtGame::MessageFactory::GetMachineInfo | ( | ) | const [inline] |
Gets the name of the factory.
| bool dtGame::MessageFactory::IsMessageTypeSupported | ( | const MessageType & | msg | ) | const |
Tells is a message type is supported.
| void dtGame::MessageFactory::GetSupportedMessageTypes | ( | std::vector< const MessageType * > & | vec | ) |
Gets a list of supported types.
| The | vector to fill |
| const MessageType & dtGame::MessageFactory::GetMessageTypeById | ( | unsigned short | id | ) | const |
Returns a MessageType for the corresponding id.
| dtUtil::Exception | with enum MessageFactoryException::TYPE_NOT_REGISTERED if the type is not found. |
| const MessageType * dtGame::MessageFactory::GetMessageTypeByName | ( | const std::string & | name | ) | const |
Returns a MessageType for the corresponding name.
| void dtGame::MessageFactory::CreateMessage | ( | const MessageType & | msgType, | |
| dtCore::RefPtr< MessageClassName > & | result | |||
| ) | [inline] |
Creates a message from the factory and fills a passed in refptr.
This is templated so one can pass in a ref ptr to the actual subclass of dtGame::Message and fill it without having to do a cast outside the method.
| msgType | The type of message to generate | |
| result | A RefPtr to fill with the created message. |
| dtUtil::Exception | if the given message type is not registered. |
| dtCore::RefPtr< Message > dtGame::MessageFactory::CreateMessage | ( | const MessageType & | msgType | ) |
Creates a message from the factory.
This only returns a poiner to a Message. One should use the templated version of the method unless there is no need to have a subclass of Message.
| msgType | The type of message to generate |
| dtUtil::Exception | if the given message type is not registered. |
| dtCore::RefPtr< Message > dtGame::MessageFactory::CloneMessage | ( | const Message & | msg | ) |
Make a copy of a message.
It makes sure the right type is created and then calls the message to copy the data.
| msg | the message to clone | |
| the | clone. |
| dtUtil::Exception | if the message cannot be cloned. |