QtGStreamer 0.10.1
|
00001 /* 00002 Copyright (C) 2009-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 #include "type.h" 00020 #include "quark.h" 00021 #include <glib-object.h> 00022 00023 namespace QGlib { 00024 00025 Type Type::fromInstance(void *instance) 00026 { 00027 if (!instance) { 00028 return Invalid; 00029 } else { 00030 return G_TYPE_FROM_INSTANCE(instance); 00031 } 00032 } 00033 00034 Type Type::fromName(const char *name) 00035 { 00036 return g_type_from_name(name); 00037 } 00038 00039 QString Type::name() const 00040 { 00041 return QString::fromUtf8(g_type_name(m_type)); 00042 } 00043 00044 Quark Type::nameQuark() const 00045 { 00046 return g_type_qname(m_type); 00047 } 00048 00049 bool Type::isValid() const 00050 { 00051 return m_type != Type::Invalid; 00052 } 00053 00054 bool Type::isAbstract() const 00055 { 00056 return G_TYPE_IS_ABSTRACT(m_type); 00057 } 00058 00059 bool Type::isDerived() const 00060 { 00061 return G_TYPE_IS_DERIVED(m_type); 00062 } 00063 00064 bool Type::isFundamental() const 00065 { 00066 return G_TYPE_IS_FUNDAMENTAL(m_type); 00067 } 00068 00069 bool Type::isValueType() const 00070 { 00071 return G_TYPE_IS_VALUE_TYPE(m_type); 00072 } 00073 00074 bool Type::hasValueTable() const 00075 { 00076 return G_TYPE_HAS_VALUE_TABLE(m_type); 00077 } 00078 00079 bool Type::isClassed() const 00080 { 00081 return G_TYPE_IS_CLASSED(m_type); 00082 } 00083 00084 bool Type::isInstantiatable() const 00085 { 00086 return G_TYPE_IS_INSTANTIATABLE(m_type); 00087 } 00088 00089 bool Type::isDerivable() const 00090 { 00091 return G_TYPE_IS_DERIVABLE(m_type); 00092 } 00093 00094 bool Type::isDeepDerivable() const 00095 { 00096 return G_TYPE_IS_DEEP_DERIVABLE(m_type); 00097 } 00098 00099 bool Type::isInterface() const 00100 { 00101 return G_TYPE_IS_INTERFACE(m_type); 00102 } 00103 00104 Type Type::fundamental() const 00105 { 00106 return G_TYPE_FUNDAMENTAL(m_type); 00107 } 00108 00109 Type Type::parent() const 00110 { 00111 return g_type_parent(m_type); 00112 } 00113 00114 uint Type::depth() const 00115 { 00116 return g_type_depth(m_type); 00117 } 00118 00119 Type Type::nextBase(Type rootType) const 00120 { 00121 return g_type_next_base(m_type, rootType); 00122 } 00123 00124 bool Type::isA(Type is_a_type) const 00125 { 00126 return g_type_is_a(m_type, is_a_type); 00127 } 00128 00129 static inline QList<Type> gtypeArrayToList(GType *array, uint n) 00130 { 00131 QList<Type> result; 00132 for(uint i = 0; i<n; ++i) { 00133 result.append(array[i]); 00134 } 00135 g_free(array); 00136 return result; 00137 } 00138 00139 QList<Type> Type::children() const 00140 { 00141 uint n; 00142 GType *a = g_type_children(m_type, &n); 00143 return gtypeArrayToList(a, n); 00144 } 00145 00146 QList<Type> Type::interfaces() const 00147 { 00148 uint n; 00149 GType *a = g_type_interfaces(m_type, &n); 00150 return gtypeArrayToList(a, n); 00151 } 00152 00153 QList<Type> Type::interfacePrerequisites() const 00154 { 00155 uint n; 00156 GType *a = g_type_interface_prerequisites(m_type, &n); 00157 return gtypeArrayToList(a, n); 00158 } 00159 00160 void *Type::quarkData(const Quark & qname) const 00161 { 00162 return g_type_get_qdata(m_type, qname); 00163 } 00164 00165 void Type::setQuarkData(const Quark & qname, void *data) 00166 { 00167 g_type_set_qdata(m_type, qname, data); 00168 } 00169 00170 }