CTR-Pia  5.4.3
Game Communication Engine
 全て クラス ネームスペース 関数 変数 型定義 列挙型 列挙型の値 ページ
common_StepSequenceJob.h
1 /*--------------------------------------------------------------------------------*
2  Copyright (C)Nintendo All rights reserved.
3 
4  These coded instructions, statements, and computer programs contain proprietary
5  information of Nintendo and/or its licensed developers and are protected by
6  national and international copyright laws. They may not be disclosed to third
7  parties or copied or duplicated in any form, in whole or in part, without the
8  prior written consent of Nintendo.
9 
10  The content herein is highly confidential and should be handled accordingly.
11  *--------------------------------------------------------------------------------*/
12 
13 
14 #pragma once
15 
16 #include <nn/pia/common/common_Definitions.h>
17 
18 #include <nn/pia/common/common_RootObject.h>
19 #include <nn/pia/common/common_Job.h>
20 #include <nn/pia/common/common_Trace.h>
21 
22 
23 namespace nn
24 {
25 namespace pia
26 {
27 namespace common
28 {
29 
30 #define NN_PIA_JOBSTEP(STEP) Step(static_cast<StepMethod>(&STEP), #STEP)
31 
32 
33 /*!
34 @cond PRIVATE
35  @brief ステップ実行ジョブの基底クラスです。
36 
37  @details このクラスを用いると、ジョブのメンバ関数の単位で処理を
38  実行することができます。
39  */
40 class StepSequenceJob : public nn::pia::common::Job
41 {
42 public:
43  typedef Job::ExecuteResult (StepSequenceJob::*StepMethod)();
44 
45  class Step : public nn::pia::common::RootObject
46  {
47  public:
48  Step(void)
49  : m_pStepMethod(NULL), m_pName(NULL)
50  {
51  }
52  Step(StepMethod pStepMethod, const char* pName)
53  : m_pStepMethod(pStepMethod), m_pName(pName)
54  {
55  }
56 
57  virtual ~Step(void)
58  {
59  }
60 
61  const char* GetName(void) const
62  {
63  return m_pName ? m_pName : "(no name)";
64  }
65 
66  Job::ExecuteResult Execute(StepSequenceJob* pJob)
67  {
68  return (pJob->*m_pStepMethod)();
69  }
70 
71  bool operator==(const Step& rhs) const;
72  bool operator!=(const Step& rhs) const
73  {
74  return !(*this == rhs);
75  }
76 
77  virtual void Trace(uint64_t flag) const
78  {
79  PIA_TRACE(flag, "StepSequenceJob::Step::Trace() called. (%s)", GetName());
80  }
81 
82  private:
83  StepMethod m_pStepMethod;
84  const char* m_pName;
85  };
86 
87 
88  /*!
89  @brief コンストラクタです。
90  */
91  StepSequenceJob(void);
92 
93 
94  /*!
95  @brief デストラクタです。
96  */
97  virtual ~StepSequenceJob(void);
98 
99 
100  virtual void Reset(bool isCheck = true);
101 
102 
103  void CancelStepSequence()
104  {
105  m_IsCancelStepSequence = true;
106  }
107 
108  virtual void CancelCleanup()
109  {
110  }
111 
112  /*!
113  @brief 逐次実行する関数を登録します。
114 
115  @details 関数をバッチ的に実行していくためのセッティングを行う関数です。
116  <br>
117  @param[in] step 次回に実行する関数が内包されたStepインスタンス。
118  通常、このインスタンスは NN_PIA_JOBSTEPマクロで作成します。
119  */
120  void SetStep(const Step& step)
121  {
122  m_NextStep = step;
123  }
124 
125  void WaitForCompletion(uint32_t sleepTime);
126 
127  /*!
128  @brief トレースフラグをセットします。
129 
130  @param[in] flags トレースフラグ。
131  */
132  void SetTraceFlags(uint64_t flags)
133  {
134  m_TraceFlags = flags;
135  }
136 
137 
138  /*!
139  @brief トレースフラグを取得します。
140  */
141  uint64_t GetTraceFlags(void) const
142  {
143  return m_TraceFlags;
144  }
145 
146  /*!
147  @brief デバッグに有用な情報をプリントします。
148 
149  @param[in] flag トレースフラグの論理和。詳細は@ref TraceFlag 型を参照してください。
150  */
151  virtual void Trace(uint64_t flag) const;
152 
153 protected:
154  // オーバーライド。
155  virtual Job::ExecuteResult ExecuteCore();
156 
157  // SetStep() で登録されているインスタンスを返します。
158  const Step& GetStep(void) const
159  {
160  return m_NextStep;
161  }
162 
163 private:
164  // 次回に実行されるジョブが内包されるインスタンス。
165  Step m_NextStep;
166 
167  volatile bool m_IsCancelStepSequence;
168 
169  // 本インスタンスのトレースフラグ。
170  uint64_t m_TraceFlags;
171 };
172 //! @endcond
173 }
174 }
175 } // end of namespace nn::pia::common