QtGStreamer 1.2.0
Loading...
Searching...
No Matches
qglib_signal.h
1/*
2 Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
3 Copyright (C) 2010 Collabora Ltd.
4 @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
5
6 This library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef QGLIB_SIGNAL_H
20#define QGLIB_SIGNAL_H
21
22#include "global.h"
23#include <QtCore/QString>
24#include <QtCore/QFlags>
25#include <QtCore/QSharedData>
26
27//Qt's emit will clash
28#if defined(emit)
29# if !defined(QGLIB_NO_EMIT_WARNING) //define that to get rid of the warning
30# if defined(Q_CC_GNU)
31# warning "The emit keyword is defined and will be undefined here to compile QGlib::emit."
32# warning "It is recommended to compile your project with QT_NO_KEYWORDS defined."
33# elif defined(Q_CC_MSVC)
34# pragma message("Warning: The emit keyword is defined and will be undefined here to compile QGlib::emit.")
35# pragma message("Warning: It is recommended to compile your project with QT_NO_KEYWORDS defined.")
36# endif
37# endif
38# undef emit
39# define QT_NO_EMIT //undocumented Qt macro that skips "#define emit" in qglobal.h
40#endif
41
42namespace QGlib {
43
62class QTGLIB_EXPORT Signal
63{
64public:
65 enum SignalFlag {
66 RunFirst = 1<<0,
67 RunLast = 1<<1,
68 RunCleanup = 1<<2,
69 NoRecurse = 1<<3,
70 Detailed = 1<<4,
71 Action = 1<<5,
72 NoHooks = 1<<6
73 };
74 Q_DECLARE_FLAGS(SignalFlags, SignalFlag);
75
76 Signal(const Signal & other);
77 Signal & operator=(const Signal & other);
78 virtual ~Signal();
79
82 bool isValid() const;
83
84 uint id() const;
85 QString name() const;
86 SignalFlags flags() const;
87
89 Type instanceType() const;
90 Type returnType() const;
91 QList<Type> paramTypes() const;
92
95 static Signal lookup(const char *name, Type type);
96
98 static QList<Signal> listSignals(Type type);
99
100private:
101 QTGLIB_NO_EXPORT Signal(uint id);
102
103 struct Private;
104 QSharedDataPointer<Private> d;
105};
106
107Q_DECLARE_OPERATORS_FOR_FLAGS(Signal::SignalFlags)
108
109#if defined(DOXYGEN_RUN)
110
156template <typename R, typename... Args>
157R emit(void *instance, const char *detailedSignal, const Args & ... args);
158
163template <typename R, typename... Args>
164R emitWithDetail(void *instance, const char *signal, Quark detail, const Args & ... args);
165
166#endif //DOXYGEN_RUN
167
168} //namespace QGlib
169
170#if !QGLIB_HAVE_CXX0X && !defined(QGLIB_SIGNAL_MAX_ARGS)
171# define QGLIB_SIGNAL_MAX_ARGS 9
172#endif
173
174#define IN_QGLIB_SIGNAL_H
175# include "emitimpl.h"
176#undef IN_QGLIB_SIGNAL_H
177
178#if defined(QGLIB_SIGNAL_MAX_ARGS)
179# undef QGLIB_SIGNAL_MAX_ARGS
180#endif
181
182#endif
Wrapper class for GQuark.
Definition quark.h:43
Helper class providing introspection of GObject signals.
Wrapper class for GType.
Definition type.h:64
Wrappers for Glib and GObject classes.
R emitWithDetail(void *instance, const char *signal, Quark detail, const Args &... args)
Definition emitimpl.h:117
R emit(void *instance, const char *detailedSignal, const Args &... args)
Definition emitimpl.h:111