QtGStreamer 0.10.1
|
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 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_OBJECT_H 00020 #define QGLIB_OBJECT_H 00021 00022 #include "global.h" 00023 #include "refpointer.h" 00024 #include "paramspec.h" 00025 #include "value.h" 00026 #include "type.h" 00027 #include <QtCore/QList> 00028 00029 namespace QGlib { 00030 00038 class QTGLIB_EXPORT ObjectBase : public RefCountedObject 00039 { 00040 public: 00044 ParamSpecPtr findProperty(const char *name) const; 00045 00047 QList<ParamSpecPtr> listProperties() const; 00048 00052 Value property(const char *name) const; 00053 00058 template <class T> void setProperty(const char *name, const T & value); 00059 00065 void setProperty(const char *name, const Value & value); 00066 00067 void *data(const char *key) const; 00068 void *stealData(const char *key) const; 00069 void setData(const char *key, void *data, void (*destroyCallback)(void*) = NULL); 00070 00071 void *quarkData(const Quark & quark) const; 00072 void *stealQuarkData(const Quark & quark) const; 00073 void setQuarkData(const Quark & quark, void *data, void (*destroyCallback)(void*) = NULL); 00074 00075 protected: 00076 ObjectBase() {} 00077 virtual ~ObjectBase() {} 00078 Q_DISABLE_COPY(ObjectBase); 00079 00080 virtual void ref(bool increaseRef); 00081 virtual void unref(); 00082 }; 00083 00089 class QTGLIB_EXPORT Object : virtual public ObjectBase 00090 { 00091 QGLIB_WRAPPER(Object) 00092 }; 00093 00099 class QTGLIB_EXPORT Interface : virtual public ObjectBase 00100 { 00101 QGLIB_WRAPPER_DIFFERENT_C_CLASS(Interface, Object) 00102 }; 00103 00104 00105 template <class T> 00106 void ObjectBase::setProperty(const char *name, const T & value) 00107 { 00108 ParamSpecPtr param = findProperty(name); 00109 if (param) { 00110 Value v; 00111 v.init(param->valueType()); 00112 v.set<T>(value); 00113 setProperty(name, v); 00114 } 00115 } 00116 00117 } //namespace QGlib 00118 00119 QGLIB_REGISTER_TYPE(QGlib::Object) 00120 QGLIB_REGISTER_TYPE(QGlib::Interface) 00121 QGLIB_REGISTER_WRAPIMPL_FOR_SUBCLASSES_OF(QGlib::Object, QGlib::Private::wrapObject) 00122 00123 #endif