17 #include <pia/clone/clone_definitions.h> 18 #include <pia/clone/clone_CloneElementBase.h> 19 #include <pia/common/common_TreeMapNode.h> 20 #include <pia/common/common_OffsetTreeMap.h> 21 #include <pia/common/common_OffsetList.h> 77 return static_cast<Id
>(m_TreeMapNode.GetKey() & 0xffffffff);
87 return m_pProtocol != NULL;
133 return m_ElementCollection.Find(elementId);
144 return m_ElementCollection.Find(elementId);
156 return (m_State == STATE_ACTIVE);
190 return m_pSendProfiler;
201 return m_pReceiveProfiler;
293 virtual void Trace(u64 flag)
const;
303 TYPE_SEQUENTIAL = 0x04
306 virtual Type GetTypeVirtual()
const = 0;
312 static s32 GetTreeMapNodeOffset()
314 return offsetof(
CloneBase, m_TreeMapNode);
319 bool CheckElementSize(
size_t sizeMax);
321 void DetachProtocol();
325 return static_cast<Type
>(m_TreeMapNode.GetKey() >> 48);
329 return static_cast<StationIndex>((m_TreeMapNode.GetKey() >> 32) & 0xff);
333 return m_TreeMapNode.GetKey();
335 static Key ToKey(Type type,
StationIndex stationId, Id
id)
337 return (static_cast<u64>(type) << 48) | (
static_cast<u64
>(stationId) << 32) | id;
348 STATE_COMPLETE_FOR_UNREGISTER,
349 STATE_ENDING_FOR_UNREGISTER,
350 STATE_ENDED_FOR_UNREGISTER
353 State GetState()
const 360 return m_pSendProfiler;
364 return m_pReceiveProfiler;
384 OnDisconnect(stationId, isValid);
388 bool IsReceiveData()
const 390 return m_State != STATE_INACTIVE;
393 bool IsSendingData(
StationIndex stationId,
bool isDebug =
false)
const;
396 virtual void OnStartup()
399 virtual void OnCleanup()
405 virtual void OnComplete()
408 virtual bool OnCheckEnd()
421 virtual void OnDisconnect(
StationIndex stationId,
bool isValid)
426 virtual void OnRegister()
431 virtual bool IsReadyToSetValue()
const 435 virtual u32 GetDestBitmap()
const = 0;
436 virtual bool IsInRequest()
const 441 virtual u8 GetLocalRegisterCount()
const 445 virtual u64 GetRegisterCountAll()
const 449 virtual bool IsMatchLocalRegisterCount(u64 registerCountAll)
const 451 NN_PIA_DUMMY_PARAM(registerCountAll);
455 void AddSendData(CloneElementBase::ISendToken* pToken);
456 void AddSendDelayData(CloneElementBase::ResendableSendToken* pToken);
457 void CancelSendData(CloneElementBase::ISendToken* pToken);
458 void ErrorDropEvent();
462 typedef common::OffsetList<CloneElementBase::ISendToken> SendDataList;
463 typedef common::OffsetList<CloneElementBase::ResendableSendToken> ResendableDataList;
466 class DataTokenAccessor
469 DataTokenAccessor(
CloneBase* pClone, SystemTime time, SystemTime resendSpan, SystemTime maxSendDelay,
bool isUnicast,
StationIndex stationIndex);
470 CloneElementBase::ISendToken* Get()
const 474 void Reset(
bool isUnicast,
StationIndex stationIndex, SystemTime resendSpan);
476 void Commit(u32 dispatchCount, u32 destBitmap);
479 void NextToken(
bool isFirst);
480 void NextUnicastToken();
485 SystemTime m_ResendSpan;
486 SystemTime m_MaxSendDelay;
487 CloneElementBase::ISendToken* m_pToken;
501 ListState m_ListState;
522 INVALID_COMMAND_INDEX = 0
529 : m_ListNode(), m_pClone(pClone), m_LastSendTime(INVALID_SYSTEM_TIME)
534 bool IsInList()
const 536 return m_ListNode.IsFreeListNode() ==
false;
538 virtual CommandType GetType()
const = 0;
539 virtual u32 GetDestStationBitmap()
const = 0;
540 Id GetCloneId()
const 542 return m_pClone->GetId();
544 SystemTime GetLastSendTime(
StationIndex stationIndex)
const 548 return m_LastSendTime;
552 PIA_ASSERT(IsUnicast());
554 return m_LastSendTimeArray[stationIndex];
557 void SetLastSendTime(SystemTime time,
StationIndex stationIndex)
561 m_LastSendTime = time;
565 PIA_ASSERT(IsUnicast());
567 m_LastSendTimeArray[stationIndex] = time;
574 static s32 GetListNodeOffset()
576 return offsetof(CommandToken, m_ListNode);
583 virtual bool IsUnicast()
const 589 common::ListNode m_ListNode;
591 SystemTime m_LastSendTime;
596 class ClockCommandToken :
public CommandToken
600 : CommandToken(pClone)
613 : m_ListNode(), m_pClone(pClone)
616 bool IsInList()
const 618 return m_ListNode.IsFreeListNode() ==
false;
624 bool CheckEraseFromList()
const 626 return m_pClone->IsSendDataEmpty();
628 static s32 GetListNodeOffset()
630 return offsetof(DataToken, m_ListNode);
634 common::ListNode m_ListNode;
651 void RequestInitialData();
655 bool IsSendDataEmpty()
const 657 return m_SendDataList.IsEmpty() && m_SendDelayDataList.IsEmpty() && m_ResendDataList.IsEmpty();
661 common::TreeMapNode<Key> m_TreeMapNode;
666 typedef common::OffsetTreeMap<CloneElementBase::Id, CloneElementBase> ElementCollection;
667 ElementCollection m_ElementCollection;
670 SendDataList m_SendDataList;
671 ResendableDataList m_ResendDataList;
672 ResendableDataList m_SendDelayDataList;
674 DataToken m_DataToken;
681 template <
int TEST_ID,
typename Arg>
682 static void Test(
const CloneBase& obj, Arg* pArg = NULL);
686 void SetElementNumToMonitoringData();
u32 GetProfiledTotalReceiveCount(StationIndex stationIndex) const
Gets the number of times received since ResetProfiler was called.
u32 GetProfiledLatestSendCount(StationIndex stationIndex) const
Gets the send count for the last CloneProfiler::LATEST_BUFFER_SIZE times common::Scheduler::Dispatch ...
This is the base class for managing data that is sent and received. .
Definition: clone_CloneElementBase.h:40
u32 GetProfiledTotalSendCount(StationIndex stationIndex) const
Gets the number of times sent since ResetProfiler was called.
const CloneElementBase * SearchElement(CloneElementBase::Id elementId) const
Searches for the clone element of the specified ID.
Definition: clone_CloneBase.h:142
u32 ClockValue
Defines a type that holds a clock value.
Definition: clone_definitions.h:44
StationIndex
Enumerates StationIndex values.
Definition: platformCtr.h:44
bool IsRegisteredWithProtocol() const
Determines whether the object is registered with CloneProtocol.
Definition: clone_CloneBase.h:85
const CloneProfilerBase * GetSendProfiler() const
Gets the object configured to manage send profiling.
Definition: clone_CloneBase.h:188
ID indicating a station that is not present in the session.
Definition: platformCtr.h:59
Id GetId() const
Gets the ID.
Definition: clone_CloneBase.h:75
u32 GetProfiledLatestReceiveCount(StationIndex stationIndex) const
Gets the receive count for the last CloneProfiler::LATEST_BUFFER_SIZE times common::Scheduler::Dispat...
nn::Result RegisterElement(CloneElementBase *pElement, CloneElementBase::Id elementId)
Registers a clone element.
Represents a protocol for sharing values between stations.
Definition: clone_CloneProtocol.h:51
u32 GetProfiledTotalReceiveSize(StationIndex stationIndex) const
Gets the amount of data, in bytes, received since ResetProfiler was called.
bool IsActive() const
Determines whether this object is active.
Definition: clone_CloneBase.h:154
u32 GetProfiledTotalSendSize(StationIndex stationIndex) const
Gets the amount of data, in bytes, sent since ResetProfiler was called.
This base class manages PiaClone profiling.
Definition: clone_CloneProfilerBase.h:33
This is the base class for managing sending and receiving. .
Definition: clone_CloneBase.h:38
const size_t MAX_STATION_NUM
The maximum value for the number of stations that can participate in a Pia session.
Definition: platformCtr.h:64
CloneElementBase * SearchElement(CloneElementBase::Id elementId)
Searches for the clone element of the specified ID.
Definition: clone_CloneBase.h:131
u32 GetProfiledLatestReceiveSize(StationIndex stationIndex) const
Gets the total amount of data, in bytes, received during the last CloneProfiler::LATEST_BUFFER_SIZE t...
virtual ~CloneBase()
Destroys the object.
nn::Result UnregisterElement(CloneElementBase *pElement)
Unregisters a clone element.
u32 GetProfiledLatestSendSize(StationIndex stationIndex) const
Gets the total amount of data, in bytes, sent during the last CloneProfiler::LATEST_BUFFER_SIZE times...
const CloneProfilerBase * GetReceiveProfiler() const
Gets the object configured to manage receive profiling.
Definition: clone_CloneBase.h:199
nn::Result SetProfiler(CloneProfilerBase *pSendProfiler, CloneProfilerBase *pReceiveProfiler)
Sets an object to manage send/receive profiling.
u32 Id
Specifies the type of the ID for identifying clones.
Definition: clone_CloneBase.h:68
const CloneProtocol * GetProtocol() const
Gets the CloneProtocol this object is registered to.
Definition: clone_CloneBase.h:59
void ResetProfiler()
Resets the results of send/receive profiling.
u16 Id
Specifies the type of the ID for identifying clone elements.
Definition: clone_CloneElementBase.h:59