00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef QGLIB_SIGNAL_H
00020 #define QGLIB_SIGNAL_H
00021
00022 #include "global.h"
00023 #include <QtCore/QString>
00024 #include <QtCore/QFlags>
00025 #include <QtCore/QSharedData>
00026
00027
00028 #if defined(emit)
00029 # if !defined(QGLIB_NO_EMIT_WARNING) //define that to get rid of the warning
00030 # if defined(Q_CC_GNU)
00031 # warning "The emit keyword is defined and will be undefined here to compile QGlib::emit."
00032 # warning "It is recommended to compile your project with QT_NO_KEYWORDS defined."
00033 # elif defined(Q_CC_MSVC)
00034 # pragma message("Warning: The emit keyword is defined and will be undefined here to compile QGlib::emit.")
00035 # pragma message("Warning: It is recommended to compile your project with QT_NO_KEYWORDS defined.")
00036 # endif
00037 # endif
00038 # undef emit
00039 # define QT_NO_EMIT //undocumented Qt macro that skips "#define emit" in qglobal.h
00040 #endif
00041
00042 namespace QGlib {
00043
00062 class QTGLIB_EXPORT Signal
00063 {
00064 public:
00065 enum SignalFlag {
00066 RunFirst = 1<<0,
00067 RunLast = 1<<1,
00068 RunCleanup = 1<<2,
00069 NoRecurse = 1<<3,
00070 Detailed = 1<<4,
00071 Action = 1<<5,
00072 NoHooks = 1<<6
00073 };
00074 Q_DECLARE_FLAGS(SignalFlags, SignalFlag);
00075
00076 Signal(const Signal & other);
00077 Signal & operator=(const Signal & other);
00078 virtual ~Signal();
00079
00082 bool isValid() const;
00083
00084 uint id() const;
00085 QString name() const;
00086 SignalFlags flags() const;
00087
00089 Type instanceType() const;
00090 Type returnType() const;
00091 QList<Type> paramTypes() const;
00092
00095 static Signal lookup(const char *name, Type type);
00096
00098 static QList<Signal> listSignals(Type type);
00099
00100 private:
00101 QTGLIB_NO_EXPORT Signal(uint id);
00102
00103 struct Private;
00104 QSharedDataPointer<Private> d;
00105 };
00106
00107 Q_DECLARE_OPERATORS_FOR_FLAGS(Signal::SignalFlags)
00108
00109 #if defined(DOXYGEN_RUN)
00110
00156 template <typename R, typename... Args>
00157 R emit(void *instance, const char *detailedSignal, const Args & ... args);
00158
00163 template <typename R, typename... Args>
00164 R emitWithDetail(void *instance, const char *signal, Quark detail, const Args & ... args);
00165
00166 #endif //DOXYGEN_RUN
00167
00168 }
00169
00170 #if !QGLIB_HAVE_CXX0X && !defined(QGLIB_SIGNAL_MAX_ARGS)
00171 # define QGLIB_SIGNAL_MAX_ARGS 9
00172 #endif
00173
00174 #define IN_QGLIB_SIGNAL_H
00175 # include "emitimpl.h"
00176 #undef IN_QGLIB_SIGNAL_H
00177
00178 #if defined(QGLIB_SIGNAL_MAX_ARGS)
00179 # undef QGLIB_SIGNAL_MAX_ARGS
00180 #endif
00181
00182 #endif