QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
signal.h
00001 /*
00002     Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
00003     Copyright (C) 2010 Collabora Ltd.
00004       @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
00005 
00006     This library is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU Lesser General Public License as published
00008     by the Free Software Foundation; either version 2.1 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU Lesser General Public License for more details.
00015 
00016     You should have received a copy of the GNU Lesser General Public License
00017     along with this program.  If not, see <http://www.gnu.org/licenses/>.
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 //Qt's emit will clash
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 } //namespace QGlib
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