1 \section{\class{wxObject
}}\label{wxobject
}
3 This is the root class of all wxWidgets classes.
4 It declares a virtual destructor which ensures that
5 destructors get called for all derived class objects where necessary.
7 wxObject is the hub of a dynamic object creation
8 scheme, enabling a program to create instances of a class only knowing
9 its string class name, and to query the class hierarchy.
11 The class contains optional debugging versions
12 of
{\bf new
} and
{\bf delete
}, which can help trace memory allocation
13 and deallocation problems.
15 wxObject can be used to implement
\helpref{reference counted
}{trefcount
} objects,
16 such as wxPen, wxBitmap and others (see
\helpref{this list
}{refcountlist
}).
20 \helpref{wxClassInfo
}{wxclassinfo
},
\helpref{Debugging overview
}{debuggingoverview
},
\rtfsp
21 \helpref{wxObjectRefData
}{wxobjectrefdata
}
23 \wxheading{Derived from
}
27 \wxheading{Include files
}
31 \latexignore{\rtfignore{\wxheading{Members
}}}
33 \membersection{wxObject::wxObject
}\label{wxobjectctor
}
35 \func{}{wxObject
}{\void}
37 \func{}{wxObject
}{\param{const wxObject\&
}{ other
}}
39 Default and copy constructors.
41 \membersection{wxObject::
\destruct{wxObject
}}\label{wxobjectdtor
}
43 \func{}{wxObject
}{\void}
45 Destructor. Performs dereferencing, for those objects
46 that use reference counting.
48 \membersection{wxObject::m
\_refData}\label{wxobjectmrefdata
}
50 \member{wxObjectRefData*
}{m
\_refData}
52 Pointer to an object which is the object's reference-counted data.
56 \helpref{wxObject::Ref
}{wxobjectref
},
\helpref{wxObject::UnRef
}{wxobjectunref
},
\rtfsp
57 \helpref{wxObject::SetRefData
}{wxobjectsetrefdata
},
\rtfsp
58 \helpref{wxObject::GetRefData
}{wxobjectgetrefdata
},
\rtfsp
59 \helpref{wxObjectRefData
}{wxobjectrefdata
}
61 \membersection{wxObject::Dump
}\label{wxobjectdump
}
63 \func{void
}{Dump
}{\param{ostream\&
}{ stream
}}
65 A virtual function that may be redefined by derived classes to allow dumping of
68 This function is only defined in debug build and doesn't exist at all if
69 {\tt \_\_WXDEBUG\_\_} is not defined.
71 \wxheading{Parameters
}
73 \docparam{stream
}{Stream on which to output dump information.
}
77 Currently wxWidgets does not define Dump for derived classes, but
78 programmers may wish to use it for their own applications. Be sure to
79 call the Dump member of the class's base class to allow all information to be
82 The implementation of this function in wxObject just writes the class name of
85 \membersection{wxObject::GetClassInfo
}\label{wxobjectgetclassinfo
}
87 \func{wxClassInfo *
}{GetClassInfo
}{\void}
89 This virtual function is redefined for every class that requires run-time
90 type information, when using DECLARE
\_CLASS macros.
92 \membersection{wxObject::GetRefData
}\label{wxobjectgetrefdata
}
94 \constfunc{wxObjectRefData*
}{GetRefData
}{\void}
96 Returns the
{\bf m
\_refData} pointer.
100 \helpref{wxObject::Ref
}{wxobjectref
},
\helpref{wxObject::UnRef
}{wxobjectunref
},
\helpref{wxObject::m
\_refData}{wxobjectmrefdata
},
\rtfsp
101 \helpref{wxObject::SetRefData
}{wxobjectsetrefdata
},
\rtfsp
102 \helpref{wxObjectRefData
}{wxobjectrefdata
}
104 \membersection{wxObject::IsKindOf
}\label{wxobjectiskindof
}
106 \func{bool
}{IsKindOf
}{\param{wxClassInfo *
}{info
}}
108 Determines whether this class is a subclass of (or the same class as)
111 \wxheading{Parameters
}
113 \docparam{info
}{A pointer to a class information object, which may be obtained
114 by using the CLASSINFO macro.
}
116 \wxheading{Return value
}
118 true if the class represented by
{\it info
} is the same class as
119 this one or is derived from it.
124 bool tmp = obj->IsKindOf(CLASSINFO(wxFrame));
127 \membersection{wxObject::IsSameAs
}\label{wxobjectissameas
}
129 \func{bool
}{IsSameAs
}{\param{const wxObject\&
}{ obj
}}
131 Returns
\true if this object has the same data pointer as
\arg{obj
}. Notice
132 that
\true is returned if the data pointers are
\NULL in both objects.
134 This function only does a
\emph{shallow
} comparison, i.e. it doesn't compare
135 the objects pointed to by the data pointers of these objects.
137 \membersection{wxObject::Ref
}\label{wxobjectref
}
139 \func{void
}{Ref
}{\param{const wxObject\&
}{clone
}}
141 Makes this object refer to the data in
{\it clone
}.
143 \wxheading{Parameters
}
145 \docparam{clone
}{The object to `clone'.
}
149 First this function calls
\helpref{wxObject::UnRef
}{wxobjectunref
} on itself
150 to decrement (and perhaps free) the data it is currently referring to.
152 It then sets its own m
\_refData to point to that of
{\it clone
}, and increments the reference count
157 \helpref{wxObject::UnRef
}{wxobjectunref
},
\helpref{wxObject::m
\_refData}{wxobjectmrefdata
},
\rtfsp
158 \helpref{wxObject::SetRefData
}{wxobjectsetrefdata
},
\helpref{wxObject::GetRefData
}{wxobjectgetrefdata
},
\rtfsp
159 \helpref{wxObjectRefData
}{wxobjectrefdata
}
161 \membersection{wxObject::SetRefData
}\label{wxobjectsetrefdata
}
163 \func{void
}{SetRefData
}{\param{wxObjectRefData*
}{ data
}}
165 Sets the
{\bf m
\_refData} pointer.
169 \helpref{wxObject::Ref
}{wxobjectref
},
\helpref{wxObject::UnRef
}{wxobjectunref
},
\helpref{wxObject::m
\_refData}{wxobjectmrefdata
},
\rtfsp
170 \helpref{wxObject::GetRefData
}{wxobjectgetrefdata
},
\rtfsp
171 \helpref{wxObjectRefData
}{wxobjectrefdata
}
173 \membersection{wxObject::UnRef
}\label{wxobjectunref
}
175 \func{void
}{UnRef
}{\void}
177 Decrements the reference count in the associated data, and if it is zero, deletes the data.
178 The
{\bf m
\_refData} member is set to NULL.
182 \helpref{wxObject::Ref
}{wxobjectref
},
\helpref{wxObject::m
\_refData}{wxobjectmrefdata
},
\rtfsp
183 \helpref{wxObject::SetRefData
}{wxobjectsetrefdata
},
\helpref{wxObject::GetRefData
}{wxobjectgetrefdata
},
\rtfsp
184 \helpref{wxObjectRefData
}{wxobjectrefdata
}
186 \membersection{wxObject::UnShare
}\label{wxobjectunshare
}
188 \func{void
}{UnShare
}{\void}
190 Ensure that this object's data is not shared with any other object.
193 data, it is created using CreateRefData() below, if we have shared data
194 it is copied using CloneRefData(), otherwise nothing is done.
197 \membersection{wxObject::operator new
}\label{wxobjectnew
}
199 \func{void *
}{new
}{\param{size
\_t }{size
},
\param{const wxString\&
}{filename = NULL
},
\param{int
}{ lineNum =
0}}
201 The
{\it new
} operator is defined for debugging versions of the library only, when
202 the identifier
\_\_WXDEBUG\_\_ is defined. It takes over memory allocation, allowing
203 wxDebugContext operations.
205 \membersection{wxObject::operator delete
}\label{wxobjectdelete
}
207 \func{void
}{delete
}{\param{void
}{buf
}}
209 The
{\it delete
} operator is defined for debugging versions of the library only, when
210 the identifier
\_\_WXDEBUG\_\_ is defined. It takes over memory deallocation, allowing
211 wxDebugContext operations.
217 \section{\class{wxObjectRefData
}}\label{wxobjectrefdata
}
219 This class is used to store reference-counted data. Derive classes from this to
220 store your own data. When retrieving information from a
{\bf wxObject
}'s reference data,
221 you will need to cast to your own derived class.
225 \helpref{wxObject
}{wxobject
}
229 \helpref{wxObject
}{wxobject
}
231 \wxheading{Derived from
}
235 \wxheading{Include files
}
239 \latexignore{\rtfignore{\wxheading{Members
}}}
242 \membersection{wxObjectRefData::wxObjectRefData
}\label{wxobjectrefdatactor
}
244 \func{}{wxObjectRefData
}{\void}
246 Default constructor. Initialises the internal reference count to
1.
248 \membersection{wxObjectRefData::
\destruct{wxObjectRefData
}}\label{wxobjectrefdatadtor
}
250 \func{}{wxObjectRefData
}{\void}
252 Destructor. It's declared
{\tt protected
} so that wxObjectRefData instances will never
253 be destroyed directly but only as result of a
\helpref{DecRef
}{wxobjectrefdatadecref
} call.
255 \membersection{wxObjectRefData::GetRefCount
}\label{wxobjectrefdatagetrefcount
}
257 \constfunc{int
}{GetRefCount
}{\void}
259 Returns the reference count associated with this shared data.
260 When this goes to zero during a
\helpref{DecRef
}{wxobjectrefdatadecref
} call, the object
261 will auto-free itself.
263 \membersection{wxObjectRefData::DecRef
}\label{wxobjectrefdatadecref
}
265 \func{void
}{DecRef
}{\void}
267 Decrements the reference count associated with this shared data and, if it reaches zero,
268 destroys this instance of wxObjectRefData releasing its memory.
270 Please note that after calling this function, the caller should absolutely avoid to use
271 the pointer to this instance since it may not be valid anymore.
273 \membersection{wxObjectRefData::IncRef
}\label{wxobjectrefdataincref
}
275 \func{void
}{IncRef
}{\void}
277 Increments the reference count associated with this shared data.