VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
reflectedObjectListHLA.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2014 VT MAK
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
12 #if DtHLA
13 
14 
17 #include <vl/objectIdHashlist.h>
18 #include <vl/region.h>
19 #include <vector>
20 
21 class DtStateMsg;
22 class DtHlaObject;
23 class DtExerciseConn;
24 class DtReflectedObject;
25 
29 struct DtTimeReflectedObjectIdKey
30 {
32  DtTimeReflectedObjectIdKey(DtTime timeValue, const DtObjectId& idValue);
33 
35  DtTimeReflectedObjectIdKey(const DtReflectedObject* object);
36 
37  DtTime time;
38  DtObjectId id;
39 };
40 
42 bool operator<(const DtTimeReflectedObjectIdKey& left, const DtTimeReflectedObjectIdKey& right);
44 bool operator< (const DtTimeReflectedObjectIdKey& left, DtTime right);
45 
46 typedef bool(*DtDiscoveryCondition)(DtReflectedObject* refObj, void* usr);
47 typedef std::map<DtObjectId, DtReflectedObject*> DtRefHlaObjectMap;
48 typedef std::map<DtTimeReflectedObjectIdKey, DtReflectedObject*> DtRefHlaObjectTimeMap;
49 
50 
59 {
60 public:
61 
64  const DtDDMRegionSet* regionSetToUse = 0,
65  const DtString& updateRateTag = DtString("") );
66 
68  virtual ~DtReflectedObjectList();
69 
70 private:
71 
74 
76  DtReflectedObjectList& operator=(const DtReflectedObjectList& orig);
77 
78 public:
79 
81  virtual DtReflectedObject* lookupObj(
82 #if DtHLA_1516
83  RTI::ObjectInstanceHandle id);
84 #else
85  RTI::ObjectHandle id);
86 #endif
87 
89  virtual DtReflectedObject* lookupObj(const DtGlobalObjectDesignator& objName);
90 
92 
93  virtual DtReflectedObject* firstObj() const;
94  virtual DtReflectedObject* lastObj() const;
96 
98  virtual int count() const;
99 
101  virtual DtExerciseConn *exerciseConn() const;
102 
112  virtual void manageObjectClass(RTI::ObjectClassHandle handle);
113 
122  virtual bool removeObject(const DtObjectId& id);
123 
125  virtual void addObjectAdditionCallback(
126  DtReflectedObjectCallbackFunction cb, void* userData);
127  virtual void removeObjectAdditionCallback(
128  DtReflectedObjectCallbackFunction cb, void* userData);
129 
131  virtual void addObjectRemovalCallback(
132  DtReflectedObjectCallbackFunction cb, void* userData);
133  virtual void removeObjectRemovalCallback(
134  DtReflectedObjectCallbackFunction cb, void* userData);
135 
137  virtual void print();
138 
140  virtual void printWaitList();
141 
144  virtual void setTimeoutProcessing(bool onOff);
145 
147  virtual bool isTimeoutProcessing() const;
148 
150 
151  virtual void setTimeoutInterval(DtTime time);
152  virtual DtTime timeoutInterval() const;
154 
157  virtual bool requestsEnabled() const;
158 
161 
162  virtual void setWaitListRefreshEnabled(bool on);
163  virtual bool waitListRefreshEnabled() const;
165 
167 
168  virtual void setWaitListRefreshPeriod(DtTime period);
169  virtual DtTime waitListRefreshPeriod() const;
171 
173 
174  virtual DtReflectedObject* firstWaitingObj() const;
175  virtual DtReflectedObject* lastWaitingObj() const;
177 
179  virtual int numberObjectsWaiting() const;
180 
182  virtual DtTime nextRequestTime() const;
183 
186  virtual void setDiscoveryCondition(DtDiscoveryCondition fn, void* usr);
187 
190  virtual void clearDiscoveryCondition();
191 
193  virtual const DtDDMRegionSet& subscribedRegions();
194 
195 public:
196 
200 
201  static void setAutoSubscribeFlag(bool flag);
202  static bool autoSubscribeFlag();
204 
208 
209  static void setRequestClassUpdateFlag(bool onOff);
210  static bool requestClassUpdateFlag();
212 
215 
216  static void setRequestObjectUpdateFlag(bool onOff);
217  static bool requestObjectUpdateFlag();
219 
223 
224  static void setRequestWhenInitializedFlag(bool onOff);
225  static bool requestWhenInitializedFlag();
227 
229 
230  static void setDefaultWaitListRefreshFlag(bool onOff);
231  static bool defaultWaitListRefreshFlag();
233 
235 
236  static void setDefaultWaitListRefreshPeriod(DtTime period);
237  static DtTime defaultWaitListRefreshPeriod();
239 
241  static bool requestUpdateFlags();
242 
244  static void findDiscoveredObjectsCb(void* usr);
245 
246 protected:
247 
250  virtual void processDiscoverObject(DtHlaObject* obj);
251 
254  virtual void processRemoveObject(DtHlaObject* obj);
255 
258  virtual void processTimedOutObjectReflect(const DtStateMsg& msg,
259  DtHlaObject* obj);
260 
264  virtual void doTimeouts();
265 
267  // or any objects which have not met their discovery criteria yet.
268  virtual void doRequestUpdates();
269 
272  virtual DtReflectedObject* newReflectedObject(DtHlaObject* obj) const = 0;
273 
276  virtual void removeAndDelete(DtReflectedObject* obj, char* msg = nullptr);
277 
283  virtual void objectAdded(DtReflectedObject* object);
284 
287  virtual bool shouldBeTimedOut(DtReflectedObject* object);
288 
292  virtual void timeOutObject(DtReflectedObject* object);
293 
296  virtual void unTimeOutObject(DtHlaObject* obj);
297 
300  virtual void addObjectClass(RTI::ObjectClassHandle handle);
301 
304  virtual void addObjectClassByName(const char* className);
305 
308  virtual void init(const DtList* handleList);
309 
312  void emptyLists();
313 
316  void emptyCallbackLists();
317 
319  virtual void processObjectAdditionCallbacks(
320  DtReflectedObject* object);
321  virtual void processObjectRemovalCallbacks(
322  DtReflectedObject* object);
323 
328  virtual void findAlreadyDiscoveredObjects();
329 
330  virtual void checkDiscoveryCondition(DtReflectedObject* refObj);
331 
334  virtual bool readyToAdd(DtReflectedObject* obj);
335 
337  virtual void addToObjectList(DtReflectedObject* refObj);
338 
340  virtual void addToWaitList(DtReflectedObject* refObj);
341 
343  virtual void removeFromWaitList(DtReflectedObject* refObj);
344 
346  virtual void addToRefreshList(DtReflectedObject* refObj, DtTime timeToRefresh);
347 
349  virtual DtReflectedObject* lookupObjInWaitList(
350 #if DtHLA_1516
351  RTI::ObjectInstanceHandle id);
352 #else
353  RTI::ObjectHandle id);
354 #endif
355 
357  virtual DtReflectedObject* lookupObjInWaitList(
358  const DtGlobalObjectDesignator& name);
359 
360  void unsubscribeRegions();
361 
362 #if DtHLA_1516_EVOLVED
363  const DtString& updateRateSubscriptionName() const;
366 #endif
367 
368 protected:
369 
372  static void discoverObjectCb(DtHlaObject* hlaObj, void* rel);
373 
376  static void removeObjectCb(DtHlaObject* hlaObj, void* rel);
377 
380  static void timedOutObjectReflectCb(const DtStateMsg& msg,
381  DtHlaObject* obj,
382  void* usr);
383 
385  static void doTimeoutsPostDrainCb(void* usr);
386 
388  static void doRequestUpdatesPostDrainCb(void* usr);
389 
391  static void postUpdateCb(DtReflectedObject* obj, void* usr);
392 
393 protected:
394 
395  DtExerciseConn* myExConn;
396  DtRefHlaObjectMap myObjectList;
397  DtHashList myObjectListByName;
398 
399  // When an object is unable to be discovered due to not meeting discovery criteria
400  // it is placed on wait list and initially on discovery request list.
401  // If object instance requests are enabled, after first request it is moved to refresh list
402  DtRefHlaObjectMap myWaitList;
403  DtRefHlaObjectMap myDiscoveryList;
404  DtRefHlaObjectTimeMap myRefreshList;
405  bool myWaitListRefreshEnabled;
406  DtTime myNextRequestTime;
407  DtTime myWaitListRefreshPeriod;
408 
409  DtList myTimedOutObjectList;
410  DtTime myTimeoutInterval;
411  bool myTimeoutProcessingFlag;
412 
413  std::vector<RTI::ObjectClassHandle> myHandleList;
414  DtIntrusiveList myObjectAddedCallbacks;
415  DtIntrusiveList myObjectRemovedCallbacks;
416  DtDiscoveryCondition myDiscoveryCondition;
417  void* myDiscoveryConditionParameter;
418  DtDDMRegionSet mySubscribedRegions;
419  DtString myUpdateRateTag;
420 
421 protected:
422 
423  static bool theAutoSubscribeFlag;
424  static bool theRequestClassUpdateFlag;
425  static bool theRequestObjectUpdateFlag;
426  static bool theRequestWhenInitializedFlag;
427  static bool theRequestUpdateFlags;
428  static bool theDefaultWaitListRefreshFlag;
429  static DtTime theDefaultWaitListRefreshPeriod;
430 };
431 
433 {
434  return myExConn;
435 }
436 
438 {
439  return myObjectList.size() > 0 ? (DtReflectedObject* ) myObjectList.begin()->second : nullptr;
440 }
441 
443 {
444  return myObjectList.size() > 0 ? (DtReflectedObject* ) myObjectList.rend()->second : nullptr;
445 }
446 
447 inline DtReflectedObject* DtReflectedObjectList::firstWaitingObj() const
448 {
449  return myWaitList.size() > 0 ? (DtReflectedObject*)myWaitList.begin()->second : nullptr;
450 }
451 
452 inline DtReflectedObject* DtReflectedObjectList::lastWaitingObj() const
453 {
454  return myWaitList.size() > 0 ? (DtReflectedObject*)myWaitList.rend()->second : nullptr;
455 }
456 
457 inline int DtReflectedObjectList::numberObjectsWaiting() const
458 {
459  return myWaitList.size();
460 }
461 
462 inline DtTime DtReflectedObjectList::waitListRefreshPeriod() const
463 {
464  return myWaitListRefreshPeriod;
465 }
466 
467 inline bool DtReflectedObjectList::waitListRefreshEnabled() const
468 {
469  return myWaitListRefreshEnabled;
470 }
471 
472 inline bool DtReflectedObjectList::defaultWaitListRefreshFlag()
473 {
474  return theDefaultWaitListRefreshFlag;
475 }
476 
477 inline DtTime DtReflectedObjectList::defaultWaitListRefreshPeriod()
478 {
479  return theDefaultWaitListRefreshPeriod;
480 }
481 
482 inline bool DtReflectedObjectList::requestClassUpdateFlag()
483 {
484  return theRequestClassUpdateFlag;
485 }
486 
487 inline bool DtReflectedObjectList::requestObjectUpdateFlag()
488 {
489  return theRequestObjectUpdateFlag;
490 }
491 
492 inline bool DtReflectedObjectList::requestWhenInitializedFlag()
493 {
494  return theRequestWhenInitializedFlag;
495 }
496 
497 inline bool DtReflectedObjectList::requestUpdateFlags()
498 {
499  return theRequestUpdateFlags;
500 }
501 
502 inline bool DtReflectedObjectList::isTimeoutProcessing() const
503 {
505 }
506 
508 {
509  return myTimeoutInterval;
510 }
511 
512 inline bool operator<(const DtTimeReflectedObjectIdKey& left, DtTime right)
513 {
514  return left.time < right;
515 }
516 
517 inline bool operator<(const DtTimeReflectedObjectIdKey& left, const DtTimeReflectedObjectIdKey& right)
518 {
519  if (left.time < right.time) return true;
520  if (left.time > right.time) return false;
521 
522  // time are equal, compare Id
523  return (left.id < right.id);
524 }
525 
526 
527 #endif
Instances of DtReflectedObjectList are lists of instances of classes derived from DtReflectedObject...
Definition: reflectedObjectListDIS.h:38
bool(* DtDiscoveryCondition)(DtReflectedObject *refObj, void *usr)
Definition: reflectedObjectListDIS.h:30
Instances of DtExerciseConn are used to provide an application&#39;s interface or connection to the netwo...
Definition: exerciseConnDIS.h:61
virtual DtReflectedObject * firstObj() const
Get the first/last object in the list.
#define DT_DLL_VL
Definition: vlMachineTypes.h:108
DtIntrusiveList myWaitList
Definition: reflectedObjectListDIS.h:186
DtTime myTimeoutInterval
Definition: reflectedObjectListDIS.h:190
virtual DtExerciseConn * exerciseConn() const
Get my exerciseConn.
This file contains typedefs used to represent objects in a protocol neutral way.
An intrusive list is a list that assumes that the elements that you add are pointers to instances of ...
Definition: vlList.h:196
DtList is deprecated, please use std::list&lt;T&gt;.
Definition: vlList.h:71
Instances of DtReflectedObject are used to represent a simulation entity reflected across a network (...
Definition: reflectedObjectDIS.h:34
Instances of DtEntityIdentifier are used as a unique ID for entities in DIS.
Definition: entityIdentifier.h:31
virtual DtReflectedObject * lastObj() const
virtual DtTime timeoutInterval()
DtHashlist is deprecated and provided for backwards compatibility only.
Definition: vlHashlist.h:69
void(* DtReflectedObjectCallbackFunction)(DtReflectedObject *obj, void *userData)
Callback function that takes a DtReflectedObject and user data.
Definition: reflectedObjectCallbackInfo.h:19
Instances of DtString are used to represent strings.
Definition: vlString.h:29
DtIntrusiveList myObjectList
Definition: reflectedObjectListDIS.h:185
const bool operator<(const DtU128 &lhs, const DtU128 &rhs)
Instances of DtStateMsg are used to represent state data communicated via the network in a DIS (as op...
Definition: stateMsgDIS.h:21
bool myTimeoutProcessingFlag
Definition: reflectedObjectListDIS.h:193
DtExerciseConn * myExConn
Definition: reflectedObjectListDIS.h:182

Document ID: Generated on Mon Apr 25 03:39:01 EDT 2022 from SVN revision 242502
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)