16 #include <nn/pia/reckoning/reckoning_Definitions.h>
17 #include <nn/pia/reckoning/reckoning_ReckoningCloneElementBase.h>
18 #include <nn/pia/reckoning/reckoning_VoidMemberConcealer.h>
19 #include <nn/pia/clone/clone_SerializePolicyDefinition.h>
20 #include <nn/pia/clone/clone_CloneProtocol.h>
98 typename ReckoningStrategy_>
111 typedef typename ReckoningStrategy::Value
Value;
117 typedef typename ReckoningStrategy::Sample
Sample;
129 typedef typename ReckoningStrategy::Work
Work;
141 static const uint32_t
BufferSize = ReckoningStrategy::BufferSize;
200 return *m_ValueWork.GetT1Ptr();
209 return PIA_IS_VALID_POINTER(m_pReckoningStrategy);
213 virtual uint32_t GetSize()
const
217 virtual void Serialize(
void* pBuffer,
const ReckoningSendToken* cpToken);
218 virtual void ClearValue()
220 m_ValueWork = VoidMemberConcealer<Value, Work>();
224 virtual void Deserialize(ReckoningSendToken* pToken,
const void* cpData);
225 virtual void OnUpdateSample(
int idx);
229 SampleReckoningSendToken<Sample> m_aSampleBuffer[
BufferSize];
233 VoidMemberConcealer<Value, Work> m_ValueWork;
242 template <
typename ReckoningStrategy>
244 : ReckoningCloneElementBase(m_apToken, BufferSize),
245 m_pReckoningStrategy(pReckoningStrategy),
250 for (uint32_t i = 0; i < static_cast<uint32_t>(
BufferSize); ++i)
252 m_aSampleBuffer[i].Init(
this);
253 m_apToken[i] = &m_aSampleBuffer[i];
258 template <
typename ReckoningStrategy>
261 if (IsRegisteredWithCloneBase())
264 PIA_RETURN_RESULT_WITH_REPORT(ResultInvalidState,
"State must not be (IsRegisteredWithCloneBase() == true).");
266 m_pReckoningStrategy = pReckoningStrategy;
267 return ResultSuccess();
271 template <
typename ReckoningStrategy>
275 Result r = SetValueCore(&isSend);
280 const SampleAccessor<Sample> accessor(GetSampleBuffer());
282 bool isReliable =
false;
283 bool isSample = m_pReckoningStrategy->CheckSample(&isReliable, value, cpSetValueArg, accessor, clock, m_ValueWork.GetT2Ptr());
287 ReckoningSendToken* pToken = AssignTokenForSend(&idx, isReliable);
288 PIA_ASSERT(pToken != NULL && idx == 0);
290 SampleReckoningSendToken<Sample>* pSampleToken =
static_cast<SampleReckoningSendToken<Sample>*
>(pToken);
291 m_pReckoningStrategy->MakeSample(pSampleToken->GetSamplePtr(), value, cpSetValueArg, accessor, clock, m_ValueWork.GetT2Ptr());
292 m_pReckoningStrategy->OnUpdateSample(accessor, idx, m_ValueWork.GetT2Ptr());
300 template <
typename ReckoningStrategy>
301 void ReckoningCloneElement<ReckoningStrategy>::Serialize(
void* pBuffer,
const ReckoningSendToken* cpToken)
303 const SampleReckoningSendToken<Sample>* cpSampleToken =
static_cast<const SampleReckoningSendToken<Sample>*
>(cpToken);
304 ValueSerializePolicy::Serialize(pBuffer, cpSampleToken->GetSample());
308 template <
typename ReckoningStrategy>
309 bool ReckoningCloneElement<ReckoningStrategy>::EstimateValue(
clone::ClockValue clock)
311 const SampleAccessor<Sample> accessor(GetSampleBuffer());
312 return m_pReckoningStrategy->Estimate(m_ValueWork.GetT1Ptr(), accessor, clock, m_ValueWork.GetT2Ptr());
316 template <
typename ReckoningStrategy>
317 void ReckoningCloneElement<ReckoningStrategy>::Deserialize(ReckoningSendToken* pToken,
const void* cpData)
319 SampleReckoningSendToken<Sample>* pSampleToken =
static_cast<SampleReckoningSendToken<Sample>*
>(pToken);
320 ValueSerializePolicy::Deserialize(pSampleToken->GetSamplePtr(), cpData);
324 template <
typename ReckoningStrategy>
325 void ReckoningCloneElement<ReckoningStrategy>::OnUpdateSample(
int idx)
327 const SampleAccessor<Sample> accessor(GetSampleBuffer());
328 m_pReckoningStrategy->OnUpdateSample(accessor, idx, m_ValueWork.GetT2Ptr());