DataBlock_Function Class Reference

#include <DataBlock_Function.h>

Inheritance diagram for DataBlock_Function:

Inheritance graph
[legend]
Collaboration diagram for DataBlock_Function:

Collaboration graph
[legend]

List of all members.

Public Types

typedef void( tDataBlock_Function_funcp )(void *classp, void *data)

Public Member Functions

 DataBlock_Function ()
virtual ~DataBlock_Function ()
virtual void Poll (DataBlockReason *reason)
virtual void ParseMessage (MessageHelper *message)
void RegisterInClassPointer (void *classp, tDataBlock_Function_funcp *funcp)
void AddFunctionStateChange (void *data, int len, const char *debug=0)
bool IsAttached (void *data)

Static Public Member Functions

static
DataBlock_Function
Register (void *classp, tDataBlock_Function_funcp *funcp)
static void SetSessionIDFilter (const int numSessionIDs=0, const int *sessionIDs=0)

Protected Attributes

void * mClassp
tDataBlock_Function_funcp * mData
RegistryManagerMap
< int,
SessionBlock_Function > 
mPerSessionFunction
std::list
< CombinedDataPacket * > 
mFunctionStateChanges

Static Protected Attributes

static int mConfiguredNumSessions
static int * mConfiguredSessionIDs


Detailed Description

This DataBlock derived class enables class member functions to be called on replicas of an object. Deleting a ReplicaObject derived class during a networked function call is not allowed. ReplicaObject::DelayedDelete() should be used instead. This will flag the object for a delete as soon as it is safe to do so.
This DataBlock does not do any latency compensation or prediction.
This DataBlock does not use the rules set by SetUpdateDelayMinimum() and SetForceSendMaximumUpdates() because the frequency of calling member functions and hence the frequency of DataBlock updates is defined by the application.
For security reasons only the master can send function calls to other replicas. A replica does not send any function updates to other replicas directly and will only send to the master. Therefore many of the macros, like ALL_REPLICAS_FUNCTION_CALL(), will operate differently depending on if the object is a master or a replica.
Before the object is published no network class member function calls will be propagated. Using these macros with an unpublished object will only cause the non-network portion to be executed, for example GLOBAL_FUNCTION_CALL will only call the function on the object.
You can use these macros to call network class member functions:
GLOBAL_FUNCTION_CALL()
Example: GLOBAL_FUNCTION_CALL(ASampleMemberFunction(foo,bar,wibble));
From a master this calls the function on the master and all replicas.
From a replica this only calls the function on the current replica and the master.

ALL_REPLICAS_FUNCTION_CALL()
Example: ALL_REPLICAS_FUNCTION_CALL(ASampleMemberFunction(foo));
From a master this calls the function on all replicas.
From a replica this only calls the function on the master.

MASTER_FUNCTION_CALL()
Example: MASTER_FUNCTION_CALL(ASampleMemberFunction(bar,wibble));
From a master this calls the function on all replicas.
From a replica this only calls the function on the master.
ALL_REPLICAS_FUNCTION_CALL() and MASTER_FUNCTION_CALL() have identical implementation, the naming is different to improve code readability.

NOMINATED_REPLICAS_FUNCTION_CALL()
Example: NOMINATED_REPLICAS_FUNCTION_CALL(numSessionIDs,sessionIDs,APublicFunction(random_int,random_float));
From a master this uses DataBlock_Function::SetSessionIDFilter() to propagate function calls to selected session IDs. From a replica this calls the function on the master regardless of the session ID list.

Constructor & Destructor Documentation

DataBlock_Function (  ) 

The ctor performs some basic initialisation

virtual ~DataBlock_Function (  )  [virtual]

The dtor makes sure everything is tidy


Member Function Documentation

virtual void Poll ( DataBlockReason reason  )  [virtual]

A poll function that is called by ReplicaNet to check for updates to this particular data block. If this virtual method is implemented by a derived class this base class method should be called before a data packet is created. Processing for this function may occur during the thread context of ReplicaNet so processing time used by this function should be kept to a minimum to avoid performance issues.

Parameters:
reason the reason code that is passed in to this class to enable a response to be calculated

Reimplemented from DataBlock.

virtual void ParseMessage ( MessageHelper message  )  [virtual]

This parses a message for the derived class of this data block. Processing for this function may occur during the thread context of ReplicaNet so processing time used by this function should be kept to a minimum to avoid performance issues.

Parameters:
message The current message buffer that contains the packet data

Reimplemented from DataBlock.

static DataBlock_Function* Register ( void *  classp,
tDataBlock_Function_funcp *  funcp 
) [static]

This registers the memory area with this data block type and returns a new pointer

Parameters:
classp is the pointer to this class that is passed through the message pipeline
funcp the actual function pointer to call that cracks the message
Returns:
Returns a pointer that can be used to attach to a ReplicaObject

void RegisterInClassPointer ( void *  classp,
tDataBlock_Function_funcp *  funcp 
) [inline]

This registers the memory area with this data block type. This is used when the memory is in datablocks that are allocated as part of a bigger class.

Parameters:
classp is the pointer to this class that is passed through the message pipeline
funcp the actual function pointer to call that cracks the message

static void SetSessionIDFilter ( const int  numSessionIDs = 0,
const int *  sessionIDs = 0 
) [static]

This configures the next networked function call from a master object to send the function call to the nominated sessionIDs. After the function call is completed all subsequent network function calls are sent without this filter unless this function is used. The NOMINATED_REPLICAS_FUNCTION_CALL() macro also uses this function.
Care must be taken when using this static function that multi-threaded ReplicaObject derived classes do not interrupt calls to this function and the subsequent network function call. The array pointed to by this function must persist until the subsequent network function call.

Parameters:
numSessionIDs The number of session IDs in the array.
sessionIDs An array of session IDs that will receive the next network function call.

bool IsAttached ( void *  data  )  [virtual]

Given a data pointer this function identifies if this data block is attached to the pointer.

Returns:
returns true if the data pointer is attached to this data block.

Reimplemented from DataBlock.


Generated on Sat Jun 28 22:02:21 2008 for ReplicaNet and RNLobby by  doxygen 1.5.3