]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/object.tex
corrected the completely wrong example (bug 545427)
[wxWidgets.git] / docs / latex / wx / object.tex
CommitLineData
a660d684
KB
1\section{\class{wxObject}}\label{wxobject}
2
3This is the root class of all wxWindows classes.
4It declares a virtual destructor which ensures that
5destructors get called for all derived class objects where necessary.
6
7wxObject is the hub of a dynamic object creation
8scheme, enabling a program to create instances of a class only knowing
9its string class name, and to query the class hierarchy.
10
11The class contains optional debugging versions
12of {\bf new} and {\bf delete}, which can help trace memory allocation
13and deallocation problems.
14
15wxObject can be used to implement reference counted objects, such as
16wxPen, wxBitmap and others.
17
18\wxheading{See also}
19
20\helpref{wxClassInfo}{wxclassinfo}, \helpref{Debugging overview}{debuggingoverview},\rtfsp
21\helpref{wxObjectRefData}{wxobjectrefdata}
22
23\latexignore{\rtfignore{\wxheading{Members}}}
24
25\membersection{wxObject::wxObject}\label{wxobjectconstr}
26
27\func{}{wxObject}{\void}
28
29Default constructor.
30
31\membersection{wxObject::\destruct{wxObject}}
32
33\func{}{wxObject}{\void}
34
35Destructor. Performs dereferencing, for those objects
36that use reference counting.
37
38\membersection{wxObject::m\_refData}\label{wxobjectmrefdata}
39
40\member{wxObjectRefData* }{m\_refData}
41
42Pointer to an object which is the object's reference-counted data.
43
44\wxheading{See also}
45
46\helpref{wxObject::Ref}{wxobjectref}, \helpref{wxObject::UnRef}{wxobjectunref},\rtfsp
47\helpref{wxObject::SetRefData}{wxobjectsetrefdata},\rtfsp
48\helpref{wxObject::GetRefData}{wxobjectgetrefdata},\rtfsp
49\helpref{wxObjectRefData}{wxobjectrefdata}
50
cd4915e2
VZ
51\membersection{wxObject::CopyObject}\label{wxobjectcopyobject}
52
53\func{virtual void}{CopyObject}{\param{wxObject\&}{ object\_dest}}
54
55Create a copy of this object in object\_dest. Must perform a full copy of self
56so that object\_dest will be valid after this object is deleted
57
a660d684
KB
58\membersection{wxObject::Dump}\label{wxobjectdump}
59
60\func{void}{Dump}{\param{ostream\&}{ stream}}
61
62A virtual function that should be redefined by derived classes to allow dumping of
63memory states.
64
65\wxheading{Parameters}
66
67\docparam{stream}{Stream on which to output dump information.}
68
69\wxheading{Remarks}
70
71Currently wxWindows does not define Dump for derived classes, but
72programmers may wish to use it for their own applications. Be sure to
73call the Dump member of the class's base class to allow all information to be dumped.
74
fe26d444
VZ
75The implementation of this function just writes the class name of the object
76in debug build (\_\_WXDEBUG\_\_ defined), otherwise it does nothing.
a660d684
KB
77
78\membersection{wxObject::GetClassInfo}\label{wxobjectgetclassinfo}
79
80\func{wxClassInfo *}{GetClassInfo}{\void}
81
82This virtual function is redefined for every class that requires run-time
83type information, when using DECLARE\_CLASS macros.
84
85\membersection{wxObject::GetRefData}\label{wxobjectgetrefdata}
86
87\constfunc{wxObjectRefData*}{GetRefData}{\void}
88
89Returns the {\bf m\_refData} pointer.
90
91\wxheading{See also}
92
93\helpref{wxObject::Ref}{wxobjectref}, \helpref{wxObject::UnRef}{wxobjectunref}, \helpref{wxObject::m\_refData}{wxobjectmrefdata},\rtfsp
94\helpref{wxObject::SetRefData}{wxobjectsetrefdata},\rtfsp
95\helpref{wxObjectRefData}{wxobjectrefdata}
96
97\membersection{wxObject::IsKindOf}\label{wxobjectiskindof}
98
99\func{bool}{IsKindOf}{\param{wxClassInfo *}{info}}
100
101Determines whether this class is a subclass of (or the same class as)
102the given class.
103
104\wxheading{Parameters}
105
106\docparam{info}{A pointer to a class information object, which may be obtained
107by using the CLASSINFO macro.}
108
109\wxheading{Return value}
110
111TRUE if the class represented by {\it info} is the same class as
112this one or is derived from it.
113
114\wxheading{Example}
115
116\begin{verbatim}
117 bool tmp = obj->IsKindOf(CLASSINFO(wxFrame));
118\end{verbatim}
119
120\membersection{wxObject::Ref}\label{wxobjectref}
121
122\func{void}{Ref}{\param{const wxObject\& }{clone}}
123
124Makes this object refer to the data in {\it clone}.
125
126\wxheading{Parameters}
127
128\docparam{clone}{The object to `clone'.}
129
130\wxheading{Remarks}
131
132First this function calls \helpref{wxObject::UnRef}{wxobjectunref} on itself
133to decrement (and perhaps free) the data it is currently referring to.
134
135It then sets its own m\_refData to point to that of {\it clone}, and increments the reference count
136inside the data.
137
138\wxheading{See also}
139
140\helpref{wxObject::UnRef}{wxobjectunref}, \helpref{wxObject::m\_refData}{wxobjectmrefdata},\rtfsp
141\helpref{wxObject::SetRefData}{wxobjectsetrefdata}, \helpref{wxObject::GetRefData}{wxobjectgetrefdata},\rtfsp
142\helpref{wxObjectRefData}{wxobjectrefdata}
143
144\membersection{wxObject::SetRefData}\label{wxobjectsetrefdata}
145
146\func{void}{SetRefData}{\param{wxObjectRefData*}{ data}}
147
148Sets the {\bf m\_refData} pointer.
149
150\wxheading{See also}
151
152\helpref{wxObject::Ref}{wxobjectref}, \helpref{wxObject::UnRef}{wxobjectunref}, \helpref{wxObject::m\_refData}{wxobjectmrefdata},\rtfsp
153\helpref{wxObject::GetRefData}{wxobjectgetrefdata},\rtfsp
154\helpref{wxObjectRefData}{wxobjectrefdata}
155
156\membersection{wxObject::UnRef}\label{wxobjectunref}
157
158\func{void}{UnRef}{\void}
159
160Decrements the reference count in the associated data, and if it is zero, deletes the data.
161The {\bf m\_refData} member is set to NULL.
162
163\wxheading{See also}
164
165\helpref{wxObject::Ref}{wxobjectref}, \helpref{wxObject::m\_refData}{wxobjectmrefdata},\rtfsp
166\helpref{wxObject::SetRefData}{wxobjectsetrefdata}, \helpref{wxObject::GetRefData}{wxobjectgetrefdata},\rtfsp
167\helpref{wxObjectRefData}{wxobjectrefdata}
168
169\membersection{wxObject::operator new}\label{wxobjectnew}
170
171\func{void *}{new}{\param{size\_t }{size}, \param{const wxString\& }{filename = NULL}, \param{int}{ lineNum = 0}}
172
173The {\it new} operator is defined for debugging versions of the library only, when
fe26d444 174the identifier \_\_WXDEBUG\_\_ is defined. It takes over memory allocation, allowing
a660d684
KB
175wxDebugContext operations.
176
177\membersection{wxObject::operator delete}\label{wxobjectdelete}
178
179\func{void}{delete}{\param{void }{buf}}
180
181The {\it delete} operator is defined for debugging versions of the library only, when
fe26d444 182the identifier \_\_WXDEBUG\_\_ is defined. It takes over memory deallocation, allowing
a660d684
KB
183wxDebugContext operations.
184
185\section{\class{wxObjectRefData}}\label{wxobjectrefdata}
186
187This class is used to store reference-counted data. Derive classes from this to
188store your own data. When retrieving information from a {\bf wxObject}'s reference data,
189you will need to cast to your own derived class.
190
191\wxheading{Friends}
192
193\helpref{wxObject}{wxobject}
194
195\wxheading{See also}
196
197\helpref{wxObject}{wxobject}
198
199\latexignore{\rtfignore{\wxheading{Members}}}
200
201\membersection{wxObjectRefData::m\_count}
202
203\member{int}{m\_count}
204
205Reference count. When this goes to zero during a \helpref{wxObject::UnRef}{wxobjectunref}, an object
206can delete the {\bf wxObjectRefData} object.
207
208\membersection{wxObjectRefData::wxObjectRefData}\label{wxobjectrefdataconstr}
209
210\func{}{wxObjectRefData}{\void}
211
212Default constructor. Initialises the {\bf m\_count} member to 1.
213
214\membersection{wxObjectRefData::\destruct{wxObjectRefData}}
215
216\func{}{wxObjectRefData}{\void}
217
218Destructor.
219
220