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;
81 template <
typename T_Component>
84 if (hasStateComponentType(T_Component::ComponentType()))
86 return (dynamic_cast<const T_Component*>(getStateComponent(T_Component::ComponentType())) !=
nullptr);
94 virtual void aboutToBeDeleted();
96 unsigned long long legionGlobalId()
const;
126 template <
typename T_Component>
127 T_Component* addStateComponent(
bool checkWritable =
false,
bool isRemote =
false);
132 template <
typename T_Component>
133 void removeStateComponents();
136 template <
typename T_Component>
141 const T_Component* comp =
dynamic_cast<const T_Component*
>(getStateComponent(scType, index));
151 template <
typename T_Component>
155 std::vector<T_Component*> results;
157 if (scType < myFrameState.size())
159 std::vector<DtFrameStateInterface*>::const_iterator iter = myFrameState[scType].begin();
160 std::vector<DtFrameStateInterface*>::const_iterator end = myFrameState[scType].end();
163 results.push_back(dynamic_cast<T_Component*>(*iter));
173 if (scType < myFrameState.size())
175 if (index < myFrameState[scType].
size())
177 return myFrameState[scType][index];
186 if (scType < myFrameState.size())
188 if (index < myFrameState[scType].
size())
190 return myFrameState[scType][index];
201 template <
typename T_Component>
204 T_Component* comp = getStateComponent<T_Component>(0,
false);
206 return (comp && comp->isWritable());
210 template <
typename T_Component>
215 if (scType < myFrameState.size())
217 if (index < myFrameState[scType].
size())
223 T_Component* comp =
dynamic_cast<T_Component*
>(sc);
225 if (comp && (!checkWritable || comp->isWritable()))
242 const DtString& markingText()
const;
246 return myFrameState.size();
270 bool isValid()
const;
273 template <
typename T_Component>
274 const T_Component* getStateComponent(
int index = 0)
const;
278 template <
typename T_Component>
282 std::vector<const T_Component*> results;
284 if (scType < myFrameState.size())
286 std::vector<const DtFrameStateInterface*>::const_iterator iter = myFrameState[scType].begin();
287 std::vector<const DtFrameStateInterface*>::const_iterator end = myFrameState[scType].end();
290 results.push_back(dynamic_cast<const T_Component*>(*iter));
302 const DtString& markingText()
const;
306 return myFrameState.size();
309 bool advancedFrame()
const;
344 PublishComponentsOnly
357 virtual void invalidate();
358 virtual bool isValid()
const;
359 virtual bool isWritable()
const;
361 template <
typename T_Component>
364 if (myWriteStateInstance.isValid())
366 return myWriteStateInstance.typeExtensionCount<T_Component>();
370 return getCurrentFrameNumberOfLegionComponents<T_Component>();
374 template <
typename T_Component>
377 if (myReadStateInstance && myReadStateInstance->isValid())
379 return myReadStateInstance->typeExtensionCount<T_Component>();
387 template <
typename T_Component>
390 if (myWriteStateInstance.isValid())
392 return myWriteStateInstance.typeExtensionCount<T_Component>();
394 else if (myReadStateInstance && myReadStateInstance->isValid())
396 return myReadStateInstance->typeExtensionCount<T_Component>();
402 template <
typename T_Component>
405 if (myWriteStateInstance.isValid())
407 return myWriteStateInstance.findTypeExtension<T_Component>(std::max(0, index));
411 return findCurrentFrameLegionComponent<T_Component>(index);
415 template <
typename T_Component>
418 if (myReadStateInstance && myReadStateInstance->isValid())
420 if (T_Component::isType(myReadStateInstance->instanceHandle()))
422 return T_Component(myReadStateInstance->instanceHandle());
425 return myReadStateInstance->findTypeExtension<T_Component>(std::max(0, index));
429 return T_Component();
435 return myAdvancedFrame;
440 return &myNextFrameState;
445 return &myCurrentFrameState;
451 template <
typename T_Component>
454 return myNextFrameState.addStateComponent<T_Component>(checkWritable, isRemote);
457 template <
typename T_Component>
460 return myNextFrameState.isWritable<T_Component>();
465 if (myWriteStateInstance.isValid() && myDatabase)
467 destroyInstance(myWriteStateInstance);
468 myWriteStateInstance = Legion::WriteStateInstance();
469 delete myReadStateInstance;
470 myReadStateInstance =
nullptr;
476 database()->destroyInstance(wsi);
480 virtual void createAndInitializeMainInstance();
482 template <
typename T_Component>
485 tbb::mutex::scoped_lock lock(theCreateInstanceMutex);
486 myWriteStateInstance = myDatabase->createInstance<T_Component>();
489 return T_Component(myWriteStateInstance.instanceHandle());
492 template <
typename T_Component>
495 if (!myWriteStateInstance.isValid())
501 tbb::mutex::scoped_lock lock(theCreateInstanceMutex);
502 T_Component comp = myDatabase->createInstance<T_Component>();
508 return T_Component();
511 template <
typename T_Component>
514 if (!myWriteStateInstance.isValid())
520 tbb::mutex::scoped_lock lock(theCreateInstanceMutex);
521 T_Component comp = myDatabase->createInstance<T_Component>();
524 myWriteStateInstance.addExtension(comp);
529 return T_Component();
532 template <
typename T_Component>
535 if (T_Component::ComponentType() < myStateComponents.size())
537 if (index < myStateComponents[T_Component::ComponentType()].size())
539 return myStateComponents[T_Component::ComponentType()][index];
546 template <
typename T_Component>
549 return myNextFrameState.getStateComponentList<T_Component>();
552 template <
typename T_Component>
555 return myCurrentFrameState.getStateComponentList<T_Component>();
558 template <
typename T_Component>
563 if (nextFrameState()->hasStateComponent<T_Component>())
567 return (nextFrameStateComponent<T_Component>()->isWritable());
574 return currentFrameState()->hasStateComponent<T_Component>();
585 template <
typename T_Component>
588 if (currentFrameState()->hasStateComponent<T_Component>())
590 return (dynamic_cast<const T_Component*>(currentFrameState()->getStateComponent<T_Component>()) !=
nullptr);
596 template <
typename T_Component>
599 T_Component* comp = nextFrameState()->getStateComponent<T_Component>(0);
600 if (comp && comp->isWritable())
610 template <
typename T_Component>
613 return currentFrameState()->getStateComponent<T_Component>(0);
620 void removeComponent(Legion::WriteStateInstance& set);
625 const DtUUID& uuid()
const;
626 void setUUID(
const DtUUID&);
628 void setGlobalId(
const DtString& s);
631 void setMarkingText(
const DtString& name);
632 const DtString& markingText()
const;
634 const DtString parentGlobalId()
const;
637 const DtUUID& nextFrameHostId()
const;
638 const DtUUID& currentFrameHostId()
const;
640 bool isBackgroundEntity()
const;
646 DtEntityType
entityType()
const {
return DtEntityType(objectType()); };
649 void setEntityId(
const DtEntityIdentifier& s);
650 DtEntityIdentifier entityId()
const;
653 virtual void setAwaitingTransfer(
bool);
656 return myAwaitingTransfer;
670 template <
typename T_Class>
671 void removeInstanceUpdatedCallback(Legion::InstanceHandle instanceHandle,
unsigned int callbackHandle);
672 template <
typename T_Class>
674 const std::vector<Legion::AttributeIndex>& attributeIndexFilter = std::vector<Legion::AttributeIndex>());
676 virtual void advanceFrame();
684 void setIsLocal(
bool b);
685 bool isLocal()
const;
689 return myPublishFlag;
694 return ((myPublishFlag == PublishAll) || (myPublishFlag == PublishComponentsOnly));
699 return myStateDataManager;
704 return myStateDataManager;
707 double absRealTime()
const;
711 return myCoordinateSystem;
716 return myWriteStateInstance;
721 return myReadStateInstance;
725 UInt64 legionGlobalId()
const;
728 virtual void clearComponents();
758 virtual void removeIffSystem();
762 virtual void removeUnderwaterAcousticsSystem();
774 virtual void convertToRemote();
777 virtual void convertToLocal();
787 virtual void shuttingDown();
794 static void addDefaultPublicDataFor(
const std::string& type,
const std::string& componentCreator);
795 static void removeDefaultPublicDataFor(
const std::string& type,
const std::string& componentCreator);
796 static std::set<std::string> defaultPublicDataFor(DtEntityType defaultEntityType,
const std::string& dislpayName,
const std::string& parameterType);
800 static void addPublicDataFor(
const std::string& type,
const std::string& componentCreator);
801 static void removePublicDataFor(
const std::string& type,
const std::string& componentCreator);
802 static std::set<std::string> additionalPublicDataFor(DtEntityType defaultEntityType,
const std::string& dislpayName,
const std::string& parameterType);
808 static void setDefaultMainComponentFor(
const std::string& type,
const std::string& defaultPublicData);
809 static std::string defaultMainComponentFor(DtEntityType defaultEntityType,
const std::string& dislpayName,
const std::string& type);
814 virtual void aboutToBeDeleted();
816 virtual void setPublishingOnLegionNetwork(
bool b);
819 return myPublishingOnLegionNetwork;
828 virtual DtStateData* currentFrameHostStateData()
const;
833 virtual void hostChanged(
const DtUUID& oldUUID,
const DtUUID& newUUID);
835 virtual void subordinatesChanged(
const std::vector<DtUUID>& oldSubordinates,
const std::vector<DtUUID>& newSubordinates);
847 virtual void completeRemoteConversion();
849 virtual void hostWasDeleted();
855 virtual void uuidChanged(
const DtUUID& oldUUID,
const DtUUID& newUUID);
864 boost::signals2::signal<void (const DtStateData*, const DtUUID& oldUUID, const DtUUID& newUUID)>
signal_hostChanged;
881 boost::signals2::signal<void (const DtStateData*, const std::vector<DtUUID>& added,
const std::vector<DtUUID>& removed)> signal_subordinatesChanged;
925 typedef std::map<std::string, std::set<std::string> >
PublicData;
947 #include <vrfStateData/stateData.inl>
bool isWritable()
Definition: stateData.h:202
UUID is a unique ID wrapper class.
Definition: rwUUID.h:226
bool myAdvancedFrame
Definition: stateData.h:910
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:63
T_Component * nextFrameStateComponent()
Definition: stateData.h:597
std::vector< T_Component * > getNextFrameStateComponentList() const
Definition: stateData.h:547
const DtSimulatedObjectStateComponent * myCurrentFrameSimulatedObjectStateComponent
Definition: stateData.h:937
DtExternalCurrentFrameState(DtStateData *sd)
Definition: stateData.h:263
Definition: stateDataTypes.h:23
unsigned long long SimStateID
Definition: stateData.h:339
std::vector< const T_Component * > getStateComponentList() const
Definition: stateData.h:279
const bool hasStateComponent() const
Definition: stateData.h:586
boost::signals2::scoped_connection mySubordinatesChangedConnection
Definition: stateData.h:917
boost::signals2::signal< void(SimStateID)> signal_preFrameAdvanced
Definition: stateData.h:867
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:211
int mySessionId
Definition: stateData.h:904
boost::signals2::signal< void(const DtStateData *)> signal_convertedToLocal
Definition: stateData.h:879
The DtLocationStateComponent interface contains the interface that all DtLocationStateComponents can ...
Definition: locationStateComponent.h:25
DtEntityType entityType() const
Definition: stateData.h:646
int getCurrentFrameNumberOfLegionComponents() const
Definition: stateData.h:375
const Coordinate_System * myCoordinateSystem
Definition: stateData.h:902
unsigned int StateComponentType
Definition: stateComponent.h:55
std::vector< std::vector< DtStateComponent * > > myStateComponents
Definition: stateData.h:906
int numberOfFrameStates() const
Definition: stateData.h:304
boost::signals2::signal< void(const DtStateData *)> signal_modified
Signal sent if this state had modified components.
Definition: stateData.h:873
PublishFlag myPublishFlag
Simulated locally vs. remote representation.
Definition: stateData.h:900
The DtSimulatedObjectStateComponent is an interface that all main components (those that are consider...
Definition: simulatedObjectStateComponent.h:21
T_Component createUnattachedInstance()
Definition: stateData.h:493
static tbb::mutex theCreateInstanceMutex
Definition: stateData.h:943
static PublicData theDefaultPublicData
Definition: stateData.h:926
Definition: stateData.h:342
Legion::SimulationDatabase * database()
Definition: stateData.h:767
PublishFlag publishFlag() const
Definition: stateData.h:687
static DefaultMainComponentMap theDefaultMainComponentMap
Definition: stateData.h:930
voidpf void uLong size
Definition: ioapi.h:39
const DtStateDataManager * stateDataManager() const
Definition: stateData.h:702
const DtFrameStateInterface * getStateComponent(DtStateComponent::StateComponentType scType, int index=0) const
Definition: stateData.h:171
DtFrameStateInterface * getStateComponent(DtStateComponent::StateComponentType scType, int index=0)
Definition: stateData.h:184
void setPublishFlag(PublishFlag b)
Only called during construction.
Definition: stateData.h:840
Legion::SimulationDatabase * myDatabase
Definition: stateData.h:891
bool hasStateComponent(bool checkWritable=false)
Definition: stateData.h:559
Definition: stateData.h:113
boost::signals2::signal< void(const DtStateData *)> signal_frameAdvanced
Signal sent regardless of whether or not this state had any modified components.
Definition: stateData.h:870
Contains the DtUUID class declaration.
PublishFlag
Definition: stateData.h:340
Legion::ReadStateInstance * myReadStateInstance
Definition: stateData.h:895
unsigned int componentCount() const
Definition: stateData.h:388
std::vector< std::vector< DtStateComponent * > > myCreatedStateComponents
Definition: stateData.h:907
T_Component findNextFrameLegionComponent(int index=0)
Definition: stateData.h:403
SimStateID id() const
Definition: stateData.h:665
const DtVrfObjectParameters * myParameters
Definition: stateData.h:933
T_Component createInstance()
Definition: stateData.h:512
Definition: stateData.h:343
T_Component findCurrentFrameLegionComponent(int index=0) const
Definition: stateData.h:416
void destroyInstance(const Legion::WriteStateInstance &wsi)
Definition: stateData.h:474
int getNextFrameNumberOfLegionComponents()
Definition: stateData.h:362
std::vector< const T_Component * > getCurrentFrameStateComponentList() const
Definition: stateData.h:553
static PublicData theAdditionalPublicData
Definition: stateData.h:927
Definition: objectType.h:27
boost::signals2::scoped_connection myHostChangedConnection
Definition: stateData.h:918
std::vector< T_Component * > getStateComponentList() const
Definition: stateData.h:152
boost::signals2::signal< void(const DtExternalFrameStateInterface *)> signal_externalFrameStateToBeDestroyed
Definition: stateData.h:97
DtStateComponent * getStateComponent(int index=0)
Definition: stateData.h:533
DtStateData * myCurrentFrameHostStateData
Definition: stateData.h:941
Definition: coordSystem.h:54
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:336
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:934
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
DtExternalNextFrameState * nextFrameState()
Definition: stateData.h:438
Legion::WriteStateInstance myWriteStateInstance
The basic data. This is what all components are hung off of if they are STE compliant.
Definition: stateData.h:894
std::atomic< unsigned int > myComponentNumber
Definition: stateData.h:915
boost::signals2::signal< void(const DtStateData *, const DtUUID &oldUUID, const DtUUID &newUUID)> signal_hostChanged
Signal sent when the host has changed.
Definition: stateData.h:864
std::map< std::string, std::string > DefaultMainComponentMap
Definition: stateData.h:929
const Coordinate_System * coordinateSystem() const
Definition: stateData.h:709
DtExternalCurrentFrameState myCurrentFrameState
Definition: stateData.h:888
boost::signals2::signal< void(const DtUUID &, const DtUUID &, SimStateID)> signal_uuidChanged
Definition: stateData.h:861
bool isWritable()
Definition: stateData.h:458
boost::signals2::signal< void(const DtStateData *)> signal_convertingToRemote
Definition: stateData.h:875
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:925
void destroyMainInstance()
Definition: stateData.h:463
Legion::ReadStateInstance * readStateInstance() const
Definition: stateData.h:719
DtStateDataManager * myStateDataManager
Definition: stateData.h:890
bool myMainComponentOnLegion
Definition: stateData.h:935
Definition: stateData.h:260
UInt64 myLegionGlobalId
Definition: stateData.h:914
DtExternalNextFrameState(DtStateData *sd)
Definition: stateData.h:116
Legion::WriteStateInstance writeStateInstance()
Definition: stateData.h:714
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:446
bool advancedFrame() const
Definition: stateData.h:433
Definition: stateDataTypes.h:28
Definition: stateComponent.h:51
boost::signals2::scoped_connection myUUIDChangedConnection
Definition: stateData.h:919
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:938
const DtExternalCurrentFrameState * currentFrameState() const
Definition: stateData.h:443
std::set< DtFrameStateInterface * > myRemoveStateComponents
Definition: stateData.h:908
boost::signals2::scoped_connection myHostWasDeletedConnection
Definition: stateData.h:920
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:110
std::vector< std::vector< DtFrameStateInterface * > > myFrameState
Definition: stateData.h:257
Definition: stateData.h:70
boost::signals2::signal< void(const DtStateData *)> signal_stateDataToBeDestroyed
Definition: stateData.h:866
bool myConvertToRemote
Definition: stateData.h:911
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:817
#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:654
bool myAwaitingTransfer
Definition: stateData.h:912
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:428
DtStateDataManager * stateDataManager()
Definition: stateData.h:697
void setObjectType(const DtObjectType &type)
Definition: stateData.h:644
const T_Component * getStateComponent(int index=0) const
The current state frame data.
Definition: stateData.h:137
bool myCleared
Definition: stateData.h:931
boost::signals2::signal< void(const DtStateData *)> signal_convertingToLocal
Definition: stateData.h:878
tbb::spin_rw_mutex myCurrentFrameHostStateDataMutex
Definition: stateData.h:942
DtExternalNextFrameState myNextFrameState
Even though this class contains the components, the frame classes will give access to those component...
Definition: stateData.h:887
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:104
DtSimulatedObjectStateComponent * myNextFrameSimulatedObjectStateComponent
Definition: stateData.h:940
boost::function< void(const std::vector< UInt32 > &)> DtInstanceUpdatedCallback
Definition: stateDataTypes.h:21
boost::signals2::signal< void(const DtStateData *)> signal_convertedToRemote
Definition: stateData.h:876
T_Component createMainInstance()
Definition: stateData.h:483
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:282
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:452
bool hasStateComponent() const
Definition: stateData.h:82
bool isPublishedOnNetwork() const
Definition: stateData.h:692
SimStateID mySimStateID
Definition: stateData.h:897
std::vector< std::vector< const DtFrameStateInterface * > > myFrameState
Definition: stateData.h:319
const T_Component * currentFrameStateComponent() const
Definition: stateData.h:611
This class holds the state data that represents each simulation object in the system.
Definition: stateDataManager.h:71
int numberOfFrameStates() const
Definition: stateData.h:244
boost::signals2::signal< void(const DtStateData *)> signal_firstFrameAdvance
Signal sent on the first frame advance.
Definition: stateData.h:859