src/core/qtmetapointer.h
00001 //------------------------------------------------------------------------------
00002 // qtmetapointer.h
00003 //
00004 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
00005 //------------------------------------------------------------------------------
00006 #ifndef __QTMETAPOINTER_H__
00007 #define __QTMETAPOINTER_H__
00008 
00009 #include <Qt>
00010 
00011 class QtMetaPointer
00012 {
00013         private:
00014                 void copy(const QtMetaPointer& copyin)
00015                 {
00016                         ptr = copyin.ptr;
00017                 }
00018                 
00019                 void* ptr;
00020 
00021         public:
00022                 QtMetaPointer() {}
00023                 QtMetaPointer(void* ptr)
00024                 {
00025                         this->ptr = ptr;
00026                 }
00027 
00028                 QtMetaPointer(const QtMetaPointer& copyin)
00029                 {
00030                         copy(copyin);
00031                 }
00032 
00033                 QtMetaPointer& operator=(const QtMetaPointer& rhs)
00034                 {
00035                         if (this != &rhs)
00036                         {
00037                                 copy(rhs);
00038                         }
00039 
00040                         return *this;
00041                 }
00042                 
00043                 QtMetaPointer& operator=(void* rhs)
00044                 {
00045                         this->ptr = rhs;
00046                         return *this;
00047                 }
00048                 
00049                 ~QtMetaPointer() {}
00050 
00051                 bool operator==(const QtMetaPointer* fPtr) const
00052                 {
00053                         return (ptr == fPtr);
00054                 }
00055 
00056                 friend bool operator==(const void* fPtr, const QtMetaPointer& ref)
00057                 {
00058                         return (fPtr == ref.ptr);
00059                 }
00060 
00061                 void* operator->()
00062                 {
00063                         return ptr;
00064                 }
00065                 
00066                 operator void* () { return ptr; }
00067                 operator const void* () const { return ptr; }
00068 };
00069 
00070 Q_DECLARE_METATYPE(QtMetaPointer) 
00071 
00072 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator