CTR-Pia  5.4.3
Game Communication Engine
 全て クラス ネームスペース 関数 変数 型定義 列挙型 列挙型の値 ページ
common_Event.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 #if NN_PIA_CTR
19 #include <nn/os.h>
20 #elif NN_PIA_A || NN_PIA_B
21 #include <pthread.h>
22 #include <semaphore.h>
23 #endif
24 
25 namespace nn
26 {
27 namespace pia
28 {
29 namespace common
30 {
31 
32 
33 /*!
34  @brief イベントのクラスです。
35 
36  */
37 class Event
38 {
39 public:
40  /*!
41  @brief コンストラクタです。
42 
43  @details イベントを使用するには、明示的に Initialize を呼ぶ必要があります。
44  */
45  Event();
46 
47  /*!
48  @brief デストラクタです。
49  */
50  ~Event();
51 
52  /*!
53  @brief イベントを初期化します。
54 
55  @param[in] bManualReset 手動リセットイベントならば true を、自動リセットイベントであるならば false を指定します。
56  @see Finalize
57  */
58  void Initialize(bool bManualReset = true);
59 
60  /*!
61  @brief イベントを破棄します。
62 
63  @see Initialize
64  */
65  void Finalize();
66 
67 
68  /*!
69  @brief イベントがシグナル状態になるのを待ちます。
70 
71  @see Signal
72  */
73  void Wait();
74 
75 
76  /*!
77  @brief イベントがシグナル状態かどうかを判定します。
78 
79  @details 自動リセットイベントの場合、シグナル状態であればクリアされます。
80 
81  @see Wait
82  */
83  bool TryWait();
84 
85 
86  /*!
87  @brief イベントをシグナル状態にします。
88 
89  @see Wait, Reset
90  */
91  void Signal();
92 
93 
94  /*!
95  @brief イベントを非シグナル状態にします。
96 
97  @see Signal
98  */
99  void Reset();
100 
101 
102 #if NN_PIA_CTR
103  /*!
104  @brief このインスタンスの実体である nn::os::LightEvent を取得します。
105  @return このインスタンスの実体である nn::os::LightEvent です。
106  */
107  nn::os::LightEvent* GetRawLightEvent()
108  {
109  return &m_OsEvent;
110  }
111 #endif
112 
113 
114 protected:
115 #if NN_PIA_NINTENDOSDK
116  nn::os::EventType m_EventInner; ///< WindowsでのEvent構造体
117 #elif NN_PIA_CTR
118  nn::os::LightEvent m_OsEvent;
119 #elif NN_PIA_WIN
120  HANDLE m_Handle;
121 #elif NN_PIA_CAFE
122  OSEvent m_Event;
123 #elif NN_PIA_A || NN_PIA_B
124  /// シグナルの状態
125  enum SignalState
126  {
127  cSignalState_Auto, ///< 自動シグナル
128  cSignalState_Manual, ///< 手動シグナルのシグナルではない状態
129  cSignalState_ManualSignal ///< 手動シグナルのシグナルになっている状態
130  };
131  SignalState mSignalState; ///< シグナルの状態
132  sem_t mSemaphore;
133 #else
134 #error "invalid platform";
135 #endif
136 
137 private:
138  NN_PIA_DISALLOW_COPY(Event);
139 };
140 }
141 }
142 } // end of namespace nn::pia::common