Eneboo - Documentación para desarrolladores
|
00001 /*************************************************************************** 00002 AQSVoidPtr_p.h 00003 ------------------- 00004 begin : 29/01/2011 00005 copyright : (C) 2003-2011 by InfoSiAL S.L. 00006 email : mail@infosial.com 00007 ***************************************************************************/ 00008 /*************************************************************************** 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; version 2 of the License. * 00012 ***************************************************************************/ 00013 /*************************************************************************** 00014 Este programa es software libre. Puede redistribuirlo y/o modificarlo 00015 bajo los términos de la Licencia Pública General de GNU en su 00016 versión 2, publicada por la Free Software Foundation. 00017 ***************************************************************************/ 00018 00019 #ifndef AQSVOIDPTR_P_H_ 00020 #define AQSVOIDPTR_P_H_ 00021 00022 #include "AQS_p.h" 00023 00024 #define AQ_DECLARE_AQS_PREFIX_VOID(Prefix,Class,BaseClass) \ 00025 protected: \ 00026 void internalInit(Prefix##Class *o) { \ 00027 o_ = o; \ 00028 AQS##BaseClass::internalInit(o); \ 00029 } \ 00030 private: \ 00031 Prefix##Class *o_; \ 00032 void init(void *vo) { \ 00033 o_ = reinterpret_cast<Prefix##Class *>(vo); \ 00034 if (!o_) { \ 00035 AQS_IF_DEBUG(printf("%s\n", \ 00036 AQ_QUOTEME(BaseClass: AQS##Class must be initialized with a valid Prefix##Class) \ 00037 )); \ 00038 } else { \ 00039 QObject::setName(AQ_QUOTEME(Prefix##Class)); \ 00040 AQS##BaseClass::internalInit(o_); \ 00041 AQS_IF_DEBUG(printf("%s init %p\n", AQ_QUOTEME(AQS##Class), o_)); \ 00042 specializedInternalInit(); \ 00043 } \ 00044 } \ 00045 void finish() { \ 00046 if (!finished_) { \ 00047 AQS_IF_DEBUG(printf("%s finish %p\n", AQ_QUOTEME(AQS##Class), o_)); \ 00048 finished_ = true; \ 00049 specializedInternalFinish(); \ 00050 } \ 00051 }\ 00052 public: \ 00053 virtual const char *RTTI() const { return #Class; } \ 00054 operator Prefix##Class *() { return o_; } \ 00055 operator const Prefix##Class *() const { return o_; } \ 00056 operator Prefix##Class &() { if (o_) return *o_; } \ 00057 operator const Prefix##Class &() const { if (o_) return *o_; } \ 00058 AQS##Class() : AQS##BaseClass (), o_(0) {} \ 00059 AQS##Class(void *vo) : AQS##BaseClass () {init(vo);} \ 00060 virtual ~AQS##Class() { \ 00061 finish(); \ 00062 } \ 00063 AQ_STATIC_CONSTRUCTOR(Prefix,Class) 00064 00065 #define AQ_DECLARE_AQS_VOID(Class,BaseClass) AQ_DECLARE_AQS_PREFIX_VOID(Q,Class,BaseClass) 00066 #define AQ_DECLARE_AQS_VOID_AQOBJECT(Class,BaseClass) AQ_DECLARE_AQS_PREFIX_VOID(AQ,Class,BaseClass) 00067 00068 class AQSVoidPtr : public AQSBaseObject 00069 { 00070 Q_OBJECT 00071 00072 AQ_DECLARE_AQS(VoidPtr) 00073 00074 public: 00075 AQSVoidPtr(void *vo) : AQSBaseObject() { 00076 init(vo); 00077 } 00078 00079 public slots : 00080 bool isEqual(void *other) const { 00081 return (o_ ? o_ == other : false); 00082 } 00083 00084 virtual QCString rtti() { 00085 return RTTI(); 00086 } 00087 00088 protected: 00089 void internalInit(void *o) { 00090 o_ = o; 00091 AQSBaseObject::internalInit(o); 00092 } 00093 00094 private: 00095 void *o_; 00096 }; 00097 00098 #endif /* AQSVOIDPTR_P_H_ */ 00099 00100 // @AQSVOIDPTR@ 00101