17 #include <pia/reckoning/reckoning_definitions.h> 18 #include <pia/reckoning/reckoning_ReckoningCloneElementBase.h> 19 #include <pia/clone/clone_SerializePolicyDefinition.h> 20 #include <pia/clone/clone_VoidMemberConcealer.h> 21 #include <pia/clone/clone_CloneProtocol.h> 101 typename ReckoningStrategy_,
102 typename SerializePolicy_ = clone::HostByteOrderSerializePolicy<typename ReckoningStrategy_::Sample> >
115 typedef typename ReckoningStrategy::Value
Value;
121 typedef typename ReckoningStrategy::Sample
Sample;
133 typedef typename ReckoningStrategy::Work
Work;
194 nn::Result
SetValue(
const Value& value,
const SetValueArg* cpSetValueArg = NULL);
204 return *m_ValueWork.GetT1Ptr();
213 return PIA_IS_VALID_POINTER(m_pReckoningStrategy);
217 virtual size_t GetSize()
const 219 return SerializePolicy::GetSize();
221 virtual void Serialize(
void* pBuffer,
const ReckoningSendToken* cpToken);
222 virtual void ClearValue()
224 m_ValueWork = clone::VoidMemberConcealer<Value, Work>();
228 virtual void Deserialize(ReckoningSendToken* pToken,
const void* cpData);
229 virtual void OnUpdateSample(
int idx);
233 SampleReckoningSendToken<Sample> m_aSampleBuffer[
BUFFER_SIZE];
235 ReckoningStrategy* m_pReckoningStrategy;
237 clone::VoidMemberConcealer<Value, Work> m_ValueWork;
245 template <
typename ReckoningStrategy,
typename SerializePolicy>
248 m_pReckoningStrategy(pReckoningStrategy),
253 for (u32 i = 0; i < static_cast<u32>(
BUFFER_SIZE); ++i)
255 m_aSampleBuffer[i].Init(
this);
256 m_apToken[i] = &m_aSampleBuffer[i];
261 template <
typename ReckoningStrategy,
typename SerializePolicy>
268 m_pReckoningStrategy = pReckoningStrategy;
269 return ResultSuccess();
273 template <
typename ReckoningStrategy,
typename SerializePolicy>
277 nn::Result r = SetValueCore(&isSend);
284 bool isReliable =
false;
285 bool isSample = m_pReckoningStrategy->CheckSample(&isReliable, value, cpSetValueArg, accessor, clock, m_ValueWork.GetT2Ptr());
289 ReckoningSendToken* pToken = AssignTokenForSend(&idx, isReliable);
290 PIA_ASSERT(pToken != NULL && idx == 0);
292 SampleReckoningSendToken<Sample>* pSampleToken =
static_cast<SampleReckoningSendToken<Sample>*
>(pToken);
293 m_pReckoningStrategy->MakeSample(pSampleToken->GetSamplePtr(), value, cpSetValueArg, accessor, clock, m_ValueWork.GetT2Ptr());
294 m_pReckoningStrategy->OnUpdateSample(accessor, idx, m_ValueWork.GetT2Ptr());
302 template <
typename ReckoningStrategy,
typename SerializePolicy>
305 const SampleReckoningSendToken<Sample>* cpSampleToken =
static_cast<const SampleReckoningSendToken<Sample>*
>(cpToken);
306 SerializePolicy::Serialize(pBuffer, cpSampleToken->GetSample());
310 template <
typename ReckoningStrategy,
typename SerializePolicy>
314 return m_pReckoningStrategy->Estimate(m_ValueWork.GetT1Ptr(), accessor, clock, m_ValueWork.GetT2Ptr());
318 template <
typename ReckoningStrategy,
typename SerializePolicy>
321 SampleReckoningSendToken<Sample>* pSampleToken =
static_cast<SampleReckoningSendToken<Sample>*
>(pToken);
322 SerializePolicy::Deserialize(pSampleToken->GetSamplePtr(), cpData);
326 template <
typename ReckoningStrategy,
typename SerializePolicy>
330 m_pReckoningStrategy->OnUpdateSample(accessor, idx, m_ValueWork.GetT2Ptr());
ReckoningStrategy_ ReckoningStrategy
Defines the type of the dead reckoning algorithm.
Definition: reckoning_ReckoningCloneElement.h:109
const Value & GetValue()
Gets a value.
Definition: reckoning_ReckoningCloneElement.h:201
nn::Result SetValue(const Value &value, const SetValueArg *cpSetValueArg=NULL)
Sets values.
nn::Result SetReckoningStrategy(ReckoningStrategy *pReckoningStrategy)
Sets an instance of the dead reckoning algorithm.
u32 ClockValue
Defines a type that holds a clock value.
Definition: clone_definitions.h:44
Manages the sending and receiving of values while using dead reckoning.
Definition: reckoning_ReckoningCloneElement.h:103
ReckoningCloneElement(ReckoningStrategy *pReckoningStrategy=NULL)
Instantiates the object (constructor).
Contains member functions used to access values in the sample buffer.
Definition: reckoning_ReckoningCloneElementBase.h:261
virtual ~ReckoningCloneElement()
Destroys the object (destructor).
Definition: reckoning_ReckoningCloneElement.h:160
SerializePolicy_ SerializePolicy
Specifies the algorithm to use for serializing Sample.
Definition: reckoning_ReckoningCloneElement.h:139
ReckoningStrategy::SetValueArg SetValueArg
Specifies the type of value that is passed to ReckoningStrategy::CheckSample and ReckoningStrategy::M...
Definition: reckoning_ReckoningCloneElement.h:127
nn::Result ResetReckoningStrategy()
Resets the currently set instance of the dead reckoning algorithm.
Definition: reckoning_ReckoningCloneElement.h:181
static const size_t BUFFER_SIZE
Specifies the size of the buffer that holds samples.
Definition: reckoning_ReckoningCloneElement.h:145
ReckoningStrategy::Value Value
Specifies the type of value managed by this object.
Definition: reckoning_ReckoningCloneElement.h:115
ReckoningStrategy::Sample Sample
Defines the type of the sample.
Definition: reckoning_ReckoningCloneElement.h:121
This is the base class for managing the sending and receiving of data while using dead reckoning...
Definition: reckoning_ReckoningCloneElementBase.h:47
ClockValue GetClock() const
Gets the current clock.
bool IsRegisteredWithCloneBase() const
Determines whether the object is registered with CloneBase.
Definition: clone_CloneElementBase.h:94
Indicates that the API function was called at the wrong time. Indicates that the Pia library was not ...
bool IsInitialized(void)
Gets whether the reckoning module is initialized.
const CloneProtocol * GetProtocol() const
Gets the CloneProtocol of the CloneBase this object is registered to.
ReckoningStrategy::Work Work
Defines the type of the working buffer.
Definition: reckoning_ReckoningCloneElement.h:133