![]() |
VR-Link API Documentation for DIS
|
00001 /********************************************************************* 00002 ** Copyright (c) 1992-2010 VT MAK 00003 ** All rights reserved. 00004 *********************************************************************/ 00005 00006 #ifndef bdiCustomPdu_H_ 00007 #define bdiCustomPdu_H_ 00008 00009 #if DtDIS 00010 00011 #include <vl/dStateMsg.h> 00012 #include <vl/dExerciseConn.h> 00013 #include <vlpi/entityIdentifier.h> 00014 00015 00017 typedef struct DtNetDIGuyCustomPdu 00018 { 00019 DtNetPduHeader DtHeader; 00020 DtNetU16 DtDIGuyMessageVersion; 00021 DtNetU16 DtDIGuyMessageId; 00022 DtNetEntityIdentifier DtEntityId; 00023 DtNetU8 DtDataSize; 00024 DtNetU8 DtData[1]; 00025 } DtNetDIGuyCustomPdu; 00026 00028 enum DtDIGuyCustomPduMsgId 00029 { 00030 DtDIGuyMsgIdEscapeReserved = 0, 00031 DtDIGuyMsgIdSetCharType = 1, 00032 DtDIGuyMsgIdSetCharAppearance = 2, 00033 DtDIGuyMsgIdSetCharAction = 3, 00034 DtDIGuyMsgIdSetCharVisible = 4 00035 }; 00036 00037 class DtDIGuyCustomPdu; 00038 00041 typedef void (*DtDIGuyCustomPduCb)(DtDIGuyCustomPdu* pdu, void* usr); 00042 00046 class DT_DLL_VL DtDIGuyCustomPdu : public DtStateMsg 00047 { 00048 public: 00050 enum { PduStaticSize = 23 }; 00051 00052 public: 00055 DtDIGuyCustomPdu(DtBufferPtr buffer = DtUSE_INTERNAL_BUFFER); 00056 00058 DtDIGuyCustomPdu(const DtNetDIGuyCustomPdu* initial, 00059 DtBufferPtr buffer = DtUSE_INTERNAL_BUFFER); 00060 00062 virtual ~DtDIGuyCustomPdu(); 00063 00065 DtDIGuyCustomPdu(const DtDIGuyCustomPdu& other); 00066 00068 DtDIGuyCustomPdu& operator=(const DtDIGuyCustomPdu& other); 00069 00070 //{@ 00072 virtual DtNetDIGuyCustomPdu* netDIGuyCustomPdu(); 00073 virtual const DtNetDIGuyCustomPdu* netDIGuyCustomPdu() const; 00075 00076 // MJI - I think this should always be 7, according to the SDK 00077 // User's Guide. Going to set it to 7 by default for now, and 00078 // this probably shouldn't be changed. 00079 //{@ 00082 virtual void setMessageVersion(int version); 00083 virtual int messageVersion() const; 00085 00086 //{@ 00088 virtual void setMessageId(DtDIGuyCustomPduMsgId msgId); 00089 virtual DtDIGuyCustomPduMsgId messageId() const; 00091 00092 //{@ 00094 virtual void setEntityId(const DtEntityIdentifier& entId); 00095 virtual DtEntityIdentifier entityId() const; 00097 00098 //{@ 00100 virtual void setDataSize(unsigned int size); 00101 virtual unsigned int dataSize() const; 00103 00107 virtual void addShort(short value); 00108 00112 virtual void addLong(long value); 00113 00117 virtual void addFloat(float value); 00118 00123 virtual void addString(const DtString& str); 00124 00125 //{@ 00138 virtual bool pullShort(short& value, unsigned int& byteoffset) const; 00139 virtual bool pullLong(long& value, unsigned int& byteoffset) const; 00140 virtual bool pullFloat(float& value, unsigned int& byteoffset) const; 00141 virtual bool pullString(DtString& value, unsigned int& byteoffset) const; 00143 00144 //{@ 00146 virtual void getData(unsigned char* buff) const; 00147 virtual void* data(); 00148 void setData(unsigned char* data, int numBytes); 00150 00152 virtual void printData() const; 00153 00155 virtual void printDataToStream(std::ostream& stream) const; 00156 00157 00158 public: 00160 static DtPdu* create(const DtNetPacket* initial, 00161 DtBufferPtr buffer = DtUSE_INTERNAL_BUFFER); 00162 00164 static void addCallback(DtExerciseConn* conn, DtDIGuyCustomPduCb cb, 00165 void* usr); 00166 00168 static void removeCallback(DtExerciseConn* conn, DtDIGuyCustomPduCb cb, 00169 void* usr); 00170 00175 static void setCustomPduKind(DtPduKind pduKind); 00176 static DtPduKind customPduKind(); 00177 00178 protected: 00179 virtual DtPduKind internalGetPduKind() const; 00180 00181 protected: 00182 static DtPduKind theCustomPduKind; 00183 }; 00184 00185 00186 #endif 00187 #endif 00188 00189