Package legume :: Package udp :: Module messages :: Class MessageFactory
[frames] | no frames]

type MessageFactory

object --+
         |
        MessageFactory

Instance Methods
 
__init__(self)
 
add(self, *message_classes)
Add message class(es) to the message factory.
 
getById(self, id)
Obtain a message class by specifying the packets MessageTypeID.
 
getByName(self, name)
Obtain a message class by specifying the packets name.
 
isA(self, message_instance, message_name)
Determine if message_instance is an instance of the named message class.
Method Details

__init__(self)
(Constructor)

 
Overrides: object.__init__
(inherited documentation)

add(self, *message_classes)

 

Add message class(es) to the message factory. The parameters to this method must be subclasses of BaseMessage.

A MessageError will be raised if a message already exists in this factory with an identical name or MessageTypeID.

getById(self, id)

 
Obtain a message class by specifying the packets MessageTypeID. If the message cannot be found a MessageError exception is raised.

getByName(self, name)

 
Obtain a message class by specifying the packets name. If the message cannot be found a MessageError exception is raised.

isA(self, message_instance, message_name)

 

Determine if message_instance is an instance of the named message class.

Example: >>> tp = TestPacket1() >>> message_factory.isA(tp, 'TestPacket1') True