1 | /*
|
---|
2 | * synergy -- mouse and keyboard sharing utility
|
---|
3 | * Copyright (C) 2004 Chris Schoeneman
|
---|
4 | *
|
---|
5 | * This package is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU General Public License
|
---|
7 | * found in the file COPYING that should have accompanied this file.
|
---|
8 | *
|
---|
9 | * This package is distributed in the hope that it will be useful,
|
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | * GNU General Public License for more details.
|
---|
13 | */
|
---|
14 |
|
---|
15 | #ifndef IEVENTQUEUEBUFFER_H
|
---|
16 | #define IEVENTQUEUEBUFFER_H
|
---|
17 |
|
---|
18 | #include "IInterface.h"
|
---|
19 | #include "BasicTypes.h"
|
---|
20 |
|
---|
21 | class CEvent;
|
---|
22 | class CEventQueueTimer;
|
---|
23 |
|
---|
24 | //! Event queue buffer interface
|
---|
25 | /*!
|
---|
26 | An event queue buffer provides a queue of events for an IEventQueue.
|
---|
27 | */
|
---|
28 | class IEventQueueBuffer : public IInterface {
|
---|
29 | public:
|
---|
30 | enum Type {
|
---|
31 | kNone, //!< No event is available
|
---|
32 | kSystem, //!< Event is a system event
|
---|
33 | kUser //!< Event is a user event
|
---|
34 | };
|
---|
35 |
|
---|
36 | //! @name manipulators
|
---|
37 | //@{
|
---|
38 |
|
---|
39 | //! Block waiting for an event
|
---|
40 | /*!
|
---|
41 | Wait for an event in the event queue buffer for up to \p timeout
|
---|
42 | seconds.
|
---|
43 | */
|
---|
44 | virtual void waitForEvent(double timeout) = 0;
|
---|
45 |
|
---|
46 | //! Get the next event
|
---|
47 | /*!
|
---|
48 | Get the next event from the buffer. Return kNone if no event is
|
---|
49 | available. If a system event is next, return kSystem and fill in
|
---|
50 | event. The event data in a system event can point to a static
|
---|
51 | buffer (because CEvent::deleteData() will not attempt to delete
|
---|
52 | data in a kSystem event). Otherwise, return kUser and fill in
|
---|
53 | \p dataID with the value passed to \c addEvent().
|
---|
54 | */
|
---|
55 | virtual Type getEvent(CEvent& event, UInt32& dataID) = 0;
|
---|
56 |
|
---|
57 | //! Post an event
|
---|
58 | /*!
|
---|
59 | Add the given event to the end of the queue buffer. This is a user
|
---|
60 | event and \c getEvent() must be able to identify it as such and
|
---|
61 | return \p dataID. This method must cause \c waitForEvent() to
|
---|
62 | return at some future time if it's blocked waiting on an event.
|
---|
63 | */
|
---|
64 | virtual bool addEvent(UInt32 dataID) = 0;
|
---|
65 |
|
---|
66 | //@}
|
---|
67 | //! @name accessors
|
---|
68 | //@{
|
---|
69 |
|
---|
70 | //! Check if event queue buffer is empty
|
---|
71 | /*!
|
---|
72 | Return true iff the event queue buffer is empty.
|
---|
73 | */
|
---|
74 | virtual bool isEmpty() const = 0;
|
---|
75 |
|
---|
76 | //! Create a timer object
|
---|
77 | /*!
|
---|
78 | Create and return a timer object. The object is opaque and is
|
---|
79 | used only by the buffer but it must be a valid object (i.e.
|
---|
80 | not NULL).
|
---|
81 | */
|
---|
82 | virtual CEventQueueTimer*
|
---|
83 | newTimer(double duration, bool oneShot) const = 0;
|
---|
84 |
|
---|
85 | //! Destroy a timer object
|
---|
86 | /*!
|
---|
87 | Destroy a timer object previously returned by \c newTimer().
|
---|
88 | */
|
---|
89 | virtual void deleteTimer(CEventQueueTimer*) const = 0;
|
---|
90 |
|
---|
91 | //@}
|
---|
92 | };
|
---|
93 |
|
---|
94 | #endif
|
---|