Go to the documentation of this file.00001
00002
00003
00004
00005
00008
00009 #ifndef packet_H_
00010 #define packet_H_
00011
00012 #include "lgrCore.h"
00013 #include <list>
00014 #include <vector>
00015
00016 #include "smartBuffer.h"
00017 #include "absoluteTime.h"
00018 #include "lgrEntityTracker.h"
00019
00020 #include <vlutil/vlMutex.h>
00021
00022 namespace MAKLogger
00023 {
00027 class DT_DLL_LGRCORE DtPacketAttribute
00028 {
00029 public:
00030 DtPacketAttribute(int handle);
00031 virtual ~DtPacketAttribute();
00032 inline int handle() const { return myHandle; }
00033
00034 protected:
00035 int myHandle;
00036 };
00037
00038 typedef DtBoost::shared_ptr<DtPacketAttribute> DtPacketAttributeSP;
00039
00042 class DT_DLL_LGRCORE DtPacket
00043 {
00044 public:
00045
00048 enum DtPacketType
00049 {
00050 Type_Interaction = 0,
00051 Type_Update = 1,
00052 Type_Removal = 2,
00053 Type_Annotation = 3,
00054 Type_Pdu = 4,
00055 Type_Fom = 5,
00056 Type_Audio = 6,
00057 Type_Checkpoint = 7,
00058 Type_IndexTable = 8,
00059 Type_MultiTSUpdates = 9,
00060
00061
00062
00063
00064 Type_RecordingData = 11,
00065 Type_SimulationData = 12,
00066
00067 Type_EntityTable = 13,
00068 Type_ConfigData = 14,
00069
00071 Type_UpdateDDM = 15,
00072 Type_InteractionDDM = 16,
00073
00074 Type_TapeTimeDate = 17,
00075 Type_Pause = 18,
00076 Type_Unpause = 19,
00077
00078 Type_None = 0x7FFFFFF0
00079 };
00080
00081 enum FilterType
00082 {
00083 Unfiltered,
00084 Filtered,
00085 Dropped
00086 };
00087
00089 static DtPacket* create(DtSmartBuffer data, DtAbsoluteTime time,int type, int id=-1);
00090
00092 static DtPacket* create(size_t size, DtAbsoluteTime time, int type, int id=-1);
00093
00095 ~DtPacket();
00096
00098 void operator delete(void* v,size_t t);
00099
00101 bool operator <( const DtPacket& ) const;
00102
00104
00105 char* data();
00106 const char* data() const;
00108
00110 FilterType filter() const;
00111
00113 size_t size() const;
00114
00116 const DtAbsoluteTime& time() const;
00117
00119 int type() const;
00120
00122 DtLgrEntityTracker::EntryHandle entityId() const;
00123
00125 void setEntityId(DtLgrEntityTracker::EntryHandle id);
00126
00128
00129 DtSmartBuffer& buffer();
00130 const DtSmartBuffer& buffer() const;
00132
00133 void setFilter(FilterType filter);
00134 void setTime(DtAbsoluteTime time);
00135 void setType(int type);
00136
00139 void addAttribute(DtPacketAttributeSP);
00140
00144 bool removeAttribute(int);
00145
00148 DtPacketAttributeSP lookupAttribute(int);
00149
00150 void convertTime(DtAbsoluteTime inputCurrentTime,
00151 DtAbsoluteTime outputCurrentTime);
00152
00155 static DtAbsoluteTime convertTime(
00156 DtAbsoluteTime inputCurrentTime,
00157 DtAbsoluteTime outputCurrentTime,
00158 DtAbsoluteTime arrivalTime);
00159
00160 protected:
00161
00162 DtPacket(DtSmartBuffer data, DtAbsoluteTime time, int type, int id);
00163
00165 DtPacket(size_t size, DtAbsoluteTime time, int type, int id);
00166
00167 void* operator new(size_t t);
00168
00170 DtAbsoluteTime myTime;
00171
00172 DtLgrEntityTracker::EntryHandle myEntityId;
00173
00175 int myType;
00176
00179 FilterType myFilterCondition;
00180
00182 DtSmartBuffer myData;
00183
00185 std::list<DtPacketAttributeSP> myAttributes;
00186
00187 private:
00188
00190
00191
00193 static void deleteChunks();
00194
00195 static DtPacket* theFirstPacket;
00196 static DtMutex thePacketListMutex;
00197 static std::vector<char*> theMemoryChunks;
00198 static char* currentMemory;
00199 static char* endMemory;
00200 DtPacket* next;
00202 };
00203
00204 }
00205
00206 #endif