ReplicaNet and RNLobby  1
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DataBlock_NData Class Reference

#include <DataBlock_NData.h>

Inheritance diagram for DataBlock_NData:
Inheritance graph
[legend]
Collaboration diagram for DataBlock_NData:
Collaboration graph
[legend]

Classes

struct  SessionBlock_NData
 

Public Member Functions

 RN_CLASS_MINIMAL_RTTI ()
 
 DataBlock_NData ()
 
virtual ~DataBlock_NData ()
 
virtual void Poll (DataBlockReason *reason, const bool discardOlderIncluded=false, const unsigned int discardOrder=0)
 
virtual void ParseMessage (MessageHelper *message)
 
void RegisterInClassPointer (void *const data, const int size)
 
void SetDefaultData (const void *data)
 
bool IsAttached (void *data)
 
void SetEndianTest (const bool test=true)
 
bool GetEndianTest (void) const
 
virtual void OwnerChanged (const int sessionID)
 
- Public Member Functions inherited from DataBlock
virtual int GetThisClassType (void)
 
 DataBlock ()
 
virtual ~DataBlock ()
 
void SetVariableName (const char *name=0)
 
void BindReplicaNet (ReplicaNet *current)
 
void BindReplicaObject (ReplicaObject *object)
 
void SetReliableFlag (bool reliable=false)
 
bool GetReliableFlag (void) const
 
void SetCertainFlag (bool certain=false)
 
bool GetCertainFlag (void) const
 
void SetOrderedFlag (bool ordered=false)
 
bool GetOrderedFlag (void) const
 
void SetDiscardOlder (const int windowBits=0)
 
int GetDiscardOlder (void) const
 
void SetAutomaticUpdatesFlag (bool automatic=true)
 
bool GetAutomaticUpdatesFlag (void) const
 
virtual void GiveDeltaHint (void *pdata, int dataLen)
 
void GiveDeltaHint (float delta)
 
virtual void ContinuityBreak (unsigned char breakTypes)
 
void SetForceReflectionUpdate (const bool enable=false)
 
bool GetForceReflectionUpdate (void)
 
void SetReflectionMasterUpdate (const bool enable=false)
 
bool GetReflectionMasterUpdate (void)
 
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
 
void SetBand (const unsigned int band=0)
 
unsigned int GetBand (void) const
 
bool ShouldDiscard (MessageHelper *message)
 
bool GetDiscardThisUpdate (void) const
 

Static Public Member Functions

static DataBlock_NDataRegister (void *const data, const int size)
 

Protected Member Functions

void FreeSessionBlocks (void)
 
- Protected Member Functions inherited from DataBlock
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

void * mData
 
int mSize
 
RegistryManagerMap< int,
SessionBlock_NData
mPerSessionData
 
void * mDefaultData
 
bool mDisableEndian
 
- Protected Attributes inherited from DataBlock
short mID
 
ReplicaNetmBoundReplicaNet
 
ReplicaObjectmBoundObject
 
bool mReliable
 
bool mCertain
 
bool mOrdered
 
bool mAutomaticUpdates
 
bool mIsAllocated
 
bool mDebugOn
 
char * mDebugText
 
float mUpdateDelayMinimum
 
int mForceSendMaximumUpdates
 
float mForceSendTimeDelay
 
char * mVariableName
 
unsigned int mBand
 
int mDiscardOlder
 
unsigned int mDiscardOlderMidPoint
 
unsigned int mDiscardOlderEndPoint
 
size_t mDiscardOlderRealSize
 
unsigned int mLocalisedOrderingSent
 
unsigned int mLocalisedOrderingReceived
 
bool mDiscardThisUpdate
 
bool mForceReflectionUpdate
 
bool mReflectionMasterUpdate
 

Additional Inherited Members

- Public Types inherited from DataBlock
enum  ContinuityBreakTypes { kStop = 1, kSuddenChange = 2, kTeleport = 4 }
 

Detailed Description

This DataBlock derived class scans the registered area for changes and if needed creates a packet detailing those changes
This DataBlock does not do any lag compensation or prediction. It just informs each replica of a change when one is made. By default the DataBlock will preserve the endian format of the data. To disable the endian check, an example would be for string data, then SetEndianTest(false) or the ROL command DisableEndianTest();

Constructor & Destructor Documentation

The ctor performs some basic initialisation

virtual ~DataBlock_NData ( )
virtual

The dtor makes sure everything is tidy

Member Function Documentation

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.

virtual void OwnerChanged ( const int  sessionID)
virtual

Called by ReplicaNet to indicate a change in owner. If this virtual method is implemented by a derived class the parent method must also be called.

Reimplemented from DataBlock.

virtual void ParseMessage ( MessageHelper message)
virtual

This parses a message for the derived class of this data block. If this virtual method is implemented by a derived class the parent method should be called. Implementation note: The same amount of data added to the message during the Poll() must equal the length of data retrieved during this function. Care must be taken when implementing functionality such as GetDiscardOlder() to preserve the length of data. 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
messageThe current message buffer that contains the packet data

Reimplemented from DataBlock.

virtual void Poll ( DataBlockReason reason,
const bool  discardOlderIncluded = false,
const unsigned int  discardOrder = 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 the parent 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
reasonthe reason code that is passed in to this class to enable a response to be calculated
discardOlderIncludedWhen true and using SetDiscardOlder() this gives a hint to the DataBlock that the derived class has filled in a valid value for discardOrder. The default value is false and the DataBlock will use a global discard order seqeunce.
discardOrderWhen using SetDiscardOlder() and discardOlderIncluded is true this must contain a valid order sequence number for the update. The sequence should be unique for each target sessionID for the update. Since the sequence number is local for each target sessionID the window size for SetDiscardOlder() can be smaller.

Reimplemented from DataBlock.

static DataBlock_NData* Register ( void *const  data,
const int  size 
)
static

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

Parameters
datathe start of the memory to check
sizethe size of the data block
Returns
Returns a pointer that can be used to attach to a ReplicaObject
void RegisterInClassPointer ( void *const  data,
const int  size 
)
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
datathe start of the memory to check
sizethe size of the data block
void SetDefaultData ( const void *  data)

This allows a block of memory to be passed in that shows a default state of the data block. This default memory state is copied so it can be temporary. When a session joins or an object is created, the datablock states are serialised. By setting a default state the user can avoid the extra data being sent out for the datablock state.

Parameters
datathe pointer to the memory.