source: vendor/synergy/current/lib/base/CEvent.h

Last change on this file was 2749, checked in by bird, 19 years ago

synergy v1.3.1 sources (zip).

File size: 2.7 KB
Line 
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 CEVENT_H
16#define CEVENT_H
17
18#include "BasicTypes.h"
19#include "stdmap.h"
20
21//! Event
22/*!
23A \c CEvent holds an event type and a pointer to event data.
24*/
25class CEvent {
26public:
27 typedef UInt32 Type;
28 enum {
29 kUnknown, //!< The event type is unknown
30 kQuit, //!< The quit event
31 kSystem, //!< The data points to a system event type
32 kTimer, //!< The data points to timer info
33 kLast //!< Must be last
34 };
35
36 typedef UInt32 Flags;
37 enum {
38 kNone = 0x00, //!< No flags
39 kDeliverImmediately = 0x01, //!< Dispatch and free event immediately
40 kDontFreeData = 0x02 //!< Don't free data in deleteData
41 };
42
43 CEvent();
44
45 //! Create \c CEvent with data
46 /*!
47 The \p type must have been registered using \c registerType().
48 The \p data must be POD (plain old data) allocated by malloc(),
49 which means it cannot have a constructor, destructor or be
50 composed of any types that do. \p target is the intended
51 recipient of the event. \p flags is any combination of \c Flags.
52 */
53 CEvent(Type type, void* target = NULL, void* data = NULL,
54 UInt32 flags = kNone);
55
56 //! @name manipulators
57 //@{
58
59 //! Creates a new event type
60 /*!
61 Returns a unique event type id.
62 */
63 static Type registerType(const char* name);
64
65 //! Creates a new event type
66 /*!
67 If \p type contains \c kUnknown then it is set to a unique event
68 type id otherwise it is left alone. The final value of \p type
69 is returned.
70 */
71 static Type registerTypeOnce(Type& type, const char* name);
72
73 //! Get name for event
74 /*!
75 Returns the name for the event \p type. This is primarily for
76 debugging.
77 */
78 static const char* getTypeName(Type type);
79
80 //! Release event data
81 /*!
82 Deletes event data for the given event (using free()).
83 */
84 static void deleteData(const CEvent&);
85
86 //@}
87 //! @name accessors
88 //@{
89
90 //! Get event type
91 /*!
92 Returns the event type.
93 */
94 Type getType() const;
95
96 //! Get the event target
97 /*!
98 Returns the event target.
99 */
100 void* getTarget() const;
101
102 //! Get the event data
103 /*!
104 Returns the event data.
105 */
106 void* getData() const;
107
108 //! Get event flags
109 /*!
110 Returns the event flags.
111 */
112 Flags getFlags() const;
113
114 //@}
115
116private:
117 Type m_type;
118 void* m_target;
119 void* m_data;
120 Flags m_flags;
121};
122
123#endif
Note: See TracBrowser for help on using the repository browser.