Go to the documentation of this file.00001
00002
00003
00004
00005
00008
00009 #ifndef lgrEntityTracker_H_
00010 #define lgrEntityTracker_H_
00011
00012 #include "lgrCore.h"
00013 #include "filePosition.h"
00014
00015 #include <vector>
00016 #include <map>
00017 #include <vlutil/vlNetTypes.h>
00018 #include <vlutil/vlString.h>
00019 #include <vlpi/disEnums.h>
00020
00021 namespace MAKLogger
00022 {
00023 class DtPacket;
00024 class DtLgrBaseSimManager;
00025
00028 class DT_DLL_LGRCORE DtLgrEntityTracker
00029 {
00030 public:
00031 typedef int EntryHandle;
00032
00033 public:
00035 DtLgrEntityTracker();
00036
00038 virtual ~DtLgrEntityTracker();
00039
00040 private:
00042 DtLgrEntityTracker(const DtLgrEntityTracker&);
00044 DtLgrEntityTracker& operator=(const DtLgrEntityTracker&);
00045 public:
00047 virtual void parsePacket(const DtPacket& packet);
00048
00051 virtual EntryHandle addEntry(double firstTime, double lastTime, const DtString& name,
00052 const DtString& type, DtForceType force, DtLgrEntityTracker::EntryHandle handle = -1);
00053
00058 virtual EntryHandle addTemporaryEntry(const DtString& name);
00059
00062 virtual EntryHandle findEntry(const DtString& name) const;
00063
00065 virtual void clearEntries();
00066
00068 virtual int entityCount() const;
00069
00071 virtual EntryHandle entityId(const DtPacket& packet) const;
00072
00074 virtual DtString entityName(const DtPacket& packet) const;
00075
00077 virtual DtString entityType(const DtPacket& packet) const;
00078
00080 virtual DtForceType entityForce(const DtPacket& packet) const;
00081
00083 virtual DtPacket* encodePacket() const;
00084
00089 virtual void decodePacket(const DtPacket*);
00090
00092 virtual double entityFirstTime(EntryHandle handle) const;
00093
00095 virtual double entityLastTime(EntryHandle handle) const;
00096
00098 virtual DtString entityName(EntryHandle handle) const;
00099
00101 virtual DtString entityType(EntryHandle handle) const;
00102
00104 virtual DtForceType entityForce(EntryHandle handle) const;
00105
00107 virtual bool isPermanentEntry(EntryHandle handle) const;
00108
00110 virtual void deserializeFromString(const DtString& data);
00111
00113 virtual DtString serialize();
00114
00120 virtual void setManager(DtLgrBaseSimManager* manager);
00121
00123 virtual EntryHandle begin() const;
00124
00126 virtual EntryHandle end() const;
00127
00128
00129 typedef int TrackerUpdateId;
00130 virtual DtLgrEntityTracker::TrackerUpdateId lastUpdateId() const;
00131
00132 protected:
00133
00135 struct TrackerEntry
00136 {
00137 bool temporary;
00138
00139 double firstTime;
00140 double lastTime;
00141 DtForceType force;
00142 DtString name;
00143 DtString type;
00144 };
00145
00147 struct NetTrackerEntryHeader
00148 {
00149 DtNetInt32 entrySize;
00150
00151 DtNetFloat64 firstTime;
00152 DtNetFloat64 lastTime;
00153
00154 DtNetInt32 force;
00155
00156 DtNetInt32 nameSize;
00157 DtNetInt32 typeSize;
00158 };
00159
00161 struct NetTrackerEntry
00162 {
00163 struct NetTrackerEntryHeader header;
00164 char name[1];
00165 char type[1];
00166 };
00167
00169 struct NetTrackerTable
00170 {
00171 DtNetU32 numEntries;
00172 DtNetU32 unused;
00173 };
00174
00194
00195 typedef std::vector<TrackerEntry> TrackerEntryList;
00196 TrackerEntryList myTrackedEntities;
00197
00198 typedef std::map<DtString, EntryHandle> TrackerEntryIndex;
00199 TrackerEntryIndex myEntityIndex;
00200
00201 DtLgrBaseSimManager* myManager;
00202 TrackerUpdateId myLastUpdateId;
00203
00204 };
00205 }
00206
00207 #endif