This is the root class of all wxWidgets classes. It declares a virtual destructor which ensures that destructors get called for all derived class objects where necessary.
wxObject is the hub of a dynamic object creation scheme, enabling a program to create instances of a class only knowing its string class name, and to query the class hierarchy.
The class contains optional debugging versions of new and delete, which can help trace memory allocation and deallocation problems.
wxObject can be used to implement reference counted objects, such as wxPen, wxBitmap and others (see this list).
See also
wxClassInfo, Debugging overview, wxObjectRefData
Members
wxObject::wxObject
wxObject::~wxObject
wxObject::m_refData
wxObject::Dump
wxObject::GetClassInfo
wxObject::GetRefData
wxObject::IsKindOf
wxObject::IsSameAs
wxObject::Ref
wxObject::SetRefData
wxObject::UnRef
wxObject::UnShare
wxObject::operator new
wxObject::operator delete
wxObject()
wxObject(const wxObject& other)
Default and copy constructors.
wxObject()
Destructor. Performs dereferencing, for those objects that use reference counting.
wxObjectRefData* m_refData
Pointer to an object which is the object's reference-counted data.
See also
wxObject::Ref, wxObject::UnRef, wxObject::SetRefData, wxObject::GetRefData, wxObjectRefData
void Dump(ostream& stream)
A virtual function that may be redefined by derived classes to allow dumping of memory states.
This function is only defined in debug build and doesn't exist at all if __WXDEBUG__ is not defined.
Parameters
stream
Remarks
Currently wxWidgets does not define Dump for derived classes, but programmers may wish to use it for their own applications. Be sure to call the Dump member of the class's base class to allow all information to be dumped.
The implementation of this function in wxObject just writes the class name of the object.
wxClassInfo * GetClassInfo()
This virtual function is redefined for every class that requires run-time type information, when using DECLARE_CLASS macros.
wxObjectRefData* GetRefData() const
Returns the m_refData pointer.
See also
wxObject::Ref, wxObject::UnRef, wxObject::m_refData, wxObject::SetRefData, wxObjectRefData
bool IsKindOf(wxClassInfo *info)
Determines whether this class is a subclass of (or the same class as) the given class.
Parameters
info
Return value
true if the class represented by info is the same class as this one or is derived from it.
Example
bool tmp = obj->IsKindOf(CLASSINFO(wxFrame));
bool IsSameAs(const wxObject& obj)
Returns true if this object has the same data pointer as obj. Notice that true is returned if the data pointers are NULL in both objects.
This function only does a shallow comparison, i.e. it doesn't compare the objects pointed to by the data pointers of these objects.
void Ref(const wxObject& clone)
Makes this object refer to the data in clone.
Parameters
clone
Remarks
First this function calls wxObject::UnRef on itself to decrement (and perhaps free) the data it is currently referring to.
It then sets its own m_refData to point to that of clone, and increments the reference count inside the data.
See also
wxObject::UnRef, wxObject::m_refData, wxObject::SetRefData, wxObject::GetRefData, wxObjectRefData
void SetRefData(wxObjectRefData* data)
Sets the m_refData pointer.
See also
wxObject::Ref, wxObject::UnRef, wxObject::m_refData, wxObject::GetRefData, wxObjectRefData
void UnRef()
Decrements the reference count in the associated data, and if it is zero, deletes the data. The m_refData member is set to NULL.
See also
wxObject::Ref, wxObject::m_refData, wxObject::SetRefData, wxObject::GetRefData, wxObjectRefData
void UnShare()
Ensure that this object's data is not shared with any other object.
if we have no data, it is created using CreateRefData() below, if we have shared data it is copied using CloneRefData(), otherwise nothing is done.
void * new(size_t size, const wxString& filename = NULL, int lineNum = 0)
The new operator is defined for debugging versions of the library only, when the identifier __WXDEBUG__ is defined. It takes over memory allocation, allowing wxDebugContext operations.
void delete(void buf)
The delete operator is defined for debugging versions of the library only, when the identifier __WXDEBUG__ is defined. It takes over memory deallocation, allowing wxDebugContext operations.