CTR Pia  4.11.3
Game Communication Engine
common_Event.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: common_Event.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/common/common_definitions.h>
18 
19 #if NN_PIA_CTR
20 #include <nn/os.h>
21 #endif
22 
23 namespace nn
24 {
25 namespace pia
26 {
27 namespace common
28 {
29 
30 
31 /*!
32 @brief This class represents events.
33 
34 @date 2012-10-30 Added <tt>TryWait</tt>.
35 @date 2012-09-21 Made functions public.
36 */
37 class Event
38 {
39 public:
40 /*!
41 @brief Instantiates the object.
42 
43 @details You must explicitly call <tt>Initialize</tt> to use an event.
44 */
45  Event();
46 
47 /*!
48 @brief Destroys the object.
49 */
50  ~Event();
51 
52 /*!
53 @brief Initializes an event.
54 
55 @param[in] bManualReset Specify <tt>true</tt> for manual reset, or <tt>false</tt> for automatic reset.
56 @see Finalize
57 */
58  void Initialize(bool bManualReset = true);
59 
60 /*!
61 @brief Destroys an event.
62 
63 @see Initialize
64 */
65  void Finalize();
66 
67 
68 /*!
69 @brief Waits for the event to enter the signal state.
70 
71 @see Signal
72 */
73  void Wait();
74 
75 
76 /*!
77 @brief Determines whether the event is in the signal state.
78 
79 @details Clears the signal state if the event is an automatic reset event.
80 
81 @see Wait
82 */
83  bool TryWait();
84 
85 
86 /*!
87 @brief Puts the event in the signal state.
88 
89 @see Wait, Reset
90 */
91  void Signal();
92 
93 
94 /*!
95 @brief Puts the event in the non-signal state.
96 
97 @see Signal
98 */
99  void Reset();
100 
101 
102 #if NN_PIA_CTR
103 /*!
104 @brief Gets this <tt>nn::os::LightEvent</tt> instance.
105 @return Returns this <tt>nn::os::LightEvent</tt> instance.
106 */
107  nn::os::LightEvent* GetRawLightEvent()
108  {
109  return &m_OsEvent;
110  }
111 #endif
112 
113 
114 protected:
115 #if NN_PIA_CTR
116  nn::os::LightEvent m_OsEvent;
117 #elif NN_PIA_WIN || NN_PIA_NIN_WIN
118  HANDLE m_Handle;
119 #elif NN_PIA_CAFE
120  OSEvent m_Event;
121 #else
122 #error "Invalid platform";
123 #endif
124 
125 private:
126 /*!
127 @brief This copy constructor is private.
128 */
129  Event(const Event&);
130 
131 /*!
132 @brief This assignment operator is private.
133 */
134  Event& operator=(const Event&);
135 };
136 }
137 }
138 } // end of namespace nn::pia::common
This class represents events.
Definition: common_Event.h:37
Event()
Instantiates the object.
Definition: assert.h:115
nn::os::LightEvent * GetRawLightEvent()
Gets this nn::os::LightEvent instance.
Definition: common_Event.h:107
void Reset()
Puts the event in the non-signal state.
bool TryWait()
Determines whether the event is in the signal state.
~Event()
Destroys the object.
void Wait()
Waits for the event to enter the signal state.
void Finalize()
Destroys an event.
void Initialize(bool bManualReset=true)
Initializes an event.
void Signal()
Puts the event in the signal state.