Changeset 21:eb59943050c9 in xplcommon for src/xplcommon/win32/Event.h
- Timestamp:
- 12/31/12 14:17:32 (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/xplcommon/win32/Event.h
r20 r21 32 32 //------------------------------------------------------------------------------ 33 33 34 #include " ../Failable.h"34 #include "EventFailable.h" 35 35 36 36 #include <windows.h> … … 49 49 * Wrapper for an event. 50 50 */ 51 class Event : public ::xplcommon::Failable51 class Event 52 52 { 53 53 private: 54 54 /** 55 * The object receiving the failure codes. 56 */ 57 EventFailable& eventFailable; 58 59 /** 55 60 * The handle of the event. 56 61 */ … … 66 71 * Construct the event. 67 72 */ 68 Event( );73 Event(EventFailable& eventFailable); 69 74 70 75 /** … … 96 101 97 102 /** 103 * Determine if the event is being waited for, i.e. it is 104 * associated with a waiter. 105 */ 106 bool isWaited() const; 107 108 /** 98 109 * Set the event. 99 110 */ 100 111 void fire(); 112 113 /** 114 * Determine if the event is fired or not. 115 */ 116 bool isFired() const; 101 117 102 118 /** … … 106 122 */ 107 123 bool clear(); 124 125 protected: 126 /** 127 * Set the error code on the failable object. 128 */ 129 void setErrorCode(errorCode_t errorCode); 108 130 }; 109 131 … … 112 134 //------------------------------------------------------------------------------ 113 135 114 inline Event::Event() : 136 inline Event::Event(EventFailable& eventFailable) : 137 eventFailable(eventFailable), 115 138 handle(CreateEvent(0, true, false, 0)), 116 139 waiter(0) 117 140 { 118 if (handle==0) setErrorCode(GetLastError());141 if (handle==0) eventFailable.setErrorCode(GetLastError()); 119 142 } 120 143 … … 143 166 //------------------------------------------------------------------------------ 144 167 168 inline bool Event::isWaited() const 169 { 170 return waiter!=0; 171 } 172 173 //------------------------------------------------------------------------------ 174 145 175 inline void Event::fire() 146 176 { 147 177 if (!SetEvent(handle)) { 148 setErrorCode(GetLastError());178 eventFailable.setErrorCode(GetLastError()); 149 179 } 150 180 } … … 155 185 { 156 186 if (!ResetEvent(handle)) { 157 setErrorCode(GetLastError());187 eventFailable.setErrorCode(GetLastError()); 158 188 return false; 159 189 } else { 160 190 return true; 161 191 } 192 } 193 194 //------------------------------------------------------------------------------ 195 196 inline void Event::setErrorCode(errorCode_t errorCode) 197 { 198 eventFailable.setErrorCode(errorCode); 162 199 } 163 200
Note:
See TracChangeset
for help on using the changeset viewer.