DataBlock_NData.h

00001 /* START_LICENSE_HEADER
00002 
00003 Copyright (C) 2000 Martin Piper, original design and program code
00004 Copyright (C) 2001 Replica Software
00005 
00006 This program file is copyright (C) Replica Software and can only be used under license.
00007 For more information visit: http://www.replicanet.com/
00008 Or email: info@replicanet.com
00009 
00010 END_LICENSE_HEADER */
00011 #ifndef __DATABLOCK_NDATA_H__
00012 #define __DATABLOCK_NDATA_H__
00013 #include "RNPlatform/Inc/DLLExportAPI.h"
00014 
00015 #include "RNReplicaNet/Inc/DataBlock.h"
00016 #include "RNPlatform/Inc/RegistryManagerMap.h"
00017 
00018 namespace RNReplicaNet
00019 {
00020 
00025 class REPLICANETDLL_API DataBlock_NData : public DataBlock
00026 {
00027 public:
00031     DataBlock_NData();
00032 
00036     virtual ~DataBlock_NData();
00037 
00038     virtual void Poll(DataBlockReason *reason);
00039 
00040     virtual void ParseMessage(MessageHelper *message);
00041 
00048     static DataBlock_NData *Register(void *const data,const int size);
00049 
00055     void RegisterInClassPointer(void *const data,const int size)
00056     {
00057         mData = data;
00058         mSize = size;
00059     }
00060 
00066     void SetDefaultData(const void *data);
00067 
00068     bool IsAttached(void *data);
00069 
00070     void SetEndianTest(const bool test = true);
00071 
00072     bool GetEndianTest(void) const;
00073 
00074 protected:  // User defined DataBlocks have access to these variables.
00075     void *mData;
00076     int mSize;
00077 
00078     struct SessionBlock_NData
00079     {
00080         SessionBlock_NData(int datasize);
00081 
00082         virtual ~SessionBlock_NData();
00083 
00084         void *mTestData;
00085 
00086         // Forced updates
00087         // This works off local time, not network time
00088         float mLastUpdateSentLocalTime;
00089         int mNumForcedUpdates;
00090     };
00091 
00092     RegistryManagerMap<int,SessionBlock_NData> mPerSessionData;
00093 
00094     void *mDefaultData;
00095     bool mDisableEndian;
00096 };
00097 
00098 } // namespace RNReplicaNet
00099 
00100 /* _RO_DO_REGISTERBLOCK_NDATA_VAR macro starts here */
00101 #define _RO_DO_REGISTERBLOCK_NDATA_VAR(x)   \
00102     {\
00103         RNReplicaNet::DataBlock_NData *datablock = 0;   \
00104         datablock = RNReplicaNet::DataBlock_NData::Register(&(basepoint->x),sizeof(basepoint->x));  \
00105         _RO_DO_SETDATABLOCKVARIABLENAME(x);
00106 /* _RO_DO_REGISTERBLOCK_NDATA_VAR macro ends here */
00107 
00108 /* _RO_DO_REGISTERBLOCK_NDATA_VARAT macro starts here */
00109 #define _RO_DO_REGISTERBLOCK_NDATA_VARAT(x) \
00110     {\
00111         RNReplicaNet::DataBlock_NData *datablock = 0;   \
00112         datablock = RNReplicaNet::DataBlock_NData::Register((basepoint->x),sizeof(basepoint->x));   \
00113         _RO_DO_SETDATABLOCKVARIABLENAME(x);
00114 /* _RO_DO_REGISTERBLOCK_NDATA_VARAT macro ends here */
00115 
00116 /* _RO_DO_REGISTERBLOCK_NDATA_DISABLEENDIANTEST macro starts here */
00117 #define _RO_DO_REGISTERBLOCK_NDATA_DISABLEENDIANTEST()  \
00118         datablock->SetEndianTest(false);
00119 /* _RO_DO_REGISTERBLOCK_NDATA_DISABLEENDIANTEST macro ends here */
00120 
00121 
00122 #endif

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