15 #include <legionDataStore/writeStateInstance.h>
16 #include <legionDataStore/readStateInstance.h>
18 #include <boost/signals2.hpp>
20 #include <vlutil/vlPrint.h>
21 #include <vlpi/simulationAddress.h>
34 class WriteEntityRepository;
35 class ReadEntityRepository;
40 class SimulationDatabase;
48 class DtStateComponent;
50 class DtFrameStateInterface;
62 , SimulatedObjectStateComponent = 0
63 , EntityStateComponent = SimulatedObjectStateComponent
64 , EnvironmentalStateComponent = SimulatedObjectStateComponent
65 , AggregateStateComponent = SimulatedObjectStateComponent
66 , MetocServiceStateComponent = SimulatedObjectStateComponent
67 , AerodromeStateComponent = SimulatedObjectStateComponent
68 , SpotReportStateComponent = SimulatedObjectStateComponent
69 , OrbatStateComponent = SimulatedObjectStateComponent
70 , LocationStateComponent = 1
71 , EntityLocationStateComponent = LocationStateComponent
72 , EnvironmentalLocationStateComponent = LocationStateComponent
73 , StaticLocationStateComponent = LocationStateComponent
74 , HumanStateComponent = 2
75 , ArticulatedPartStateComponent = 3
76 , VrfStateComponent = 4
77 , StatePropertiesStateComponent = 5
78 , VrfGeometryStateComponent = 6
79 , SubordinateManagerStateComponent = 7
80 , RangeItemsStateComponent = 8
81 , CloudLayerStateComponent = 9
82 , TimeAndDateStateComponent = 10
83 , WeatherStateComponent = 11
84 , LaserDesignatorStateComponent = 12
85 , EmitterSystemStateComponent = 13
86 , IffStateComponent = 14
87 , ActiveSonarStateComponent = 15
88 , UnderwaterAcousticsStateComponent = 16
89 , SensorFieldOfViewStateComponent = 17
90 , RadioTransmitterStateComponent = 18
91 , TaskVisualizationStateComponent = 19
92 , TacticalSmokeStateComponent = 20
93 , DynamicTerrainStateComponent = 21
94 , RadioReceiverStateComponent = 22
95 , WindCorridorStateComponent = 23
96 , AirTurbulenceStateComponent = 24
97 , NavAidRadioTransmitterStateComponent = 25
98 , AisDataStateComponent = 26
99 , AircraftLightingStateComponent = 27
100 , LandSurfaceStateComponent = 28
101 , WaterSurfaceStateComponent = 29
102 , TroposphereStateComponent = 30
103 , SubsurfaceStateComponent = 31
104 , GroundVehicleLightingStateComponent = 32
105 , LaserLightStateComponent = 33
106 , SearchLightStateComponent = 34
107 , UserStateComponent = 64
119 virtual void advanceFrame();
127 virtual StateComponentType typeWithCreator()
const = 0;
130 virtual StateComponentType componentType()
const = 0;
142 virtual void setPublishingOnLegionNetwork(
bool );
146 return myPublishingOnLegionNetwork;
153 myIsRemoteComponent = b;
157 virtual void convertToRemote();
160 virtual void convertToLocal();
165 return myIsRemoteComponent;
173 virtual void completeSetup();
176 virtual void aboutToBeDeleted();
180 virtual void setId(
UInt64 id );
191 return myAdvancedFrame;
195 virtual void firstFrameAdvance();
201 UInt64 legionGlobalId()
const;
224 return myCoordinateSystem;
232 virtual bool isDoubleBuffered()
const;
249 virtual const char* stringType()
const = 0;
272 #define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent) \
273 constexpr static DtStateComponent::StateComponentType theComponentType = CreatedComponent; \
274 constexpr static const char* StringType() { return #CreatedComponent; } \
275 virtual DtStateComponent::StateComponentType typeWithCreator() const { return TypeWithCreator(); }; \
276 virtual DtStateComponent::StateComponentType componentType() const override { return ComponentType(); }; \
277 virtual const char* stringType() const override { return #CreatedComponent; }; \
278 static DtStateComponent::StateComponentType TypeWithCreator() { return (DtStateComponent::StateComponentType)((unsigned int)(theComponentCreatorType << 16) | theComponentType); }; \
279 static void SetCreatorType(UInt32 type) { theComponentCreatorType = type; }; \
280 constexpr static DtStateComponent::StateComponentType ComponentType() { return theComponentType; }; \
281 static UInt32 CreatorType() { return theComponentCreatorType; }; \
283 static UInt32 theComponentCreatorType; \
288 #define DEFINE_STATE_COMPONENT_HELPER(Component) \
289 static const char* StringType() { return #Component; } \
290 virtual DtStateComponent::StateComponentType typeWithCreator() const { return Component::TypeWithCreator(); }; \
291 virtual DtStateComponent::StateComponentType componentType() const override { return Component::ComponentType(); }; \
292 virtual DtStateComponent::StateComponentType setCreatorType(UInt32 type) const { return SetCreatorType(type); }; \
293 virtual const char* stringType() const { return #Component; }; \
294 constexpr static DtStateComponent::StateComponentType TypeWithCreator() { return Component::TypeWithCreator(); }; \
295 constexpr static DtStateComponent::StateComponentType ComponentType() { return Component::ComponentType(); }; \
296 static UInt32 SetCreatorType(UInt32 type) { Component::SetCreatorType(type); return type; };
315 virtual void registerLegionComponent( Legion::SimulationDatabase* ) = 0;
318 virtual void addAdditionalTableColumns( Legion::SimulationDatabase* ) = 0;
320 virtual bool autoCreateForRemoteObject()
const = 0;
325 template <
typename T_StateComponent,
bool T_AutoCreateForRemoteObject = true>
336 T_StateComponent::registerLegionComponent(db);
342 T_StateComponent::addAdditionalTableColumns(db);
348 return T_AutoCreateForRemoteObject;
385 virtual void markModified();
394 virtual const char* stringType()
const = 0;
414 signal_componentModified(
this );
419 myMarkedForRemoval = b;
424 return myMarkedForRemoval;
436 return myAdvancedFrame;
442 myAdvancedFrame =
true;
446 virtual void convertToRemote();
449 virtual void convertToLocal();
451 virtual void aboutToBeDeleted();
481 bool myMarkedForRemoval =
false;
488 template <
typename T_Component>
unsigned int StateComponentType
Definition: stateComponent.h:56
virtual bool forceAdvance()
Override to force an advance, even if not modified.
Definition: stateComponent.h:228
const DtStateData * stateData() const
Returns a const pointer to the owning state data.
Definition: stateComponent.h:204
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:64
void emitComponentUpdated()
Emits the signal_componentModified signal to notify observers of a state change.
Definition: stateComponent.h:412
void setLegionGlobalId(UInt64 d)
Sets the Legion global entity ID for this state.
Definition: stateComponent.h:379
void setId(UInt64 id)
Sets the unique identifier for this frame state instance.
Definition: stateComponent.h:399
virtual const DtFrameStateInterface * currentFrameState() const
Returns the read-only current frame state. Throws if not double-buffered.
Definition: stateComponent.h:234
Exception thrown when a required method has not been implemented.
Definition: stateDataTypes.h:30
const Coordinate_System * coordinateSystem() const
Returns the coordinate system associated with this component.
Definition: stateComponent.h:222
virtual void advanceFrame() override
Advances the double-buffered state, swapping buffers if modified or if forceAdvance() returns true...
Definition: stateComponent.h:535
virtual void addAdditionalTableColumns(Legion::SimulationDatabase *db) override
Delegates additional table column registration to T_StateComponent.
Definition: stateComponent.h:340
UInt64 stateId() const
Returns the state ID of the owning entity.
Definition: stateComponent.h:374
bool myAdvancedFrame
True if this frame state has been advanced at least one frame.
Definition: stateComponent.h:480
virtual Legion::WriteStateInstance writeStateInstance()
Returns the Legion write state instance for this component. Throws if not supported.
Definition: stateComponent.h:240
bool myAdvancedFrame
True if this component has advanced at least one frame.
Definition: stateComponent.h:266
virtual void setIsRemoteComponent(bool b)
Sets whether this component represents a remote (non-authoritative) entity.
Definition: stateComponent.h:151
unsigned int UInt32
32-bit unsigned integer type.
Definition: stateDataTypes.h:21
Default creator implementation for a state component type. T_StateComponent is the concrete component...
Definition: stateComponent.h:326
void setMarkedForRemoval(bool b)
Definition: stateComponent.h:417
static void registerLegionComponent(Legion::SimulationDatabase *)
Default no-op Legion component registration. Override in subclasses as needed.
Definition: stateComponent.h:558
virtual Legion::WriteStateInstance writeStateInstance()
Definition: stateComponent.h:409
virtual void removeAdditionalStateComponents()
Override this method to destroy any allocated legion extensions that need to be destroyed.
Definition: stateComponent.h:245
virtual bool isDoubleBuffered() const override
Always returns true; this component is double-buffered.
Definition: stateComponent.h:530
boost::signals2::signal< void(const DtFrameStateInterface *)> signal_componentModified
Emitted when this frame state is modified.
Definition: stateComponent.h:456
virtual void frameAdvanced()
Called during frame advance to record that this state has been advanced.
Definition: stateComponent.h:440
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
bool myPublishingOnLegionNetwork
True if this component is publishing data on the Legion network.
Definition: stateComponent.h:264
bool publishingOnLegionNetwork() const
Returns whether this component is currently publishing on the Legion network.
Definition: stateComponent.h:144
unsigned long long UInt64
64-bit unsigned integer type.
Definition: stateDataTypes.h:19
bool isWritable() const
Returns true if this frame state instance is writable.
Definition: stateComponent.h:371
virtual void setId(UInt64 id)
Sets the unique identifier for this component within a list. Use -1 if not applicable.
bool advancedFrame() const
Returns true if this component has been advanced at least one frame.
Definition: stateComponent.h:189
virtual bool autoCreateForRemoteObject() const override
Returns T_AutoCreateForRemoteObject template parameter value.
Definition: stateComponent.h:346
boost::signals2::signal< void(DtFrameStateInterface *)> signal_stateComponentAboutToBeDeleted
Emitted just before this frame state is deleted.
Definition: stateComponent.h:454
boost::signals2::signal< void(DtStateComponent *)> signal_stateComponentAboutToBeDeleted
Emitted just before this component is deleted.
Definition: stateComponent.h:133
virtual void makeWritable()
Override to make component writable.
Definition: stateComponent.h:461
virtual UInt64 id() const
Returns the unique identifier of this frame state instance.
Definition: stateComponent.h:401
bool cleared() const
Returns true if aboutToBeDeleted() has been called on this frame state.
Definition: stateComponent.h:428
Definition: coordSystem.h:54
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
#define DEFINE_STATE_COMPONENT_HELPER(Component)
Macro to delegate state component type methods to an existing component type. Used in creator and tem...
Definition: stateComponent.h:288
UInt64 legionGlobalId() const
Returns the Legion global entity ID associated with this state.
Definition: stateComponent.h:376
bool myIsWritable
True if this frame state instance is writable (i.e., the next-frame instance).
Definition: stateComponent.h:476
DtStateData * stateData()
Returns a mutable pointer to the owning state data.
Definition: stateComponent.h:216
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:489
DtStateData * myStateData
Pointer to the owning state data object.
Definition: stateComponent.h:256
UInt64 myStateId
The state ID of the owning entity.
Definition: stateComponent.h:472
virtual DtStateComponent::StateComponentType type() const
Returns the component type identifier. Delegates to componentType().
Definition: stateComponent.h:388
virtual void updateDataStorage()=0
Implement to update data storage. Called from advanceFrame.
virtual bool isModified() const
Returns true if this frame state has been modified since the last advance.
Definition: stateComponent.h:381
The creator that is used to create a state component.
Definition: stateComponent.h:299
StateComponentTypeEnum
Enumeration of all built-in state component type IDs. User-defined components should start at UserSta...
Definition: stateComponent.h:59
virtual const DtFrameStateInterface * nextFrameState() const
Returns the read-only next frame state. Throws if not double-buffered.
Definition: stateComponent.h:238
virtual void setId(UInt64 id) override
Sets the unique identifier on this component and propagates it to both frame states.
Definition: stateComponent.h:502
bool myCleared
True if aboutToBeDeleted() has been called.
Definition: stateComponent.h:262
virtual void markModified()
Marks this frame state as modified and notifies the owning state data.
Definition: stateComponent.h:52
virtual void registerLegionComponent(Legion::SimulationDatabase *db) override
Delegates Legion component registration to T_StateComponent.
Definition: stateComponent.h:334
bool isRemoteComponent() const
Returns true if this component represents a remote (non-authoritative) entity.
Definition: stateComponent.h:163
void setIsWritable(bool b)
Sets whether this frame state instance is writable.
Definition: stateComponent.h:369
UInt64 myLegionId
The Legion global entity ID.
Definition: stateComponent.h:474
virtual void clearModified()
Clears the modified flag.
Definition: stateComponent.h:383
virtual Legion::ReadStateInstance readStateInstance() const
If supported, the read or write state legion instance of this component.
Definition: stateComponent.h:408
bool advancedFrame() const
Returns true if this frame state has been advanced at least one frame.
Definition: stateComponent.h:434
bool markedForRemoval() const
Definition: stateComponent.h:422
#define DT_DLL_vrfStateData
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfStateDataDefines.h:29
virtual UInt64 id() const
Returns the unique identifier of this component, or -1 if not part of a list.
Definition: stateComponent.h:183
virtual void updateStateData(DtStateData *)=0
Implement to update data storage to the new state data.
const Coordinate_System * myCoordinateSystem
Coordinate system used for spatial calculations.
Definition: stateComponent.h:258
bool myCleared
True if aboutToBeDeleted() has been called.
Definition: stateComponent.h:478
virtual DtStateComponent * create(DtStateData *sd) override
Creates a new instance of T_StateComponent associated with the given state data.
Definition: stateComponent.h:331
virtual void addAdditionalStateComponents()
Override to create any additional state sub-components needed by this component.
Definition: stateComponent.h:242
DtStateData * myStateData
Pointer to the owning state data object.
Definition: stateComponent.h:483
virtual DtFrameStateInterface * nextFrameState()
Returns the writable next frame state. Throws if not double-buffered.
Definition: stateComponent.h:236
bool cleared() const
Returns true if this component has been cleared (aboutToBeDeleted has been called).
Definition: stateComponent.h:210
virtual bool forceAdvance() override
Override to force an advance, even if not modified.
Definition: stateComponent.h:533
static void addAdditionalTableColumns(Legion::SimulationDatabase *)
Default no-op for adding additional table columns. Override in subclasses as needed.
Definition: stateComponent.h:560
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
UInt64 myId
Unique identifier for this frame state instance.
Definition: stateComponent.h:470
UInt64 myId
Unique identifier of this component within a list; -1 if not applicable.
Definition: stateComponent.h:254
bool myIsRemoteComponent
True if this component represents a remote (non-authoritative) entity.
Definition: stateComponent.h:260
virtual void setStateData(DtStateData *sd) override
Sets the owning state data and propagates the update to both double-buffered frame states...
Definition: stateComponent.h:519
boost::signals2::signal< void(DtStateComponent *)> signal_componentModified
Emitted when this component's state is modified during frame advance.
Definition: stateComponent.h:135
virtual void setStateData(DtStateData *)
Sets the owning state data. Only succeeds if the current state data is nullptr; otherwise a no-op...