1 //----------------------------------------------------------------------------- 2 // 3 // WaitImpl.h 4 // 5 // Windows implementation of a base class for objects we 6 // want to be able to wait for. 7 // 8 // Copyright (c) 2010 Mal Lansell <mal@lansell.org> 9 // All rights reserved. 10 // 11 // SOFTWARE NOTICE AND LICENSE 12 // 13 // This file is part of OpenZWave. 14 // 15 // OpenZWave is free software: you can redistribute it and/or modify 16 // it under the terms of the GNU Lesser General Public License as published 17 // by the Free Software Foundation, either version 3 of the License, 18 // or (at your option) any later version. 19 // 20 // OpenZWave is distributed in the hope that it will be useful, 21 // but WITHOUT ANY WARRANTY; without even the implied warranty of 22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 // GNU Lesser General Public License for more details. 24 // 25 // You should have received a copy of the GNU Lesser General Public License 26 // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>. 27 // 28 //----------------------------------------------------------------------------- 29 #ifndef _WaitImpl_H 30 #define _WaitImpl_H 31 32 #include <windows.h> 33 #include <list> 34 #include "Defs.h" 35 #include "platform/Ref.h" 36 #include "platform/Wait.h" 37 38 namespace OpenZWave 39 { 40 /** \brief Windows specific implementation of Wait objects. 41 */ 42 class WaitImpl 43 { 44 private: 45 friend class Wait; 46 47 WaitImpl( Wait* _owner ); 48 virtual ~WaitImpl(); 49 50 void AddWatcher( Wait::pfnWaitNotification_t _callback, void* _context ); 51 bool RemoveWatcher( Wait::pfnWaitNotification_t _callback, void* _context ); 52 void Notify(); 53 54 static int32 Multiple( Wait** _objects, uint32 _numObjects, int32 _timeout = -1 ); 55 56 WaitImpl( Wait const& ); // prevent copy 57 WaitImpl& operator = ( WaitImpl const& ); // prevent assignment 58 59 struct Watcher 60 { 61 Wait::pfnWaitNotification_t m_callback; 62 void* m_context; 63 }; 64 65 list<Watcher> m_watchers; 66 Wait* m_owner; 67 CRITICAL_SECTION m_criticalSection; 68 }; 69 70 } // namespace OpenZWave 71 72 #endif //_WaitImpl_H 73 74