qtmetapointer.h
1 //------------------------------------------------------------------------------
2 // qtmetapointer.h
3 //
4 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
5 //------------------------------------------------------------------------------
6 #ifndef __QTMETAPOINTER_H__
7 #define __QTMETAPOINTER_H__
8 
9 #include <Qt>
10 
12 {
13  private:
14  void copy(const QtMetaPointer& copyin)
15  {
16  ptr = copyin.ptr;
17  }
18 
19  void* ptr;
20 
21  public:
22  QtMetaPointer() {}
23  QtMetaPointer(void* ptr)
24  {
25  this->ptr = ptr;
26  }
27 
28  QtMetaPointer(const QtMetaPointer& copyin)
29  {
30  copy(copyin);
31  }
32 
33  QtMetaPointer& operator=(const QtMetaPointer& rhs)
34  {
35  if (this != &rhs)
36  {
37  copy(rhs);
38  }
39 
40  return *this;
41  }
42 
43  QtMetaPointer& operator=(void* rhs)
44  {
45  this->ptr = rhs;
46  return *this;
47  }
48 
49  ~QtMetaPointer() {}
50 
51  friend bool operator==(const void* fPtr, const QtMetaPointer& ref)
52  {
53  return (fPtr == ref.ptr);
54  }
55 
56  void* operator->()
57  {
58  return ptr;
59  }
60 
61  operator void* () { return ptr; }
62  operator const void* () const { return ptr; }
63 };
64 
65 Q_DECLARE_METATYPE(QtMetaPointer)
66 
67 #endif