VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
aggregateStateComponent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
12 #include "geometry/extent.h"
13 
14 namespace makVrf
15 {
17  {
19  : myFormation(DtOtherAggregateFormation)
20  , myAggregateState(DtOtherAggregateState)
21  {
22  }
23 
26  , myFormationName(orig.myFormationName)
27  , myAggregateState(orig.myAggregateState)
28  , myFormation(orig.myFormation)
29  , myFormationState(orig.myFormationState)
30  {
31  }
32 
34  {
36 
37  myFormationState = rhs.myFormationState;
38  myFormationName = rhs.myFormationName;
39  myFormation = rhs.myFormation;
40  myAggregateState = rhs.myAggregateState;
41 
42  return *this;
43  }
44 
45  DEFINE_REF_ACCESSORS(DtFormationState, formationState, FormationState)
46  DEFINE_ACCESSOR_MUTATOR(DtAggregateFormation, formation, Formation)
47  DEFINE_ACCESSOR_MUTATOR(DtString, formationName, FormationName)
48  DEFINE_ACCESSOR_MUTATOR(DtAggregateState, aggregateState, AggregateState)
49 
50  protected:
51  DtFormationState myFormationState;
52 
53  DtAggregateFormation myFormation;
54  DtString myFormationName;
55  DtAggregateState myAggregateState;
56  };
57 
61  {
62  public:
64 
66  : DtEntityStateComponent(storage)
67  {
68  }
69 
71  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtString, formationName, FormationName)
72  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtAggregateState, aggregateState, AggregateState)
73  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtAggregateFormation, formation, Formation)
74  };
75 
78  {
79  public:
81 
83  const DtAggregateStateComponentData& aggregateFrameState() const { return myAggregateData; };
84  DtAggregateStateComponentData& aggregateFrameState() { return myAggregateData; };
85 
86  const DtFormationState& formationState() const;
87  DtFormationState& formationState();
88 
89  const DtString& formationName() const;
90  void setFormationName(const DtString&);
91 
92  const DtAggregateState& aggregateState() const;
93  void setAggregateState(const DtAggregateState&);
94 
95  const DtAggregateFormation& formation() const;
96  void setFormation(const DtAggregateFormation&);
97 
98  protected:
100  };
101 
104  {
105  public:
107 
109  const DtAggregateStateComponentData& aggregateFrameState() const { return myAggregateData; };
110 
111  const DtFormationState& formationState() const;
112  const DtString& formationName() const;
113  const DtAggregateState& aggregateState() const;
114  const DtAggregateFormation& formation() const;
115 
116  protected:
119  {
120  myAggregateData = data;
121  }
122 
123  protected:
125  };
126 
130  {
131  public:
134 
135  bool isDoubleBuffered() { return true; };
136  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
137  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
138  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
139 
141  {
142  if (myNextFrameState.isWritable())
143  {
144  myCurrentFrameState.advanceAggregateFrame(myNextFrameState.aggregateFrameState());
145  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
146  }
147 
148  myCurrentFrameState.checkForUpdatedItems();
149  myCurrentFrameState.emitComponentUpdated();
150  }
151 
153  {
154  myCurrentFrameState.updateStateData(sd);
155  myNextFrameState.updateStateData(sd);
156  }
157 
158  Legion::WriteStateInstance writeStateInstance() override { return myWriteAggregateStateRepository; };
159 
161  virtual void convertToRemote();
162 
164  virtual void convertToLocal();
165 
166  virtual void addAdditionalStateComponents() override;
167 
168  virtual bool forceAdvance() override;
169 
170  virtual void aboutToBeDeleted() override
171  {
173  myCurrentFrameState.aboutToBeDeleted();
174  myNextFrameState.aboutToBeDeleted();
175  }
176 
177  protected:
180  LOM::WriteEntityRepository myWriteAggregateStateRepository;
181  };
182 
186 }
2) Define the next frame class. This will be used for write access.
Definition: entityStateComponent.h:103
3) Define the current frame class. This will be used for read access.
Definition: aggregateStateComponent.h:103
DtAggregateStateComponentData(const DtAggregateStateComponentData &orig)
Definition: aggregateStateComponent.h:24
DtAggregateStateComponentData operator=(const DtAggregateStateComponentData &rhs)
Definition: aggregateStateComponent.h:33
DtAggregateStateComponentNextFrame myNextFrameState
Definition: aggregateStateComponent.h:179
Definition: formationState.h:41
DtAggregateStateComponentData()
Definition: aggregateStateComponent.h:18
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: aggregateStateComponent.h:129
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: entityStateComponent.h:70
const DtAggregateStateComponentData & aggregateFrameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: aggregateStateComponent.h:109
DtAggregateState myAggregateState
Definition: aggregateStateComponent.h:55
Definition: stateComponent.h:257
void updateDataStorage()
Implement to update data storage. Called from advanceFrame.
Definition: aggregateStateComponent.h:140
2) Define the next frame class. This will be used for write access.
Definition: aggregateStateComponent.h:77
Definition: aggregateStateComponent.h:16
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: aggregateStateComponent.h:60
#define UNDEFINED_RETURNREF_ACCESSORS(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:40
DtAggregateStateComponentData myAggregateData
Definition: aggregateStateComponent.h:99
const DtFrameStateInterface * currentFrameState() const
Definition: aggregateStateComponent.h:136
Definition: entityStateComponent.h:25
DtStateComponentCreator< DtAggregateStateComponentImplementation > DtAggregateStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: aggregateStateComponent.h:185
bool isDoubleBuffered()
Definition: aggregateStateComponent.h:135
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: aggregateStateComponent.h:152
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:336
Legion::WriteStateInstance writeStateInstance() override
Definition: aggregateStateComponent.h:158
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:219
DtAggregateStateComponentData & aggregateFrameState()
Definition: aggregateStateComponent.h:84
3) Define the current frame class. This will be used for read access.
Definition: entityStateComponent.h:171
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:370
void advanceAggregateFrame(const DtAggregateStateComponentData &data)
Definition: aggregateStateComponent.h:118
DtAggregateStateComponentData myAggregateData
Definition: aggregateStateComponent.h:124
virtual void aboutToBeDeleted()
virtual const DtFrameStateInterface * nextFrameState() const
Definition: aggregateStateComponent.h:138
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
const DtAggregateStateComponentData & aggregateFrameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: aggregateStateComponent.h:83
#define DEFINE_REF_ACCESSORS(ReturnType, Method, Member)
Definition: doubleBufferedDataStorage.h:13
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
virtual void aboutToBeDeleted() override
Definition: aggregateStateComponent.h:170
DtAggregateFormation myFormation
Definition: aggregateStateComponent.h:53
DtAggregateStateComponentCurrentFrame myCurrentFrameState
Definition: aggregateStateComponent.h:178
Contains the declaration of the DtExtent class.
virtual DtFrameStateInterface * nextFrameState()
Definition: aggregateStateComponent.h:137
#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
DtEntityStateComponentData & operator=(const DtEntityStateComponentData &rhs)
Definition: entityStateComponent.h:43
DtFormationState myFormationState
Definition: aggregateStateComponent.h:51
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:282
DtString myFormationName
Definition: aggregateStateComponent.h:54
LOM::WriteEntityRepository myWriteAggregateStateRepository
Definition: aggregateStateComponent.h:180

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)