wxWidgets/include/wx/dfb/dfbptr.h
Vadim Zeitlin 3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00

110 lines
2.8 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// Name: wx/dfb/dfbptr.h
// Purpose: wxDfbPtr<T> for holding objects declared in wrapdfb.h
// Author: Vaclav Slavik
// Created: 2006-08-09
// Copyright: (c) 2006 REA Elektronik GmbH
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DFB_DFBPTR_H_
#define _WX_DFB_DFBPTR_H_
//-----------------------------------------------------------------------------
// wxDFB_DECLARE_INTERFACE
//-----------------------------------------------------------------------------
/**
Forward declares wx wrapper around DirectFB interface @a name.
Also declares wx##name##Ptr typedef for wxDfbPtr<wx##name> pointer.
@param name name of the DirectFB interface
*/
#define wxDFB_DECLARE_INTERFACE(name) \
class wx##name; \
typedef wxDfbPtr<wx##name> wx##name##Ptr;
//-----------------------------------------------------------------------------
// wxDfbPtr<T>
//-----------------------------------------------------------------------------
class wxDfbWrapperBase;
class WXDLLIMPEXP_CORE wxDfbPtrBase
{
protected:
static void DoAddRef(wxDfbWrapperBase *ptr);
static void DoRelease(wxDfbWrapperBase *ptr);
};
/**
This template implements smart pointer for keeping pointers to DirectFB
wrappers (i.e. wxIFoo classes derived from wxDfbWrapper<T>). Interface's
reference count is increased on copying and the interface is released when
the pointer is deleted.
*/
template<typename T>
class wxDfbPtr : private wxDfbPtrBase
{
public:
/**
Creates the pointer from raw pointer to the wrapper.
Takes ownership of @a ptr, i.e. AddRef() is @em not called on it.
*/
wxDfbPtr(T *ptr = NULL) : m_ptr(ptr) {}
/// Copy ctor
wxDfbPtr(const wxDfbPtr& ptr) { InitFrom(ptr); }
/// Dtor. Releases the interface
~wxDfbPtr() { Reset(); }
/// Resets the pointer to NULL, decreasing reference count of the interface.
void Reset()
{
if ( m_ptr )
{
this->DoRelease((wxDfbWrapperBase*)m_ptr);
m_ptr = NULL;
}
}
/// Cast to the wrapper pointer
operator T*() const { return m_ptr; }
// standard operators:
wxDfbPtr& operator=(T *ptr)
{
Reset();
m_ptr = ptr;
return *this;
}
wxDfbPtr& operator=(const wxDfbPtr& ptr)
{
Reset();
InitFrom(ptr);
return *this;
}
T& operator*() const { return *m_ptr; }
T* operator->() const { return m_ptr; }
private:
void InitFrom(const wxDfbPtr& ptr)
{
m_ptr = ptr.m_ptr;
if ( m_ptr )
this->DoAddRef((wxDfbWrapperBase*)m_ptr);
}
private:
T *m_ptr;
};
#endif // _WX_DFB_DFBPTR_H_