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

DataBlock_Function.h

00001 /* START_LICENSE_HEADER
00002 
00003 Copyright (C) 2000 Martin Piper, original design and program code
00004 Copyright (C) 2001-2005 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_FUNCTION_H__
00012 #define __DATABLOCK_FUNCTION_H__
00013 #include "RNPlatform/Inc/DLLExportAPI.h"
00014 
00015 #include "RNReplicaNet/Inc/DataBlock.h"
00016 #include "RNPlatform/Inc/MessageHelper.h"
00017 #include <list>
00018 
00019 namespace RNReplicaNet
00020 {
00021 
00022 struct CombinedDataPacket;
00023 struct SessionBlock_Function;
00024 
00049 class REPLICANETDLL_API DataBlock_Function : public DataBlock
00050 {
00051 public:
00055     DataBlock_Function();
00056 
00060     virtual ~DataBlock_Function();
00061 
00062     virtual void Poll(DataBlockReason *reason);
00063 
00064     virtual void ParseMessage(MessageHelper *message);
00065 
00072     static DataBlock_Function *Register(void *classp,void *funcp);
00073 
00079     void RegisterInClassPointer(void *classp,void *funcp)
00080     {
00081         mClassp = classp;
00082         mData = funcp;
00083     }
00084 
00091     static void SetSessionIDFilter(const int numSessionIDs = 0,const int *sessionIDs = 0);
00092 
00093     void AddFunctionStateChange(void *data,int len,const char *debug = 0);
00094 
00095     bool IsAttached(void *data);
00096 
00097 private:
00098     void *mClassp;
00099     void *mData;
00100 
00101     std::list<SessionBlock_Function *> mPerSessionFunction;
00102 
00103     std::list<CombinedDataPacket *> mFunctionStateChanges;
00104 
00105     static int mConfiguredNumSessions;
00106     static int *mConfiguredSessionIDs;
00107 };
00108 
00109 } // namespace RNReplicaNet
00110 
00111 
00112 /* _RO_DO_REGISTERBLOCK_FUNCTION_VAR macro starts here */
00113 #define _RO_DO_REGISTERBLOCK_FUNCTION_VAR(x)    \
00114     {\
00115         RNReplicaNet::DataBlock_Function *datablock = 0;    \
00116         datablock = RNReplicaNet::DataBlock_Function::Register((void *)this,(void *)&x);    \
00117         mDataBlockFunction_##x = datablock; \
00118         _RO_DO_SETDATABLOCKVARIABLENAME(x);
00119 /* _RO_DO_REGISTERBLOCK_FUNCTION_VAR macro ends here */
00120 
00121 // For member function wrapping. A lot of macro work
00122 /* _RO_MAKE_MEMBERFUNC macro starts here */
00123 #define _RO_MAKE_MEMBERFUNC(x)  Call_##x
00124 /* _RO_MAKE_MEMBERFUNC macro ends here */
00125 
00126 /* _RO_DO_MEMBERFUNC_PRESTAGE_DEF macro starts here */
00127 #define _RO_DO_MEMBERFUNC_PRESTAGE_DEF(x,y) \
00128 void _MAKE_RO(x)::_RO_MAKE_MEMBERFUNC(y)(
00129 /* _RO_DO_MEMBERFUNC_PRESTAGE_DEF macro ends here */
00130 
00131 
00132 /* _RO_DO_MEMBERFUNC_PRESTAGE macro starts here */
00133 #ifdef REPLICANET_VISUALDEBUGGER
00134 #define _RO_DO_MEMBERFUNC_PRESTAGE(x)   \
00135 )   \
00136 {   \
00137     char buffer[256];   \
00138     RNReplicaNet::MessageHelper message;    \
00139     message.SetBuffer(buffer);  \
00140     std::string debug;
00141 #else //ifdef REPLICANET_VISUALDEBUGGER
00142 #define _RO_DO_MEMBERFUNC_PRESTAGE(x)   \
00143 )   \
00144 {   \
00145     char buffer[256];   \
00146     RNReplicaNet::MessageHelper message;    \
00147     message.SetBuffer(buffer);
00148 #endif //ifdef REPLICANET_VISUALDEBUGGER
00149 /* _RO_DO_MEMBERFUNC_PRESTAGE macro ends here */
00150 
00151 /* _RO_DO_MEMBERFUNC_ADDVAR macro starts here */
00152 #define _RO_DO_MEMBERFUNC_ADDVAR(x) \
00153     message.AddVariable(&x,sizeof(x));
00154 // Updated version of this macro, does the same as _RO_DO_MEMBERFUNC_ADDVAR but also includes the string variable type for extra debug info.
00155 #ifdef REPLICANET_VISUALDEBUGGER
00156 #define _RO_DO_MEMBERFUNC_ADDVAR2(x,y)  \
00157     message.AddVariable(&x,sizeof(x));  \
00158     if (RNReplicaNet::XPURL::GetDebugHandler()) \
00159     {   \
00160         debug += #y;    \
00161         debug += "\n";  \
00162         debug += RNReplicaNet::MessageHelper::DumpAsHex(&x,sizeof(x));  \
00163         debug += "\n";  \
00164     }
00165 #else // ifdef REPLICANET_VISUALDEBUGGER
00166 #define _RO_DO_MEMBERFUNC_ADDVAR2(x,y)  \
00167     message.AddVariable(&x,sizeof(x));
00168 #endif // ifdef REPLICANET_VISUALDEBUGGER
00169 /* _RO_DO_MEMBERFUNC_ADDVAR macro ends here */
00170 
00171 /* _RO_DO_MEMBERFUNC_POSTSTAGE macro starts here */
00172 #ifdef REPLICANET_VISUALDEBUGGER
00173 #define _RO_DO_MEMBERFUNC_POSTSTAGE(x)  \
00174     RNReplicaNet::DataBlock_Function *datablock = (RNReplicaNet::DataBlock_Function *) mDataBlockFunction_##x;  \
00175     datablock->AddFunctionStateChange(buffer,message.GetSize(),debug.c_str());  \
00176 }
00177 #else //ifdef REPLICANET_VISUALDEBUGGER
00178 #define _RO_DO_MEMBERFUNC_POSTSTAGE(x)  \
00179     RNReplicaNet::DataBlock_Function *datablock = (RNReplicaNet::DataBlock_Function *) mDataBlockFunction_##x;  \
00180     datablock->AddFunctionStateChange(buffer,message.GetSize());    \
00181 }
00182 #endif //ifdef REPLICANET_VISUALDEBUGGER
00183 /* _RO_DO_MEMBERFUNC_POSTSTAGE macro ends here */
00184 
00185 
00186 /* _RO_DO_MEMBERFUNC_CRACK_START macro starts here */
00187 #define _RO_DO_MEMBERFUNC_CRACK_START(x,y)  \
00188 void _MAKE_RO(x)::##y(void *classp,void *opaque_message)    \
00189 {   \
00190     _MAKE_RO(x) *thisclass = (_MAKE_RO(x) *) classp;    \
00191     RNReplicaNet::MessageHelper *message = (RNReplicaNet::MessageHelper *) opaque_message;  \
00192     message = message;
00193 /* _RO_DO_MEMBERFUNC_CRACK_STARTmacro ends here */
00194 // Change done to avoid compiler warnings about unused variables
00195 
00196 /* _RO_DO_MEMBERFUNC_MESSAGE_CRACK macro starts here */
00197 #define _RO_DO_MEMBERFUNC_MESSAGE_CRACK(x)  \
00198 MESSAGEHELPER_GETVARIABLEp((*message),##x);
00199 /* _RO_DO_MEMBERFUNC_MESSAGE_CRACK macro ends here */
00200 
00201 
00202 /* _RO_DO_MEMBERFUNC_CRACK_END macro starts here */
00203 #define _RO_DO_MEMBERFUNC_CRACK_END(x,y)    \
00204     ((x*)thisclass)->##y(
00205 /* _RO_DO_MEMBERFUNC_CRACK_END macro ends here */
00206 
00207 /* _RO_DO_MEMBERFUNC_CRACK_END2 macro starts here */
00208 #define _RO_DO_MEMBERFUNC_CRACK_END2()  \
00209 );  \
00210 }
00211 /* _RO_DO_MEMBERFUNC_CRACK_END2 macro ends here */
00212 
00213 #endif

Generated on Sun Oct 30 01:11:54 2005 for ReplicaNet by  doxygen 1.4.1