summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qcom.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/qcom.h b/library/qcom.h
index 5703800..be94013 100644
--- a/library/qcom.h
+++ b/library/qcom.h
@@ -27,146 +27,146 @@
27 27
28#include <qpe/quuid.h> 28#include <qpe/quuid.h>
29#include <qpe/qpeglobal.h> 29#include <qpe/qpeglobal.h>
30 30
31#define QRESULT unsigned long 31#define QRESULT unsigned long
32#define QS_OK (QRESULT)0x00000000 32#define QS_OK (QRESULT)0x00000000
33#define QS_FALSE (QRESULT)0x00000001 33#define QS_FALSE (QRESULT)0x00000001
34 34
35#define QE_NOTIMPL (QRESULT)0x80000001 35#define QE_NOTIMPL (QRESULT)0x80000001
36#define QE_OUTOFMEMORY (QRESULT)0x80000002 36#define QE_OUTOFMEMORY (QRESULT)0x80000002
37#define QE_INVALIDARG (QRESULT)0x80000003 37#define QE_INVALIDARG (QRESULT)0x80000003
38#define QE_NOINTERFACE (QRESULT)0x80000004 38#define QE_NOINTERFACE (QRESULT)0x80000004
39#define QE_NOCOMPONENT (QRESULT)0x80000005 39#define QE_NOCOMPONENT (QRESULT)0x80000005
40 40
41// {1D8518CD-E8F5-4366-99E8-879FD7E482DE} 41// {1D8518CD-E8F5-4366-99E8-879FD7E482DE}
42#ifndef IID_QUnknown 42#ifndef IID_QUnknown
43#define IID_QUnknown QUuid(0x1d8518cd, 0xe8f5, 0x4366, 0x99, 0xe8, 0x87, 0x9f, 0xd7, 0xe4, 0x82, 0xde) 43#define IID_QUnknown QUuid(0x1d8518cd, 0xe8f5, 0x4366, 0x99, 0xe8, 0x87, 0x9f, 0xd7, 0xe4, 0x82, 0xde)
44#endif 44#endif
45 45
46struct Q_EXPORT QUnknownInterface 46struct Q_EXPORT QUnknownInterface
47{ 47{
48 virtual QRESULT queryInterface( const QUuid&, QUnknownInterface** ) = 0; 48 virtual QRESULT queryInterface( const QUuid&, QUnknownInterface** ) = 0;
49 virtual ulong addRef() = 0; 49 virtual ulong addRef() = 0;
50 virtual ulong release() = 0; 50 virtual ulong release() = 0;
51}; 51};
52 52
53// {D16111D4-E1E7-4C47-8599-24483DAE2E07} 53// {D16111D4-E1E7-4C47-8599-24483DAE2E07}
54#ifndef IID_QLibrary 54#ifndef IID_QLibrary
55#define IID_QLibrary QUuid( 0xd16111d4, 0xe1e7, 0x4c47, 0x85, 0x99, 0x24, 0x48, 0x3d, 0xae, 0x2e, 0x07) 55#define IID_QLibrary QUuid( 0xd16111d4, 0xe1e7, 0x4c47, 0x85, 0x99, 0x24, 0x48, 0x3d, 0xae, 0x2e, 0x07)
56#endif 56#endif
57 57
58struct Q_EXPORT QLibraryInterface : public QUnknownInterface 58struct Q_EXPORT QLibraryInterface : public QUnknownInterface
59{ 59{
60 virtual bool init() = 0; 60 virtual bool init() = 0;
61 virtual void cleanup() = 0; 61 virtual void cleanup() = 0;
62 virtual bool canUnload() const = 0; 62 virtual bool canUnload() const = 0;
63}; 63};
64 64
65#define Q_CREATE_INSTANCE( IMPLEMENTATION ) \ 65#define Q_CREATE_INSTANCE( IMPLEMENTATION ) \
66 IMPLEMENTATION *i = new IMPLEMENTATION; \ 66 IMPLEMENTATION *i = new IMPLEMENTATION; \
67 QUnknownInterface* iface = 0; \ 67 QUnknownInterface* iface = 0; \
68 i->queryInterface( IID_QUnknown, &iface ); \ 68 i->queryInterface( IID_QUnknown, &iface ); \
69 return iface; 69 return iface;
70 70
71template <class T> 71template <class T>
72class QInterfacePtr 72class QInterfacePtr
73{ 73{
74public: 74public:
75 QInterfacePtr():iface(0){} 75 QInterfacePtr():iface(0){}
76 76
77 QInterfacePtr( T* i) { 77 QInterfacePtr( T* i) {
78 if ( (iface = i) ) 78 if ( (iface = i) )
79 iface->addRef(); 79 iface->addRef();
80 } 80 }
81 81
82 QInterfacePtr(const QInterfacePtr<T> &p) { 82 QInterfacePtr(const QInterfacePtr<T> &p) {
83 if ( (iface = p.iface) ) 83 if ( (iface = p.iface) )
84 iface->addRef(); 84 iface->addRef();
85 } 85 }
86 86
87 ~QInterfacePtr() { 87 ~QInterfacePtr() {
88 if ( iface ) 88 if ( iface )
89 iface->release(); 89 iface->release();
90 } 90 }
91 91
92 QInterfacePtr<T> &operator=(const QInterfacePtr<T> &p) { 92 QInterfacePtr<T> &operator=(const QInterfacePtr<T> &p) {
93 if ( iface != p.iface ) { 93 if ( iface != p.iface ) {
94 if ( iface ) 94 if ( iface )
95 iface->release(); 95 iface->release();
96 if ( (iface = p.iface) ) 96 if ( (iface = p.iface) )
97 iface->addRef(); 97 iface->addRef();
98 } 98 }
99 return *this; 99 return *this;
100 } 100 }
101 101
102 QInterfacePtr<T> &operator=(T* i) { 102 QInterfacePtr<T> &operator=(T* i) {
103 if (iface != i ) { 103 if (iface != i ) {
104 if ( iface ) 104 if ( iface )
105 iface->release(); 105 iface->release();
106 if ( (iface = i) ) 106 if ( (iface = i) )
107 iface->addRef(); 107 iface->addRef();
108 } 108 }
109 return *this; 109 return *this;
110 } 110 }
111 111
112 bool operator==( const QInterfacePtr<T> &p ) const { return iface == p.iface; } 112 bool operator==( const QInterfacePtr<T> &p ) const { return iface == p.iface; }
113 113
114 bool operator!= ( const QInterfacePtr<T>& p ) const { return !( *this == p ); } 114 bool operator!= ( const QInterfacePtr<T>& p ) const { return !( *this == p ); }
115 115
116 bool isNull() const { return !iface; } 116 bool isNull() const { return !iface; }
117 117
118 T* operator->() const { return iface; } 118 T* operator->() const { return iface; }
119 119
120 T& operator*() const { return *iface; } 120 T& operator*() const { return *iface; }
121 121
122 operator T*() const { return iface; } 122 operator T*() const { return iface; }
123 123
124 QUnknownInterface** operator &() const { 124 QUnknownInterface** operator &() const {
125 if( iface ) 125 if( iface )
126 iface->release(); 126 iface->release();
127 return (QUnknownInterface**)&iface; 127 return (QUnknownInterface**)&iface;
128 } 128 }
129 129
130 T** operator &() { 130 T** operator &() {
131 if ( iface ) 131 if ( iface )
132 iface->release(); 132 iface->release();
133 return &iface; 133 return &iface;
134 } 134 }
135 135
136private: 136private:
137 T* iface; 137 T* iface;
138}; 138};
139 139
140 140
141// internal class that wraps an initialized ulong 141// internal class that wraps an initialized ulong
142struct Q_EXPORT QtULong 142struct Q_EXPORT QtULong
143{ 143{
144 QtULong() : ref( 0 ) { } 144 QtULong() : ref( 0 ) { }
145 operator unsigned long () const { return ref; } 145 operator unsigned long () const { return ref; }
146 unsigned long& operator++() { return ++ref; } 146 unsigned long& operator++() { return ++ref; }
147 unsigned long operator++( int ) { return ref++; } 147 unsigned long operator++( int ) { return ref++; }
148 unsigned long& operator--() { return --ref; } 148 unsigned long& operator--() { return --ref; }
149 unsigned long operator--( int ) { return ref--; } 149 unsigned long operator--( int ) { return ref--; }
150 150
151 unsigned long ref; 151 unsigned long ref;
152}; 152};
153 153
154#define Q_EXPORT_INTERFACE() \ 154#define Q_EXPORT_INTERFACE() \
155 extern "C" QUnknownInterface* ucm_instantiate QPE_EXPORT_SYMBOL () 155 extern "C" QPE_EXPORT_SYMBOL QUnknownInterface* ucm_instantiate ()
156 156
157#define Q_REFCOUNT \ 157#define Q_REFCOUNT \
158private: \ 158private: \
159 QtULong qtrefcount; \ 159 QtULong qtrefcount; \
160public: \ 160public: \
161 ulong addRef() {return qtrefcount++;} \ 161 ulong addRef() {return qtrefcount++;} \
162 ulong release() {if(!--qtrefcount){delete this;return 0;}return qtrefcount;} 162 ulong release() {if(!--qtrefcount){delete this;return 0;}return qtrefcount;}
163 163
164#else // QT_NO_COMPONENT 164#else // QT_NO_COMPONENT
165 165
166struct Q_EXPORT QUnknownInterface 166struct Q_EXPORT QUnknownInterface
167{ 167{
168}; 168};
169 169
170#endif // QT_NO_COMPONENT 170#endif // QT_NO_COMPONENT
171 171
172#endif // QCOM_H 172#endif // QCOM_H