Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

RNReplicaNet::DataBlock Class Reference

#include <DataBlock.h>

Inheritance diagram for RNReplicaNet::DataBlock:

Inheritance graph
[legend]
Collaboration diagram for RNReplicaNet::DataBlock:

Collaboration graph
[legend]
List of all members.

Public Types

enum  ContinuityBreakTypes { kStop = 1, kSuddenChange = 2, kTeleport = 4 }

Public Member Functions

 DataBlock ()
virtual ~DataBlock ()
virtual void Poll (DataBlockReason *reason=0)
virtual void ParseMessage (MessageHelper *message)
void SetVariableName (const char *name=0)
void BindReplicaNet (ReplicaNet *current)
void BindReplicaObject (ReplicaObject *object)
void SetReliableFlag (bool reliable=false)
bool GetReliableFlag (void)
void SetCertainFlag (bool certain=false)
bool GetCertainFlag (void)
void SetAutomaticUpdatesFlag (bool automatic=true)
bool GetAutomaticUpdatesFlag (void)
virtual void GiveDeltaHint (void *pdata, int dataLen)
void GiveDeltaHint (float delta)
virtual void ContinuityBreak (unsigned char breakTypes)
virtual bool IsAttached (void *data)
virtual bool IsAllocated (void) const
void SetIsAllocated (const bool isAllocated=true)
void SetUpdateDelayMinimum (const float delay=0.0f)
float GetUpdateDelayMinimum (void) const
void SetForceSendMaximumUpdates (const int updates=0)
int GetForceSendMaximumUpdates (void) const
void SetForceSendTimeDelay (const float delay=0.0f)
float GetForceSendTimeDelay (void) const

Protected Member Functions

void SetID (int id)
const char * GetROName (ReplicaObject *from=0)
void EmitBaseDebugInfo (const char *name, const char *className, DataBlockReason *reason)
void EmitBaseDebugInfoUpdates (const char *name, const char *className, DataBlockReason *reason)
std::string GetVariableName (void)

Protected Attributes

short mID
ReplicaNetmBoundReplicaNet
ReplicaObjectmBoundObject
bool mReliable
bool mCertain
bool mAutomaticUpdates
bool mIsAllocated
bool mDebugOn
char * mDebugText
float mUpdateDelayMinimum
int mForceSendMaximumUpdates
float mForceSendTimeDelay
char * mVariableName

Friends

class ReplicaObject

Detailed Description

A ReplicaObject derived class can have any number of variables that need to be shared to the corresponding replicas.
A data block is a class that monitors for a change of a specific variable in a master object and if needed creates a data packet that is sent around the session to other replicas.
It is possible for a DataBlock to receive kDataBlockReason_CalculateMasterPoll and kDataBlockReason_ReplicaPrepAfterTakeover, thus allowing a DataBlock to be a master and a replica at the same time and this can allow a DataBlock to reflect propagated values. Each new data type that can get shared across a network creates a new class that inherits from this one


Member Enumeration Documentation

enum RNReplicaNet::DataBlock::ContinuityBreakTypes
 

Enums for the continuity break function

Enumeration values:
kStop  Indicates the data set value has stopped changing for the time being
kSuddenChange  Indicates a sudden change in direction or movement
kTeleport  Indicates the value has a large dislocation i.e. An object has teleported


Constructor & Destructor Documentation

RNReplicaNet::DataBlock::DataBlock  ) 
 

The ctor performs some basic initialisation

virtual RNReplicaNet::DataBlock::~DataBlock  )  [virtual]
 

The dtor makes sure everything is tidy


Member Function Documentation

void RNReplicaNet::DataBlock::BindReplicaNet ReplicaNet current  ) 
 

Bind this data block with the ReplicaNet pointer. This is called from ReplicaObject::RegisterDataBlock()

Parameters:
current the ReplicaNet pointer

void RNReplicaNet::DataBlock::BindReplicaObject ReplicaObject object  ) 
 

Bind this data block with the ReplicaObject pointer. This is called from ReplicaObject::RegisterDataBlock()

Parameters:
current the ReplicaObject pointer

virtual void RNReplicaNet::DataBlock::ContinuityBreak unsigned char  breakTypes  )  [virtual]
 

This is used to set a continuity break for the data set and provides useful information to the extrapolation algorithm

Parameters:
breakTypes The break types to use for this break. For example : DataBlock::ContinuityBreakTypes::kSuddenChange | DataBlock::ContinuityBreakTypes::kTeleport

Reimplemented in RNReplicaNet::DataBlock_Predict_Float.

bool RNReplicaNet::DataBlock::GetAutomaticUpdatesFlag void   ) 
 

Gets the automatic update flag for a particular data set

Returns:
if this data block is meant to be automatically updated true is returned

bool RNReplicaNet::DataBlock::GetCertainFlag void   ) 
 

Gets the reliable flag for a particular data set

Returns:
if this data block is meant to be reliable true is returned

int RNReplicaNet::DataBlock::GetForceSendMaximumUpdates void   )  const
 

This function returns the value set by SetUpdateDelayMaximum()

Returns:
The value.

float RNReplicaNet::DataBlock::GetForceSendTimeDelay void   )  const
 

This function returns the value set by SetUpdateDelayMaximum()

Returns:
The value.

bool RNReplicaNet::DataBlock::GetReliableFlag void   ) 
 

Gets the reliable flag for a particular data set

Returns:
if this data block is meant to be reliable true is returned

float RNReplicaNet::DataBlock::GetUpdateDelayMinimum void   )  const
 

This function returns the value set by SetUpdateDelayMinimum()

Returns:
The value.

void RNReplicaNet::DataBlock::GiveDeltaHint float  delta  )  [inline]
 

This is a feedback function that enables an application to give a delta hint to a DataBlock. This float type call maps to the opaque data type call

Parameters:
This delta hint is a float type

Reimplemented in RNReplicaNet::DataBlock_Predict_Float.

virtual void RNReplicaNet::DataBlock::GiveDeltaHint void *  pdata,
int  dataLen
[virtual]
 

This is a feedback function that enables an application to give a delta hint to a DataBlock

Parameters:
pdata the pointer to the data type to give a hint for
dataLem the length of the data type

Reimplemented in RNReplicaNet::DataBlock_Predict_Float.

virtual bool RNReplicaNet::DataBlock::IsAllocated void   )  const [virtual]
 

This virtual function allows the DataBlock to say how is was allocated.

Returns:
Returns true if the DataBlock was allocated using 'new' as a pointer returned.

virtual bool RNReplicaNet::DataBlock::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 in RNReplicaNet::DataBlock_Function, RNReplicaNet::DataBlock_NData, and RNReplicaNet::DataBlock_Predict_Float.

virtual void RNReplicaNet::DataBlock::ParseMessage MessageHelper *  message  )  [virtual]
 

This parses a message for the derived class of this data block

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

Reimplemented in RNReplicaNet::DataBlock_Function, RNReplicaNet::DataBlock_NData, and RNReplicaNet::DataBlock_Predict_Float.

virtual void RNReplicaNet::DataBlock::Poll DataBlockReason reason = 0  )  [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.

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

Reimplemented in RNReplicaNet::DataBlock_Function, RNReplicaNet::DataBlock_NData, and RNReplicaNet::DataBlock_Predict_Float.

void RNReplicaNet::DataBlock::SetAutomaticUpdatesFlag bool  automatic = true  ) 
 

Sets the automatic update flag for a particular data set. By default a datablock will calculate the best time to create an update for a particular set of data. If the automatic updates are switched off then the datablock relies on hints from the user to calculate updates.

Parameters:
automatic set to true if this data block is meant to be automatically updated. The default is true

void RNReplicaNet::DataBlock::SetCertainFlag bool  certain = false  ) 
 

Sets the certain flag for a particular data set

Parameters:
certain set to true if this data block is meant to be certain and the reliable update is set to be false. The default is false

void RNReplicaNet::DataBlock::SetForceSendMaximumUpdates const int  updates = 0  ) 
 

This sets the maximum number of consecutive force updates that can be sent from this DataBlock to each ReplicaObject. Forced updates are sent for this DataBlock to a ReplicaObject if the time since the last update, either due to the update filter policy or due to a forced update, is greater than the time set by SetForceSendTimeDelay(). Usually the best possible approximation of the DataBlock change calculated at the time is used. If a normal DataBlock update is sent, in other words an update falls within the DataBlock update filter policy, then the trigger for forced updates is set allowing consecutive forced updates to be started. This feature is useful for unreliable updates where DataBlocks that do not change often usually causing fewer DataBlock updates can be refreshed or force updated. It is a good idea, but not required, to set SetForceSendTimeDelay() before setting this value to be anything greater than 0 because the default value of 0.0f for SetForceSendTimeDelay() could cause many quick consecutive updates to be sent. This can be changed by the user at any time. The default value is 0 which disables this mechanism. The actual mechanism is implemented by the derived DataBlock. For user extended DataBlocks this mechanism can be ignored if the DataBlock filter policy method does not require this functionality.

void RNReplicaNet::DataBlock::SetForceSendTimeDelay const float  delay = 0.0f  ) 
 

This sets a time delay from the previous DataBlock update to a ReplicaObject before another forced send update is required. Setting this to be 0.2f causes a forced send update to be sent if the time since the last DataBlock update is more than 0.2f seconds. Therefore if SetForceSendTimeDelay(0.3f) and SetForceSendMaximumUpdates(3) is used, then a DataBlock that stops changing will get 3 extra updates with a delay of 0.3f of a second between each update. This setting for forced updates overrides the SetUpdateDelayMaximum() setting. This can be changed by the user at any time. The default value is 0.0f which then causes delays to be sent every internal ReplicaNet poll as required by SetMaximumForceSendUpdates() The actual mechanism is implemented by the derived DataBlock. For user extended DataBlocks this mechanism can be ignored if the DataBlock filter policy method does not require this functionality.

void RNReplicaNet::DataBlock::SetID int  id  )  [protected]
 

This sets the ID of the data block when it is used in a ReplicaObject. This function is called from ReplicaObject::RegisterDataBlock()

void RNReplicaNet::DataBlock::SetIsAllocated const bool  isAllocated = true  ) 
 

Defines how the DataBlock was allocated.

Parameters:
isAllocated Set this to be true is the DataBlock was allocated by using 'new' and a pointer returned. This is the default value.

void RNReplicaNet::DataBlock::SetReliableFlag bool  reliable = false  ) 
 

Sets the reliable flag for a particular data set

Parameters:
reliable set to true if this data block is meant to be reliable and the certain update is set to be false. The default is false

void RNReplicaNet::DataBlock::SetUpdateDelayMinimum const float  delay = 0.0f  ) 
 

This sets the minimum possible delay between each update, due to a DataBlock filter condition being met, for this datablock to each ReplicaObject. This allows the bandwidth for this DataBlock to be fine tuned. A value of 1.0f will mean a maximum of 1 update per second to each ReplicaObject. A value of 0.2f will mean a maximum possible 5 updates due to filter conditions per second, one every 0.2 seconds, to each ReplicaObject. This setting is separate from SetForceSendTimeDelay() This can be changed by the user at any time. The default value is 0.0f which disables this mechanism. The actual mechanism is implemented by the derived DataBlock. For user extended DataBlocks this mechanism can be ignored if the DataBlock filter policy method does not require this functionality.

Parameters:
delay The minimum delay in seconds.

void RNReplicaNet::DataBlock::SetVariableName const char *  name = 0  ) 
 

Sets the name of the variable attached to this DataBlock which is then used to output extended debugging information using the registered DebugHandler if available. The default value for the variable name is null. This function is used by ReplicaNet and the standard DataBlocks added to objects using the ROL Language if the preprocessor define REPLICANET_VISUALDEBUGGER is used. For user allocated DataBlocks this function can be used to set extra debugging information, such as the variable name, useful to the author. Each DataBlock implementation can choose to not output debug information if there is no name set. The standard DataBlocks included with ReplicaNet output the DataBlock class name with a unique hex number identifier prefixed with "<Unknown>" if the variable name is null.

Parameters:
name The name of the variable.


The documentation for this class was generated from the following file:
Generated on Sun Oct 30 01:11:56 2005 for ReplicaNet by  doxygen 1.4.1