CTR Pia  4.11.3
Game Communication Engine
clone_CloneProfiler.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: clone_CloneProfiler.h
4 
5  Copyright Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 
15 #pragma once
16 
17 #include <pia/clone/clone_definitions.h>
18 #include <pia/clone/clone_CloneProfilerBase.h>
19 #include <pia/assert.h>
20 
21 namespace nn
22 {
23 namespace pia
24 {
25 namespace clone
26 {
27 
28 
29 /*!
30  @brief This class manages <tt>PiaClone</tt> profiling.
31 
32  @details It adds a feature that profiles the data each instance sends/receives by registering a <tt>CloneProfiler</tt> instance for the <tt>CloneProtocol</tt>, <tt>CloneBase</tt>, and <tt>CloneElementBase</tt> instances.
33  <tt>CloneProtocol</tt> send/receive tasks can be profiled by configuring instance.
34  @details You must use a separate <tt>CloneProfiler</tt> instance for each instance of <tt>CloneProtocol</tt>,
35  <tt>CloneBase</tt>, and <tt>CloneElementBase</tt> to be profiled at the same time.
36 
37  @tparam STATION_NUM The number of stations to measure. Normally you specify the largest number of stations participating in the session.
38  @tparam LATEST_BUFFER_SIZE Measures the data sent and received the last <tt>LATEST_BUFFER_SIZE</tt> times the <tt>common::Scheduler::Dispatch()</tt> function was called.
39  Specify <tt>0</tt> if not necessary.
40 
41  @see CloneProtocol::SetProfiler, CloneBase::SetProfiler, CloneElementBase::SetProfiler
42 
43  @date 2013-11-25 Initial version.
44 */
45 template <u32 STATION_NUM, u32 LATEST_BUFFER_SIZE>
47 {
48 public:
49 /*!
50  @brief Instantiates an object with default parameters (default constructor).
51 */
54  (LATEST_BUFFER_SIZE > 0) ? reinterpret_cast<u32*>(&m_aBuffer[cDispatchCountBufferOffset]) : NULL,
55  (LATEST_BUFFER_SIZE > 0) ? &m_aBuffer[cCountBufferOffset] : NULL,
56  (LATEST_BUFFER_SIZE > 0) ? reinterpret_cast<u16*>(&m_aBuffer[cSizeBufferOffset]) : NULL,
57  reinterpret_cast<u16*>(&m_aBuffer[cTotalCountBufferOffset]),
58  reinterpret_cast<u32*>(&m_aBuffer[cTotalSizeBufferOffset]),
59  cStationNum,
60  LATEST_BUFFER_SIZE)
61  {
62  PIA_COMPILE_ASSERT(STATION_NUM > 0);
63  };
64 
65 
66 private:
67  enum
68  {
69  cStationNum = STATION_NUM < 32 ? STATION_NUM : 32,
70  cDispatchCountBufferSize = sizeof(u32) * LATEST_BUFFER_SIZE,
71  cCountBufferSize = sizeof(u8) * LATEST_BUFFER_SIZE * cStationNum,
72  cSizeBufferSize = sizeof(u16) * LATEST_BUFFER_SIZE * cStationNum,
73  cTotalCountBufferSize = sizeof(u16) * cStationNum,
74  cTotalSizeBufferSize = sizeof(u32) * cStationNum,
75  cDispatchCountBufferOffset = 0,
76  cTotalSizeBufferOffset = cDispatchCountBufferOffset + cDispatchCountBufferSize,
77  cTotalCountBufferOffset = cTotalSizeBufferOffset + cTotalSizeBufferSize,
78  cSizeBufferOffset = cTotalCountBufferOffset + cTotalCountBufferSize,
79  cCountBufferOffset = cSizeBufferOffset + cSizeBufferSize,
80  cBufferSize = cCountBufferOffset + cCountBufferSize
81  };
82 
83  PIA_ATTRIBUTE_ALIGN(4) u8 m_aBuffer[cBufferSize];
84 };
85 }
86 }
87 } // end of namespace nn::pia::clone
Definition: assert.h:115
This base class manages PiaClone profiling.
Definition: clone_CloneProfilerBase.h:33
This class manages PiaClone profiling.
Definition: clone_CloneProfiler.h:46
CloneProfiler()
Instantiates an object with default parameters (default constructor).
Definition: clone_CloneProfiler.h:52