| OpenZWave Library 1.6.0

Wait.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Wait.h
4 //
5 // Cross-platform abstract 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 _Wait_H
30 #define _Wait_H
31
32 #include <list>
33 #include "platform/Ref.h"
34
35 namespace OpenZWave
36 {
37 class WaitImpl;
38
42 class Wait: public Ref
43 {
44 friend class WaitImpl;
45 friend class ThreadImpl;
46
47 public:
48 enum
49 {
50 Timeout_Immediate = 0,
51 Timeout_Infinite = -1
52 };
53
54 typedef void (*pfnWaitNotification_t)( void* _context );
55
62 void AddWatcher( pfnWaitNotification_t _callback, void* _context );
63
70 void RemoveWatcher( pfnWaitNotification_t _callback, void* _context );
71
78 static int32 Single( Wait* _object, int32 _timeout = -1 ){ return Multiple( &_object, 1, _timeout ); }
79
88 static int32 Multiple( Wait** _objects, uint32 _numObjects, int32 _timeout = -1 );
89
90 protected:
91 Wait();
92 virtual ~Wait();
93
97 void Notify();
98
102 virtual bool IsSignalled() = 0;
103
104 private:
105 Wait( Wait const& ); // prevent copy
106 Wait& operator = ( Wait const& ); // prevent assignment
107
108 WaitImpl* m_pImpl; // Pointer to an object that encapsulates the platform-specific implementation of a Wait object.
109 };
110
111 } // namespace OpenZWave
112
113 #endif //_Wait_H
114
uint32
unsigned int uint32
Definition: Defs.h:95
OpenZWave::Wait::Wait
Wait()
Definition: Wait.cpp:51
OpenZWave::Wait::Timeout_Infinite
@ Timeout_Infinite
Definition: Wait.h:51
OpenZWave::Wait::Multiple
static int32 Multiple(Wait **_objects, uint32 _numObjects, int32 _timeout=-1)
Definition: Wait.cpp:123
OpenZWave::Wait::Timeout_Immediate
@ Timeout_Immediate
Definition: Wait.h:50
OpenZWave::Wait::pfnWaitNotification_t
void(* pfnWaitNotification_t)(void *_context)
Definition: Wait.h:54
OpenZWave::Wait::AddWatcher
void AddWatcher(pfnWaitNotification_t _callback, void *_context)
Definition: Wait.cpp:73
OpenZWave::Wait::Single
static int32 Single(Wait *_object, int32 _timeout=-1)
Definition: Wait.h:78
OpenZWave::Ref
Definition: Ref.h:47
OpenZWave::Wait::RemoveWatcher
void RemoveWatcher(pfnWaitNotification_t _callback, void *_context)
Definition: Wait.cpp:96
int32
signed int int32
Definition: Defs.h:94
OpenZWave::Wait
Platform-independent definition of Wait objects.
Definition: Wait.h:43
OpenZWave::Wait::~Wait
virtual ~Wait()
Definition: Wait.cpp:62
Ref.h
OpenZWave::Wait::ThreadImpl
friend class ThreadImpl
Definition: Wait.h:45
OpenZWave::Wait::IsSignalled
virtual bool IsSignalled()=0
OpenZWave::Wait::WaitImpl
friend class WaitImpl
Definition: Wait.h:44
OpenZWave::Wait::Notify
void Notify()
Definition: Wait.cpp:112
OpenZWave
Definition: Bitfield.h:35