26 #ifndef OBJECTGENERATOR_H
27 #define OBJECTGENERATOR_H
31 #include <QSharedDataPointer>
35 class ObjectGeneratorPrivate;
38 class ObjectGenerator;
39 class ActionGenerator;
44 Q_DISABLE_COPY(ObjectGeneratorHolderData)
46 ObjectGenerator *generator()
const;
47 ActionGenerator *actionGenerator()
const;
50 friend class ObjectGenerator;
51 ObjectGeneratorHolderData(ObjectGenerator *generator);
52 ObjectGenerator *m_generator;
72 Q_DECLARE_PRIVATE(ObjectGenerator)
84 typedef QExplicitlySharedDataPointer<ObjectGeneratorHolderData> Ptr;
102 ObjectGenerator *addProperty(
const QByteArray &name,
const QVariant &value);
107 {
return generateHelper2(); }
120 QObject *
object = generateHelper2();
121 T *t = qobject_cast<T *>(
object);
122 if (!t)
delete object;
148 virtual const QMetaObject *metaObject()
const = 0;
155 bool hasInterface(
const char *
id)
const;
157 virtual QList<QByteArray> interfaces()
const;
167 bool extends(
const QMetaObject *super)
const;
174 inline bool extends(
const char *
id)
const
175 {
return id && hasInterface(
id); }
182 inline bool extends()
const
183 {
return extends_helper<T>(
reinterpret_cast<T *
>(0)); }
188 static bool isInited();
200 {
return module_helper<T>(
reinterpret_cast<T *
>(0)); }
202 ExtensionInfo info()
const;
204 template<
typename T>
static inline GeneratorList module_helper(
const QObject *)
206 template<
typename T>
static inline GeneratorList module_helper(
const void *)
209 inline bool extends_helper(
const QObject *)
const
210 {
return extends(&T::staticMetaObject); }
212 inline bool extends_helper(
const void *)
const
213 {
return extends(qobject_interface_iid<T *>()); }
214 QObject *generateHelper2()
const;
224 virtual QObject *generateHelper()
const = 0;
225 virtual void virtual_hook(
int id,
void *data);
226 QScopedPointer<ObjectGeneratorPrivate> d_ptr;
229 typedef ObjectGeneratorPrivate Data;
230 inline Data *data() {
return d_ptr.data(); }
234 template<
typename T,
typename I0 = void,
235 typename I1 = void,
typename I2 = void,
typename I3 = void,
236 typename I4 = void,
typename I5 = void,
typename I6 = void,
237 typename I7 = void,
typename I8 = void,
typename I9 =
void>
238 class GeneralGenerator :
public ObjectGenerator
262 return &T::staticMetaObject;
272 QList<QByteArray> result;
273 addInterface<I0>(result);
274 addInterface<I1>(result);
275 addInterface<I2>(result);
276 addInterface<I3>(result);
277 addInterface<I4>(result);
278 addInterface<I5>(result);
279 addInterface<I6>(result);
280 addInterface<I7>(result);
281 addInterface<I8>(result);
282 addInterface<I9>(result);
286 template<
typename Interface>
287 Q_INLINE_TEMPLATE
void addInterface(QList<QByteArray> &result, T *pointer = 0)
const
289 Interface *i = pointer;
291 if (qobject_interface_iid<Interface*>())
292 result << qobject_interface_iid<Interface*>();
297 template<
typename T,
typename I0 = void,
298 typename I1 = void,
typename I2 = void,
typename I3 = void,
299 typename I4 = void,
typename I5 = void,
typename I6 = void,
300 typename I7 = void,
typename I8 = void,
typename I9 =
void>
301 class SingletonGenerator :
public GeneralGenerator<T, I0, I1, I2, I3, I4, I5, I6, I7, I8, I9>
331 #endif // OBJECTGENERATOR_H