27 #include <legionDataStore/simulationDatabase.h>
28 #include <legionDataStore/writeStateInstance.h>
29 #include <legionDataStore/readStateInstance.h>
30 #include "legionDataStore/view.h"
32 #include <vlutil/vlString.h>
33 #include <vlpi/disEnums.h>
34 #include <tbb/spin_rw_mutex.h>
35 #include <tbb/spin_mutex.h>
36 #include <tbb/mutex.h>
38 #include <boost/signals2.hpp>
42 class WriteEntityRepository;
43 class ReadEntityRepository;
48 class SimulationDatabase;
49 class WriteStateInstance;
57 class DtStateDataManager;
58 class DtLaserDesignatorStateComponent;
59 class DtIffStateComponent;
60 class DtActiveSonarStateComponent;
61 class DtTaskVisualizationStateComponent;
62 class DtRadioTransmitterStateComponent;
63 class DtNavAidRadioTransmitterStateComponent;
64 class DtUnderwaterAcousticsStateComponent;
65 class DtEmitterSystemStateComponent;
66 class DtRadioReceiverStateComponent;
67 class DtSimulatedObjectStateComponent;
68 class DtLocationStateComponent;
69 class DtAisDataStateComponent;
70 class DtAircraftLightingStateComponent;
71 class DtGroundVehicleLightingStateComponent;
84 template <
typename T_Component>
87 if (hasStateComponentType(T_Component::ComponentType()))
89 return (dynamic_cast<const T_Component*>(getStateComponent(T_Component::ComponentType())) !=
nullptr);
97 virtual void aboutToBeDeleted();
99 unsigned long long legionGlobalId()
const;
129 template <
typename T_Component>
130 T_Component* addStateComponent(
bool checkWritable =
false,
bool isRemote =
false);
135 template <
typename T_Component>
136 void removeStateComponents();
139 template <
typename T_Component>
144 const T_Component* comp =
dynamic_cast<const T_Component*
>(getStateComponent(scType, index));
154 template <
typename T_Component>
158 std::vector<T_Component*> results;
160 if (scType < myFrameState.size())
162 std::vector<DtFrameStateInterface*>::const_iterator iter = myFrameState[scType].begin();
163 std::vector<DtFrameStateInterface*>::const_iterator end = myFrameState[scType].end();
166 results.push_back(dynamic_cast<T_Component*>(*iter));
176 if (scType < myFrameState.size())
178 if (index < myFrameState[scType].
size())
180 return myFrameState[scType][index];
189 if (scType < myFrameState.size())
191 if (index < myFrameState[scType].
size())
193 return myFrameState[scType][index];
204 template <
typename T_Component>
207 T_Component* comp = getStateComponent<T_Component>(0,
false);
209 return (comp && comp->isWritable());
213 template <
typename T_Component>
218 if (scType < myFrameState.size())
220 if (index < myFrameState[scType].
size())
226 T_Component* comp =
dynamic_cast<T_Component*
>(sc);
228 if (comp && (!checkWritable || comp->isWritable()))
245 const DtString& markingText()
const;
249 return myFrameState.size();
273 bool isValid()
const;
276 template <
typename T_Component>
277 const T_Component* getStateComponent(
int index = 0)
const;
281 template <
typename T_Component>
285 std::vector<const T_Component*> results;
287 if (scType < myFrameState.size())
289 std::vector<const DtFrameStateInterface*>::const_iterator iter = myFrameState[scType].begin();
290 std::vector<const DtFrameStateInterface*>::const_iterator end = myFrameState[scType].end();
293 results.push_back(dynamic_cast<const T_Component*>(*iter));
305 const DtString& markingText()
const;
309 return myFrameState.size();
312 bool advancedFrame()
const;
347 PublishComponentsOnly
360 virtual void invalidate();
361 virtual bool isValid()
const;
362 virtual bool isWritable()
const;
364 template <
typename T_Component>
367 if (myWriteStateInstance.isValid())
369 return myWriteStateInstance.typeExtensionCount<T_Component>();
373 return getCurrentFrameNumberOfLegionComponents<T_Component>();
377 template <
typename T_Component>
380 if (myReadStateInstance && myReadStateInstance->isValid())
382 return myReadStateInstance->typeExtensionCount<T_Component>();
390 template <
typename T_Component>
393 if (myWriteStateInstance.isValid())
395 return myWriteStateInstance.typeExtensionCount<T_Component>();
397 else if (myReadStateInstance && myReadStateInstance->isValid())
399 return myReadStateInstance->typeExtensionCount<T_Component>();
405 template <
typename T_Component>
408 if (myWriteStateInstance.isValid())
410 return myWriteStateInstance.findTypeExtension<T_Component>(std::max(0, index));
414 return findCurrentFrameLegionComponent<T_Component>(index);
418 template <
typename T_Component>
421 if (myReadStateInstance && myReadStateInstance->isValid())
423 if (T_Component::isType(myReadStateInstance->instanceHandle()))
425 return T_Component(myReadStateInstance->instanceHandle());
428 return myReadStateInstance->findTypeExtension<T_Component>(std::max(0, index));
432 return T_Component();
438 return myAdvancedFrame;
443 return myAdvancingFrame;
448 return &myNextFrameState;
453 return &myCurrentFrameState;
459 template <
typename T_Component>
462 return myNextFrameState.addStateComponent<T_Component>(checkWritable, isRemote);
465 template <
typename T_Component>
468 return myNextFrameState.isWritable<T_Component>();
473 if (myDatabase && myWriteStateInstance.isValid())
475 destroyInstance(myWriteStateInstance);
476 myWriteStateInstance = Legion::WriteStateInstance();
477 delete myReadStateInstance;
478 myReadStateInstance =
nullptr;
484 tbb::mutex::scoped_lock lock(theCreateInstanceMutex);
485 database()->destroyInstance(wsi);
489 virtual void createAndInitializeMainInstance();
491 template <
typename T_Component>
494 tbb::mutex::scoped_lock lock(theCreateInstanceMutex);
495 myWriteStateInstance = myDatabase->createInstance<T_Component>();
498 return T_Component(myWriteStateInstance.instanceHandle());
501 template <
typename T_Component>
504 if (!myWriteStateInstance.isValid())
510 tbb::mutex::scoped_lock lock(theCreateInstanceMutex);
511 T_Component comp = myDatabase->createInstance<T_Component>();
517 return T_Component();
520 template <
typename T_Component>
523 if (!myWriteStateInstance.isValid())
529 tbb::mutex::scoped_lock lock(theCreateInstanceMutex);
530 T_Component comp = myDatabase->createInstance<T_Component>();
533 myWriteStateInstance.addExtension(comp);
538 return T_Component();
541 template <
typename T_Component>
544 if (T_Component::ComponentType() < myStateComponents.size())
546 if (index < myStateComponents[T_Component::ComponentType()].size())
548 return myStateComponents[T_Component::ComponentType()][index];
555 template <
typename T_Component>
558 return myNextFrameState.getStateComponentList<T_Component>();
561 template <
typename T_Component>
564 return myCurrentFrameState.getStateComponentList<T_Component>();
567 template <
typename T_Component>
572 if (nextFrameState()->hasStateComponent<T_Component>())
576 return (nextFrameStateComponent<T_Component>()->isWritable());
583 return currentFrameState()->hasStateComponent<T_Component>();
594 template <
typename T_Component>
597 if (currentFrameState()->hasStateComponent<T_Component>())
599 return (dynamic_cast<const T_Component*>(currentFrameState()->getStateComponent<T_Component>()) !=
nullptr);
605 template <
typename T_Component>
608 T_Component* comp = nextFrameState()->getStateComponent<T_Component>(0);
609 if (comp && comp->isWritable())
619 template <
typename T_Component>
622 return currentFrameState()->getStateComponent<T_Component>(0);
629 void removeComponent(Legion::WriteStateInstance& set);
634 const DtUUID& uuid()
const;
635 void setUUID(
const DtUUID&);
639 void setCheckForNameReservation(
bool);
640 bool checkForNameReservation()
const;
642 void setGlobalId(
const DtString& s);
645 void setMarkingText(
const DtString& name);
646 const DtString& markingText()
const;
648 const DtString parentGlobalId()
const;
651 const DtUUID& nextFrameHostId()
const;
652 const DtUUID& currentFrameHostId()
const;
654 bool isClutterEntity()
const;
657 void setEntityType(
const DtObjectType& type);
660 DtEntityType
entityType()
const {
return DtEntityType(objectType()); };
661 DtObjectType objectType()
const;
663 void setEntityId(
const DtEntityIdentifier& s);
664 DtEntityIdentifier entityId()
const;
667 virtual void setAwaitingTransfer(
bool);
670 return myAwaitingTransfer;
677 virtual bool createPublicData(
const DtVrfObjectParameters*,
bool isReflectedObject,
const DtEntityType& et);
684 template <
typename T_Class>
685 void removeInstanceUpdatedCallback(Legion::InstanceHandle instanceHandle,
unsigned int callbackHandle);
686 template <
typename T_Class>
688 const std::vector<Legion::AttributeIndex>& attributeIndexFilter = std::vector<Legion::AttributeIndex>());
690 virtual void advanceFrame();
698 void setIsLocal(
bool b);
699 bool isLocal()
const;
703 return myPublishFlag;
708 return ((myPublishFlag == PublishAll) || (myPublishFlag == PublishComponentsOnly));
713 return myStateDataManager;
718 return myStateDataManager;
721 double absRealTime()
const;
725 return myCoordinateSystem;
730 return myWriteStateInstance;
735 return myReadStateInstance;
740 return myConvertedToLocal;
744 UInt64 legionGlobalId()
const;
747 virtual void clearComponents();
777 virtual void removeIffSystem();
781 virtual void removeUnderwaterAcousticsSystem();
793 virtual void convertToRemote();
796 virtual void convertToLocal();
806 virtual void shuttingDown();
817 static void addDefaultPublicDataFor(
const std::string& type,
const std::string& componentCreator);
818 static void removeDefaultPublicDataFor(
const std::string& type,
const std::string& componentCreator);
819 static std::set<std::string> defaultPublicDataFor(DtEntityType defaultEntityType,
const std::string& dislpayName,
const std::string& parameterType);
823 static void addPublicDataFor(
const std::string& type,
const std::string& componentCreator);
824 static void removePublicDataFor(
const std::string& type,
const std::string& componentCreator);
825 static std::set<std::string> additionalPublicDataFor(DtEntityType defaultEntityType,
const std::string& dislpayName,
const std::string& parameterType);
831 static void setDefaultMainComponentFor(
const std::string& type,
const std::string& defaultPublicData);
832 static std::string defaultMainComponentFor(DtEntityType defaultEntityType,
const std::string& dislpayName,
const std::string& type);
837 virtual void aboutToBeDeleted();
839 virtual void setPublishingOnLegionNetwork(
bool b);
842 return myPublishingOnLegionNetwork;
851 virtual DtStateData* currentFrameHostStateData()
const;
856 virtual void hostChanged(
const DtUUID& oldUUID,
const DtUUID& newUUID);
858 virtual void subordinatesChanged(
const std::vector<DtUUID>& oldSubordinates,
const std::vector<DtUUID>& newSubordinates);
869 virtual std::string defaultParameterTypeForEntityType(
const DtEntityType&)
const;
873 virtual void completeRemoteConversion();
875 virtual void hostWasDeleted();
881 virtual void uuidChanged(
const DtUUID& oldUUID,
const DtUUID& newUUID);
882 virtual void markingTextChanged(
const DtString& oldUUID,
const DtString& newUUID);
892 boost::signals2::signal<void (const DtStateData*, const DtUUID& oldUUID, const DtUUID& newUUID)>
signal_hostChanged;
909 boost::signals2::signal<void (const DtStateData*, const std::vector<DtUUID>& added,
const std::vector<DtUUID>& removed)> signal_subordinatesChanged;
954 typedef std::map<std::string, std::set<std::string> >
PublicData;
974 bool myAdvancingFrame =
false;
975 bool myConvertedToLocal =
false;
979 #include <vrfStateData/stateData.inl>
bool isWritable()
Definition: stateData.h:205
UUID is a unique ID wrapper class.
Definition: uuid.h:59
bool myAdvancedFrame
Definition: stateData.h:938
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:63
boost::signals2::scoped_connection myMarkingTextChangedConnection
Definition: stateData.h:948
T_Component * nextFrameStateComponent()
Definition: stateData.h:606
std::vector< T_Component * > getNextFrameStateComponentList() const
Definition: stateData.h:556
const DtSimulatedObjectStateComponent * myCurrentFrameSimulatedObjectStateComponent
Definition: stateData.h:966
unsigned long long SimStateID
Definition: stateDataTypes.h:16
bool advancingFrame() const
Definition: stateData.h:441
DtExternalCurrentFrameState(DtStateData *sd)
Definition: stateData.h:266
Definition: stateDataTypes.h:23
unsigned long long SimStateID
Definition: stateData.h:342
std::vector< const T_Component * > getStateComponentList() const
Definition: stateData.h:282
const bool hasStateComponent() const
Definition: stateData.h:595
boost::signals2::scoped_connection mySubordinatesChangedConnection
Definition: stateData.h:945
boost::signals2::signal< void(SimStateID)> signal_preFrameAdvanced
Definition: stateData.h:895
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: radioTransmitterStateComponent.h:139
T_Component * getStateComponent(int index=0, bool checkWritable=true)
The current state frame data.
Definition: stateData.h:214
int mySessionId
Definition: stateData.h:932
The DtLocationStateComponent interface contains the interface that all DtLocationStateComponents can ...
Definition: locationStateComponent.h:25
DtEntityType entityType() const
Definition: stateData.h:660
int getCurrentFrameNumberOfLegionComponents() const
Definition: stateData.h:378
bool convertedToLocal() const
Definition: stateData.h:738
const Coordinate_System * myCoordinateSystem
Definition: stateData.h:930
unsigned int StateComponentType
Definition: stateComponent.h:55
std::vector< std::vector< DtStateComponent * > > myStateComponents
Definition: stateData.h:934
int numberOfFrameStates() const
Definition: stateData.h:307
boost::signals2::signal< void(const DtStateData *)> signal_modified
Signal sent if this state had modified components.
Definition: stateData.h:901
PublishFlag myPublishFlag
Simulated locally vs. remote representation.
Definition: stateData.h:928
The DtSimulatedObjectStateComponent is an interface that all main components (those that are consider...
Definition: simulatedObjectStateComponent.h:21
T_Component createUnattachedInstance()
Definition: stateData.h:502
boost::signals2::signal< void(const DtString &, const DtString &, const DtUUID &, SimStateID)> signal_markingTextChanged
Definition: stateData.h:889
static tbb::mutex theCreateInstanceMutex
Definition: stateData.h:972
static PublicData theDefaultPublicData
Definition: stateData.h:955
Definition: stateData.h:345
Legion::SimulationDatabase * database()
Definition: stateData.h:786
PublishFlag publishFlag() const
Definition: stateData.h:701
static DefaultMainComponentMap theDefaultMainComponentMap
Definition: stateData.h:959
voidpf void uLong size
Definition: ioapi.h:39
const DtStateDataManager * stateDataManager() const
Definition: stateData.h:716
const DtFrameStateInterface * getStateComponent(DtStateComponent::StateComponentType scType, int index=0) const
Definition: stateData.h:174
DtFrameStateInterface * getStateComponent(DtStateComponent::StateComponentType scType, int index=0)
Definition: stateData.h:187
void setPublishFlag(PublishFlag b)
Only called during construction.
Definition: stateData.h:863
Legion::SimulationDatabase * myDatabase
Definition: stateData.h:919
bool hasStateComponent(bool checkWritable=false)
Definition: stateData.h:568
Definition: stateData.h:116
boost::signals2::signal< void(const DtStateData *)> signal_frameAdvanced
Signal sent regardless of whether or not this state had any modified components.
Definition: stateData.h:898
Contains the DtUUID class declaration.
DT_DLL_vrfmodel makVrf::DtDynamicTerrainStateComponent * createStateComponent(DtLocalObject *localObject)
Creates a new state component on the localObject and returns a pointer to it. Note that the state com...
boost::signals2::signal< void(const DtUUID &, const DtUUID &, SimStateID)> signal_uuidChanged
Definition: stateData.h:888
PublishFlag
Definition: stateData.h:343
Legion::ReadStateInstance * myReadStateInstance
Definition: stateData.h:923
boost::signals2::signal< void(DtStateData *)> signal_convertedToLocal
Definition: stateData.h:907
unsigned int componentCount() const
Definition: stateData.h:391
std::vector< std::vector< DtStateComponent * > > myCreatedStateComponents
Definition: stateData.h:935
T_Component findNextFrameLegionComponent(int index=0)
Definition: stateData.h:406
SimStateID id() const
Definition: stateData.h:679
const DtVrfObjectParameters * myParameters
Definition: stateData.h:962
T_Component createInstance()
Definition: stateData.h:521
Definition: stateData.h:346
T_Component findCurrentFrameLegionComponent(int index=0) const
Definition: stateData.h:419
void destroyInstance(const Legion::WriteStateInstance &wsi)
Definition: stateData.h:482
int getNextFrameNumberOfLegionComponents()
Definition: stateData.h:365
std::vector< const T_Component * > getCurrentFrameStateComponentList() const
Definition: stateData.h:562
static PublicData theAdditionalPublicData
Definition: stateData.h:956
boost::signals2::scoped_connection myHostChangedConnection
Definition: stateData.h:946
std::vector< T_Component * > getStateComponentList() const
Definition: stateData.h:155
boost::signals2::signal< void(const DtExternalFrameStateInterface *)> signal_externalFrameStateToBeDestroyed
Definition: stateData.h:100
DtStateComponent * getStateComponent(int index=0)
Definition: stateData.h:542
DtStateData * myCurrentFrameHostStateData
Definition: stateData.h:970
Definition: coordSystem.h:54
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:339
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: laserDesignatorStateComponent.h:56
bool myPublishingOnLegionNetwork
Definition: stateData.h:963
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: activeSonarStateComponent.h:286
boost::signals2::signal< void(DtStateData *)> signal_convertedToRemote
Definition: stateData.h:904
DtExternalNextFrameState * nextFrameState()
Definition: stateData.h:446
Legion::WriteStateInstance myWriteStateInstance
The basic data. This is what all components are hung off of if they are STE compliant.
Definition: stateData.h:922
std::atomic< unsigned int > myComponentNumber
Definition: stateData.h:943
boost::signals2::signal< void(const DtStateData *, const DtUUID &oldUUID, const DtUUID &newUUID)> signal_hostChanged
Signal sent when the host has changed.
Definition: stateData.h:892
std::map< std::string, std::string > DefaultMainComponentMap
Definition: stateData.h:958
const Coordinate_System * coordinateSystem() const
Definition: stateData.h:723
DtExternalCurrentFrameState myCurrentFrameState
Definition: stateData.h:916
bool isWritable()
Definition: stateData.h:466
std::map< std::string, std::set< std::string > > PublicData
This is added for systems that might not have updated the ope files to the new format to get public d...
Definition: stateData.h:954
void destroyMainInstance()
Definition: stateData.h:471
unsigned long long UInt64
Definition: stateDataTypes.h:17
Legion::ReadStateInstance * readStateInstance() const
Definition: stateData.h:733
DtStateDataManager * myStateDataManager
Definition: stateData.h:918
bool myMainComponentOnLegion
Definition: stateData.h:964
Definition: stateData.h:263
UInt64 myLegionGlobalId
Definition: stateData.h:942
DtExternalNextFrameState(DtStateData *sd)
Definition: stateData.h:119
Legion::WriteStateInstance writeStateInstance()
Definition: stateData.h:728
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: emitterSystemStateComponent.h:466
bool advancedFrame() const
Definition: stateData.h:436
Definition: stateDataTypes.h:28
Definition: stateComponent.h:51
boost::signals2::scoped_connection myUUIDChangedConnection
Definition: stateData.h:947
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: radioReceiverStateComponent.h:64
const DtLocationStateComponent * myCurrentFrameLocationStateComponent
Definition: stateData.h:967
const DtExternalCurrentFrameState * currentFrameState() const
Definition: stateData.h:451
std::set< DtFrameStateInterface * > myRemoveStateComponents
Definition: stateData.h:936
boost::signals2::scoped_connection myHostWasDeletedConnection
Definition: stateData.h:949
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: navAidRadioTransmitterStateComponent.h:20
bool myCleared
Definition: stateData.h:113
std::vector< std::vector< DtFrameStateInterface * > > myFrameState
Definition: stateData.h:260
Definition: stateData.h:73
boost::signals2::signal< void(const DtStateData *)> signal_stateDataToBeDestroyed
Definition: stateData.h:894
boost::signals2::signal< void(DtStateData *)> signal_convertingToRemote
Definition: stateData.h:903
bool myConvertToRemote
Definition: stateData.h:939
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: underwaterAcousticsStateComponent.h:106
bool publishingOnLegionNetwork() const
Definition: stateData.h:840
#define DT_DLL_vrfStateData
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfStateDataDefines.h:26
bool awaitingTransfer() const
Definition: stateData.h:668
bool myAwaitingTransfer
Definition: stateData.h:940
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: iffStateComponent.h:83
DtStateDataManager * stateDataManager()
Definition: stateData.h:711
void setObjectType(const DtObjectType &type)
Definition: stateData.h:658
const T_Component * getStateComponent(int index=0) const
The current state frame data.
Definition: stateData.h:140
bool myCleared
Definition: stateData.h:960
tbb::spin_rw_mutex myCurrentFrameHostStateDataMutex
Definition: stateData.h:971
DtExternalNextFrameState myNextFrameState
Even though this class contains the components, the frame classes will give access to those component...
Definition: stateData.h:915
1) Define the interface class that will be used to represent the next and current frames...
Definition: taskVisualizationStateComponent.h:260
Contains the DtStateComponent class declaration.
virtual void addStateComponent(DtFrameStateInterface *)
Definition: stateData.h:107
DtSimulatedObjectStateComponent * myNextFrameSimulatedObjectStateComponent
Definition: stateData.h:969
boost::function< void(const std::vector< UInt32 > &)> DtInstanceUpdatedCallback
Definition: stateDataTypes.h:21
T_Component createMainInstance()
Definition: stateData.h:492
boost::signals2::signal< void(DtStateData *)> signal_convertingToLocal
Definition: stateData.h:906
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:291
T_Component * addStateComponent(bool checkWritable=false, bool isRemote=false)
Using the global state component factory, creates and adds a new state of the given type...
Definition: stateData.h:460
bool hasStateComponent() const
Definition: stateData.h:85
bool isPublishedOnNetwork() const
Definition: stateData.h:706
SimStateID mySimStateID
Definition: stateData.h:925
std::vector< std::vector< const DtFrameStateInterface * > > myFrameState
Definition: stateData.h:322
const T_Component * currentFrameStateComponent() const
Definition: stateData.h:620
This class holds the state data that represents each simulation object in the system.
Definition: stateDataManager.h:73
int numberOfFrameStates() const
Definition: stateData.h:247
boost::signals2::signal< void(const DtStateData *)> signal_firstFrameAdvance
Signal sent on the first frame advance.
Definition: stateData.h:886