Main Page   Modules   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

GNE::ObjectBrokerClient Class Reference
[High-Level API]

#include <ObjectBrokerClient.h>

Inheritance diagram for GNE::ObjectBrokerClient:

GNE::ObjectBroker List of all members.

Public Member Functions

 ObjectBrokerClient ()
 Default ctor.

 ~ObjectBrokerClient ()
 Default dtor.

NetworkObjectusePacket (const Packet &packet, bool ignoreUpdateError)
NetworkObjectusePacket (const Packet &packet)
 Calls usePacket( const Packet&, bool ) with the second parameter as being false, thus this method always returns a valid NetworkObject reference, or throws an exception.


Static Public Member Functions

void registerObject (guint8 id, ObjCreationFunc createFunc)
 Registers a new object type with the ObjectBrokerClient by relating a packet ID with a function that creates a NetworkObject.


Friends

bool GNE::initGNE (NLenum, int(*)(void(*)(void)), int)

Detailed Description

The ObjectBrokerClient takes packets generated from the ObjectBrokerServer and manages the object creations, updates, and deletes specified. All methods in ObjectBrokerClient are thread safe.


Member Function Documentation

void GNE::ObjectBrokerClient::registerObject guint8  id,
ObjCreationFunc  createFunc
[static]
 

Registers a new object type with the ObjectBrokerClient by relating a packet ID with a function that creates a NetworkObject.

This is similar to PacketParser::registerPacket.

While it is intended that a single creation function associated with a packet ID returns always the same type of object, this is by no means a requirement of the creation function -- it may return different subclasses of NetworkObjects different times it is called. This can be useful if the same packet type might describe a few very similar types of objects, or if there are more types of objects than there exist packet IDs.

Parameters:
id the Packet ID of a packet which has all of the needed information to create some NetworkObject.
createFunc the function which returns a new NetworkObject instance given a packet of the type specified by the id parameter, and an objectId. The create function must assign the given objectId to the object when it creates it.

NetworkObject * GNE::ObjectBrokerClient::usePacket const Packet packet,
bool  ignoreUpdateError
 

If the passed packet is an ObjectCreationPacket, a new object is created with the registered create function and returned. If an object with the ID already exists, then an Error is thrown with code Error::DuplicateObjectID. If the packet type used to create the object has not been registered, then an Error with the ID Error::InvalidCreationPacketType is thrown.

If the passed packet is an ObjectUpdatePacket, the specified object is given the packet to update itself with, and that object is returned. If no objects with the ID in the packet exist, an Error is thrown with code Error::UnknownObjectId. If ignoreUpdateError is set to true, then NULL instead is returned, and no action is taken on the packet. This particular flag is useful, because if updates are sent unreliably, then it is possible for an update for an object to arrive BEFORE its creation packet.

If the passed packet is an ObjectDeathPacket, the specified object's incomingDeathPacket and onDeregistration events are called, and that object is returned. If no objects with the ID in the packet exist, an Error is thrown with code Error::UnknownObjectId.

If the passed packet is not any one of these types, then an Error with code Error::InvalidObjectPacket is thrown.

In all cases, either a valid NetworkObject is returned, or an Error is thrown. The single exception is that NULL can be returned if ignoreUpdateError is passed as true, and ObjectUpdatePacket processing failed because of an unknown packet ID, which should be the only typical error case.


The documentation for this class was generated from the following files:
Generated on Fri Aug 22 13:40:06 2003 for GNE by doxygen1.3