1 //----------------------------------------------------------------------------- 2 // 3 // Event.h 4 // 5 // Cross-platform manual-reset event 6 // 7 // Copyright (c) 2010 Mal Lansell <mal@lansell.org> 8 // All rights reserved. 9 // 10 // SOFTWARE NOTICE AND LICENSE 11 // 12 // This file is part of OpenZWave. 13 // 14 // OpenZWave is free software: you can redistribute it and/or modify 15 // it under the terms of the GNU Lesser General Public License as published 16 // by the Free Software Foundation, either version 3 of the License, 17 // or (at your option) any later version. 18 // 19 // OpenZWave is distributed in the hope that it will be useful, 20 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 // GNU Lesser General Public License for more details. 23 // 24 // You should have received a copy of the GNU Lesser General Public License 25 // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>. 26 // 27 //----------------------------------------------------------------------------- 28 #ifndef _Event_H 29 #define _Event_H 30 31 #include "platform/Wait.h" 32 33 namespace OpenZWave 34 { 35 namespace Internal 36 { 37 namespace Platform 38 { 39 class EventImpl; 40 41 /** \brief Platform-independent definition of event objects. 42 * \ingroup Platform 43 */ 44 class Event: public Wait 45 { 46 friend class SerialControllerImpl; 47 friend class Wait; 48 49 public: 50 /** 51 * Constructor. 52 * Creates a cross-platform event object equivalent to the Windows manual-reset event 53 */ 54 Event(); 55 56 /** 57 * Set the event to signalled. 58 * \see Reset, Wait 59 */ 60 void Set(); 61 62 /** 63 * Set the event to not signalled. 64 * \see Set, Wait 65 */ 66 void Reset(); 67 68 protected: 69 /** 70 * Used by the Wait class to test whether the event is set. 71 */ 72 virtual bool IsSignalled(); 73 74 /** 75 * Used by the Wait::Multiple method. 76 * returns true if the event signalled, false if it timed out 77 */ 78 bool Wait(int32 _timeout); 79 80 /** 81 * Destructor. 82 * Destroys the event object. 83 */ 84 ~Event(); 85 86 private: 87 Event(Event const&); // prevent copy 88 Event& operator =(Event const&); // prevent assignment 89 90 EventImpl* m_pImpl; // Pointer to an object that encapsulates the platform-specific implementation of a event. 91 }; 92 } // namespace Platform 93 } // namespace Internal 94 } // namespace OpenZWave 95 96 #endif //_Event_H 97 98