Go to the documentation of this file.
34 #ifndef __XPLC_UTILS_H__
35 #define __XPLC_UTILS_H__
37 #if defined(__GNUC__) && __GNUC__ > 3
38 # pragma GCC system_header
47 #include <xplc/core.h>
48 #include <xplc/IWeakRef.h>
63 #define UUID_MAP_BEGIN(component) const UUID_Info component::xplc_iobject_uuids[] = {
68 #define UUID_MAP_ENTRY(iface) { &iface##_IID, reinterpret_cast<ptrdiff_t>(static_cast<iface*>(reinterpret_cast<ThisXPLCComponent*>(1))) - 1 },
75 #define UUID_MAP_ENTRY_2(iface, iface2) { &iface##_IID, reinterpret_cast<ptrdiff_t>(static_cast<iface2*>(reinterpret_cast<ThisXPLCComponent*>(1))) - 1 },
80 #define UUID_MAP_END { 0, 0 } };
112 #define xplcdelete delete
123 #define IMPLEMENT_IOBJECT(component) \
125 IObjectImplInternal xplc_iobject_internal; \
126 static const UUID_Info xplc_iobject_uuids[]; \
127 typedef component ThisXPLCComponent; \
129 virtual unsigned int addRef() { \
130 return ++xplc_iobject_internal.refcount; \
132 virtual unsigned int release() { \
133 if(--xplc_iobject_internal.refcount) \
134 return xplc_iobject_internal.refcount; \
136 xplc_iobject_internal.refcount = 1; \
137 if(xplc_iobject_internal.weakref) { \
138 xplc_iobject_internal.weakref->release(); \
139 xplc_iobject_internal.weakref->object = 0; \
144 virtual IObject* getInterface(const UUID& uuid) { \
145 return xplc_iobject_internal.getInterface(this, uuid, xplc_iobject_uuids); \
147 virtual IWeakRef* getWeakRef() { \
148 if(!xplc_iobject_internal.weakref) \
149 xplc_iobject_internal.weakref = new WeakRef(reinterpret_cast<IObject*>(reinterpret_cast<ptrdiff_t>(this) + xplc_iobject_uuids->delta)); \
150 xplc_iobject_internal.weakref->addRef(); \
151 return xplc_iobject_internal.weakref; \
183 template<
class Interface>
197 template<
class Interface>