]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/dfb/ifacehelpers.h
56a8808540a48e0c7e76854fc44ed696a940de76
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/dfb/ifacehelpers.h
3 // Purpose: helpers for dealing with DFB interfaces
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_DFB_IFACEHELPERS_H_
12 #define _WX_DFB_IFACEHELPERS_H_
14 //-----------------------------------------------------------------------------
15 // wxDFB_DECLARE_INTERFACE
16 //-----------------------------------------------------------------------------
19 Forward declares DirectFB interface @a name.
21 Also declares name##Ptr typedef for wxDfbPtr<name> pointer.
23 @param name name of the DirectFB interface
25 #define wxDFB_DECLARE_INTERFACE(name) \
27 typedef _##name name; \
28 typedef wxDfbPtr<name> name##Ptr;
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 // base class for wxDfbPtr
39 // increment/decrement refcount; see ifacehelpers.cpp for why using
41 static void DoAddRef(void *ptr
);
42 static void DoRelease(void *ptr
);
46 This template implements smart pointer for keeping pointers to DirectFB
47 interfaces. Interface's reference count is increased on copying and the
48 interface is released when the pointer is deleted.
51 class wxDfbPtr
: private wxDfbPtrBase
55 Creates the pointer from raw interface pointer.
57 Takes ownership of @a ptr, i.e. AddRef() is @em not called on it.
59 wxDfbPtr(T
*ptr
= NULL
) : m_ptr(ptr
) {}
62 wxDfbPtr(const wxDfbPtr
& ptr
) { InitFrom(ptr
); }
64 /// Dtor. Releases the interface
65 ~wxDfbPtr() { Reset(); }
67 /// Resets the pointer to NULL, decreasing reference count of the interface.
77 /// Cast to raw pointer
78 operator T
*() const { return m_ptr
; }
81 Cast to @em writeable raw pointer so that code like
82 "dfb->CreateFont(dfb, NULL, &desc, &fontPtr)" works.
84 Note that this operator calls Reset(), so using it looses the value.
92 // standard operators:
94 wxDfbPtr
& operator=(const wxDfbPtr
& ptr
)
101 T
& operator*() const { return *m_ptr
; }
102 T
* operator->() const { return m_ptr
; }
105 void InitFrom(const wxDfbPtr
& ptr
)
116 #endif // _WX_DFB_IFACEHELPERS_H_