10 #include <vlpi/disEnums.h>
11 #include <legionStandardOM/sets/writeEntityRepository.hpp>
12 #include "legionStandardOM/sets/readEntityRepository.hpp"
13 #include "legionDataStore/view.h"
14 #include <tbb/spin_mutex.h>
18 class ReadEntityRepository;
39 : myUUID(
DtUUID::nullUUID())
41 , myCheckForNameReservation(true)
47 : myGlobalId(orig.myGlobalId)
49 , myMarkingText(orig.myMarkingText)
50 , myCallsign(orig.myCallsign)
51 , myEntityId(orig.myEntityId)
52 , myIsLocal(orig.myIsLocal)
53 , myUserData(orig.myUserData)
54 , myOrbatId(orig.myOrbatId)
55 , myCheckForNameReservation(orig.myCheckForNameReservation)
56 , mySimEngineAddress(orig.mySimEngineAddress)
113 DtString myMarkingText;
117 DtEntityIdentifier myEntityId;
123 unsigned long long myUserData = 0;
125 unsigned long long myOrbatId = 0;
127 bool myCheckForNameReservation;
129 DtSimulationAddress mySimEngineAddress;
149 : DtSimulatedObjectStateComponent(storage)
150 , myUUIDColumn(0xFFFFFFFF)
151 , myIsClutterEntityColumn(0xFFFFFFFF)
167 virtual const std::set<DtUUID> attachments()
const {
throw DtUnimplementedMethod(
"std::set<DtUUID> attachments() is not implemented for this class."); };
177 virtual void removeAttachment(
const DtUUID&) {
throw DtUnimplementedMethod(
"void removeAttachment(const DtUUID&) is not implemented for this class."); };
184 mutable boost::signals2::signal<void (int oldState, int newState, makVrf::SimStateID)> signal_damageStateChanged;
226 template <
typename T_BaseComponent>
247 const bool& isLocal()
const;
250 void setIsLocal(
const bool&);
253 const bool& checkForNameReservation()
const;
256 void setCheckForNameReservation(
const bool&);
268 const DtUUID& uuid()
const;
271 void setUUID(
const DtUUID&);
274 const bool isClutterEntity()
const;
277 void setIsClutterEntity(
const bool&);
280 virtual const DtString& sidc()
const override;
282 virtual void setSidc(
const DtString&)
override;
285 const DtString& markingText()
const;
288 void setMarkingText(
const DtString&);
297 const DtForceType forceType()
const;
300 void setForceType(
const DtForceType&);
303 const UInt32 appearanceBits()
const;
309 void setAppearanceBits(
const UInt32&);
312 const DtEntityType
entityType()
const {
return objectType(); };
314 const DtEntityType objectType()
const;
317 void setEntityType(
const DtEntityType&);
320 const DtEntityIdentifier& entityId()
const;
323 void setEntityId(
const DtEntityIdentifier&);
326 const UInt32 capabilities()
const;
329 void setCapabilities(
const UInt32&);
332 const DtEntityType guise()
const;
335 void setGuise(
const DtEntityType&);
341 const DtUUID& superior()
const;
344 void setSuperior(
const DtUUID&);
347 const unsigned long long userLongLongData()
const;
350 void setUserLongLongData(
const unsigned long long&);
353 const unsigned long long orbatId()
const;
356 void setOrbatId(
const unsigned long long&);
362 const DtSimulationAddress simEngineAddress()
const override;
365 void setSimEngineAddress(
const DtSimulationAddress&)
override;
369 virtual void setAppearance(
const DtAppearance& app);
376 virtual void makeWritable();
381 virtual void makeReadOnly();
403 template <
typename T_BaseComponent>
423 const bool& isLocal()
const;
425 const bool& checkForNameReservation()
const;
429 const DtUUID& uuid()
const;
434 const DtString& markingText()
const;
436 virtual const DtString& sidc()
const override;
440 const DtForceType forceType()
const;
442 const DtEntityType
entityType()
const {
return DtEntityType(objectType()); };
444 const DtEntityType objectType()
const;
446 const DtEntityIdentifier& entityId()
const;
448 const UInt32 appearanceBits()
const;
450 const bool isClutterEntity()
const;
452 const UInt32 capabilities()
const;
454 const DtEntityType guise()
const;
456 const unsigned long long userLongLongData()
const;
458 const unsigned long long orbatId()
const;
463 const DtSimulationAddress simEngineAddress()
const override;
466 const DtUUID& superior()
const;
473 void addAttachment(
const DtUUID&);
476 void removeAttachment(
const DtUUID&);
479 const std::set<DtUUID> attachments()
const;
489 bool checkForUpdatedItems();
497 const DtUUID _uuid()
const;
503 const DtString _markingText()
const;
506 const DtEntityIdentifier _entityId()
const;
510 bool checkEntityIdChanged();
513 bool checkUUIDChanged();
516 bool checkForceChanged();
519 bool checkMarkingTextChanged();
522 bool checkDamageStateChanged();
525 bool checkIsClutterChanged();
533 void handleDataUpdated(
const std::vector<UInt32>& attributesUpdated);
542 void completeSetup();
556 void setSuperior(
const DtUUID&);
624 virtual void updateDataStorage()
override;
630 myCurrentFrameState.updateStateData(sd);
631 myNextFrameState.updateStateData(sd);
640 static void addAdditionalTableColumns(Legion::SimulationDatabase*);
647 virtual Legion::WriteStateInstance
writeStateInstance()
override {
return myWriteEntityStateRepository; };
653 virtual void convertToRemote()
override;
659 virtual void convertToLocal()
override;
662 virtual void addAdditionalStateComponents()
override;
668 myCurrentFrameState.aboutToBeDeleted();
669 myNextFrameState.aboutToBeDeleted();
687 #define _ENTITY_STATE_COMPONENT 1
688 #include "vrfStateData/entityStateComponent.inl"
Write-access (next-frame) entity state component template.
Definition: entityStateComponent.h:227
UUID is a unique ID wrapper class.
Definition: uuid.h:59
boost::signals2::signal< void(const DtFrameStateInterface *)> signal_attachmentsChanged
Emitted when the set of attached entities changes.
Definition: entityStateComponent.h:189
unsigned int myCallbackHandle
Handle returned by the Legion instance-updated callback registration; 0 if not registered.
Definition: entityStateComponent.h:568
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:64
LOM::WriteEntityRepository myWriteEntityStateRepository
Legion write-access repository for this entity's attribute set.
Definition: entityStateComponent.h:385
const DtEntityType entityType() const
Returns the DIS entity type (alias for objectType()).
Definition: entityStateComponent.h:442
const DtEntityStateComponentData & frameState() const
Returns the next-frame state data block (const overload).
Definition: entityStateComponent.h:239
Exception thrown when a required method has not been implemented.
Definition: stateDataTypes.h:30
DtString myMarkingText
DIS-style marking text (max 32 chars as enforced by Legion).
Definition: entityStateComponent.h:113
tbb::spin_mutex myCompleteSetupMutex
Mutex serialising concurrent calls to completeSetup().
Definition: entityStateComponent.h:579
unsigned long long myOrbatId
Order-of-Battle identifier; not reflected on the network.
Definition: entityStateComponent.h:125
bool myCheckForNameReservation
When true, HLA name reservation must complete before the object is published.
Definition: entityStateComponent.h:127
bool myIsClutterEntity
Cached clutter-entity flag for change detection.
Definition: entityStateComponent.h:570
int myForceId
Cached DIS force type for change detection.
Definition: entityStateComponent.h:564
Definition: stateComponent.h:63
virtual void addAttachment(const DtUUID &)
Records that uuid is attached to this entity.
Definition: entityStateComponent.h:174
Abstract base interface for the entity state component.
Definition: entityStateComponent.h:141
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
The DtSimulatedObjectStateComponent is an interface that all main components (those that are consider...
Definition: simulatedObjectStateComponent.h:21
UInt32 myIsClutterEntityColumn
Legion attribute column index for the ClutterEntity field; 0xFFFFFFFF until initialised.
Definition: entityStateComponent.h:214
DtEntityStateComponentData(const DtEntityStateComponentData &orig)
Copy constructor. Performs a member-wise deep copy of orig.
Definition: entityStateComponent.h:46
bool isDoubleBuffered()
Returns true; this component uses double-buffered state.
Definition: entityStateComponent.h:610
boost::signals2::scoped_connection myCompleteSetupConnection
Scoped connection to signal_firstFrameAdvance used to defer completeSetup().
Definition: entityStateComponent.h:577
boost::signals2::signal< void(const DtUUID &oldSuperior, const DtUUID &newSuperior)> signal_superiorChanged
Emitted when the superior (parent) entity UUID changes.
Definition: entityStateComponent.h:195
boost::signals2::signal< void(bool oldIsClutter, bool newIsClutter)> signal_isClutterChanged
Emitted when the clutter-entity flag changes.
Definition: entityStateComponent.h:201
virtual void setEntityType(const DtEntityType &ot) override
Sets the DIS entity type.
Definition: entityStateComponent.h:171
const DtEntityStateComponentData & frameState() const
Returns the current-frame state data block.
Definition: entityStateComponent.h:420
DtString mySidc
Visual Sidc code.
Definition: entityStateComponent.h:111
Plain-old-data container for all serializable entity state fields.
Definition: entityStateComponent.h:30
void advanceFrame(const DtEntityStateComponentData &data)
Copies data into the current-frame cache (called by updateDataStorage()).
Definition: entityStateComponent.h:547
Double-buffered entity state component implementation.
Definition: entityStateComponent.h:596
std::set< DtUUID > myAttachments
Thread-safe set of UUIDs of currently attached entities.
Definition: entityStateComponent.h:573
virtual void aboutToBeDeleted() override
Notifies both frame states that the component is about to be destroyed.
Definition: entityStateComponent.h:665
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
DtEntityStateComponentData()
Constructs a default-initialized data block.
Definition: entityStateComponent.h:38
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Macro to define all required static and virtual state component type methods. Place in the public sec...
Definition: stateComponent.h:272
Read-only (current-frame) entity state component template.
Definition: entityStateComponent.h:404
virtual Legion::WriteStateInstance writeStateInstance() override
Returns the Legion write state instance handle for this entity.
Definition: entityStateComponent.h:647
DtString myGlobalId
Accessor/mutator for the network-layer global object identifier string.
Definition: entityStateComponent.h:109
boost::signals2::signal< void(const DtString &, const DtString &, makVrf::SimStateID)> signal_callsignChanged
Emitted when the entity's callsign changes.
Definition: entityStateComponent.h:208
DtEntityStateComponentNextFrame myNextFrameState
Next-frame (write-access) entity state.
Definition: entityStateComponent.h:676
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:489
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
DtUUID mySuperior
UUID of the superior (parent) entity; updated each frame if changed.
Definition: entityStateComponent.h:562
DtEntityIdentifier myEntityId
DIS entity identifier (site / host / entity number).
Definition: entityStateComponent.h:117
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Defines an undefined virtual by-value accessor and an undefined virtual setter, both throwing DtUnimp...
Definition: doubleBufferedDataStorage.h:103
virtual void aboutToBeDeleted()
Called when the component is about to be deleted; emits signal_stateComponentAboutToBeDeleted.
unsigned long long SimStateID
Definition: entityStateComponent.h:32
LOM::ReadEntityRepository myReadEntityStateRepository
Legion read-access repository for this entity's attribute set.
Definition: entityStateComponent.h:560
virtual const DtFrameStateInterface * currentFrameState() const override
Returns the current-frame state interface (read-only).
Definition: entityStateComponent.h:612
UInt32 myUUIDColumn
Legion attribute column index for the UUID field; 0xFFFFFFFF until initialised.
Definition: entityStateComponent.h:212
virtual void updateStateData(DtStateData *sd) override
Propagates a new DtStateData pointer into both frame states.
Definition: entityStateComponent.h:628
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Defines an undefined virtual const-reference accessor and an undefined virtual setter, both throwing DtUnimplementedMethod and requiring overrides in a derived class.
Definition: doubleBufferedDataStorage.h:112
LOM::WriteEntityRepository myWriteEntityStateRepository
Legion write repository owned by this implementation instance.
Definition: entityStateComponent.h:678
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Defines a const reference accessor and an inline setter for a member variable.
Definition: doubleBufferedDataStorage.h:37
DtEntityStateComponentData myData
Cached copy of the entity state data for this frame.
Definition: entityStateComponent.h:389
DtStateComponentCreator< DtEntityStateComponentImplementation > DtEntityStateComponentCreator
Factory type that creates DtEntityStateComponentImplementation instances.
Definition: entityStateComponent.h:684
DtEntityStateComponentData myData
Cached copy of the entity state data for the current frame.
Definition: entityStateComponent.h:581
DtEntityStateComponentCurrentFrame myCurrentFrameState
Current-frame (read-only) entity state.
Definition: entityStateComponent.h:674
DtString myCallsign
Optional callsign; stored independently from the Legion data store.
Definition: entityStateComponent.h:115
virtual DtFrameStateInterface * nextFrameState() override
Returns the next-frame state interface (read-write).
Definition: entityStateComponent.h:614
DtSimulationAddress mySimEngineAddress
Simulation engine address (site/host); defaults to the entity identifier's simulation address...
Definition: entityStateComponent.h:129
#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
DtUUID myUUID
Simulation-wide UUID; backed by a raw byte array in the Legion data store.
Definition: entityStateComponent.h:119
DtEntityStateComponentData & frameState()
Returns the next-frame state data block (mutable overload).
Definition: entityStateComponent.h:244
int myDamageState
Cached damage state for change detection.
Definition: entityStateComponent.h:566
DtEntityStateComponentData & operator=(const DtEntityStateComponentData &rhs)
Assignment operator. Performs a member-wise deep copy of rhs.
Definition: entityStateComponent.h:64
unsigned long long myUserData
Application-defined 64-bit integer user payload; not reflected on the network.
Definition: entityStateComponent.h:123
virtual const DtFrameStateInterface * nextFrameState() const override
Returns the next-frame state interface (read-only overload).
Definition: entityStateComponent.h:616
bool myIsLocal
true when this entity is locally owned and published by this simulation process.
Definition: entityStateComponent.h:121
DtUUID mySuperior
UUID of the superior (parent) entity; not double-buffered.
Definition: entityStateComponent.h:387
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
tbb::spin_rw_mutex myAttachmentsMutex
Mutex protecting myAttachments from concurrent access.
Definition: entityStateComponent.h:575
const DtEntityType entityType() const
Returns the DIS entity type (alias for objectType()).
Definition: entityStateComponent.h:312
This class holds the state data that represents each simulation object in the system.
Definition: stateDataManager.h:76