aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a03321.html
blob: c1074e7a3e3c3e199016285ccad9c3791cb56ee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>NeL:  TemplateNLMISC::CRefPtr&lt; T &gt; class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex">  <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a>  | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>NLMISC::CRefPtr&lt; T &gt; Class Template Reference</h1><code>#include &lt;<a class="el" href="a06402.html">smart_ptr.h</a>&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<h3>template&lt;class T&gt;<br>
 class NLMISC::CRefPtr&lt; T &gt;</h3>

<a class="el" href="a03321.html">CRefPtr</a>: an handle on a ptr. T Must derive from <a class="el" href="a02209.html">CRefCount</a>. If you use <a class="el" href="a03321.html">CRefPtr</a>, you can kill the object simply by calling delete (T*)RefPtr, or the <a class="el" href="a03321.html#NLMISC_1_1CRefPtra3">kill()</a> method. All other <a class="el" href="a03321.html">CRefPtr</a> which point to it can know if it has been deleted. (but you must be sure that this ptr is not handle by a SmartPtr, of course...)<p>
SmartPtr are compatible with RefPtr. A ptr may be link to a <a class="el" href="a03321.html">CRefPtr</a> and a <a class="el" href="a03408.html">CSmartPtr</a>. As example, when the <a class="el" href="a03408.html">CSmartPtr</a> will destroy him, <a class="el" href="a03321.html">CRefPtr</a> will be informed... Sample: <pre class="fragment"><div>        <span class="keywordtype">void</span>    foo()
        {
                A                               *p;
                CSmartPtr&lt;A&gt;    sp;
                CRefPtr&lt;A&gt;              rp;

                p= <span class="keyword">new</span> A;
                sp= p;          <span class="comment">// OK. p is now owned by sp and will be deleted by sp.</span>
                rp= p;          <span class="comment">// OK. rp handle p.</span>
                sp= NULL;       <span class="comment">// Destruction. p deleted. rp automatically informed.</span>
                <span class="keywordflow">if</span>(rp==NULL)
                        thisIsGood();   <span class="comment">// rp==NULL.</span>
        }
</div></pre><p>
<b>PERFORMANCE</b> <b>WARNING!</b> <a class="el" href="a03321.html#NLMISC_1_1CRefPtra8">operator=()</a> are about 10 times slower than normal pointers. So use them wisely. For local use, prefer cast the refptr to a normal Ptr. Also, an object used with a <a class="el" href="a03321.html">CRefPtr</a> will allocate a small PtrInfo (one only per object, not per ptr). <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a03408.html">CSmartPtr</a> </dd></dl>

<p>

<p>
Definition at line <a class="el" href="a06402.html#l00256">256</a> of file <a class="el" href="a06402.html">smart_ptr.h</a>.<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtra0">CRefPtr</a> (const <a class="el" href="a03321.html">CRefPtr</a> &amp;copy)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Copy constructor.  <a href="#NLMISC_1_1CRefPtra0"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtra1">CRefPtr</a> (T *<a class="el" href="a04223.html#a576">v</a>)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Attach a ptr to a RefPtr.  <a href="#NLMISC_1_1CRefPtra1"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtra2">CRefPtr</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Init a NULL Ptr.  <a href="#NLMISC_1_1CRefPtra2"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtra3">kill</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>T &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtra4">operator *</a> (void) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Indirection operator. Doesn't test if ptr has been deleted somewhere, and doesn't check NULL.  <a href="#NLMISC_1_1CRefPtra4"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtra5">operator T *</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Cast operator. Check if the object has been deleted somewhere, and return NULL if this is the case.  <a href="#NLMISC_1_1CRefPtra5"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>T *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtra6">operator-&gt;</a> (void) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Selection operator. Doesn't test if ptr has been deleted somewhere, and doesn't check NULL.  <a href="#NLMISC_1_1CRefPtra6"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03321.html">CRefPtr</a> &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtra7">operator=</a> (const <a class="el" href="a03321.html">CRefPtr</a> &amp;copy)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">operator=. Giving a NULL pointer is a valid operation.  <a href="#NLMISC_1_1CRefPtra7"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03321.html">CRefPtr</a> &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtra8">operator=</a> (T *<a class="el" href="a04223.html#a576">v</a>)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">operator=. Giving a NULL pointer is a valid operation.  <a href="#NLMISC_1_1CRefPtra8"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtra9">~CRefPtr</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Release the RefPtr.  <a href="#NLMISC_1_1CRefPtra9"></a><br><br></td></tr>
<tr><td colspan=2><br><h2>Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtrd0">unRef</a> () const </td></tr>

<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03320.html">CRefCount::CPtrInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a></td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>T *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a></td></tr>

</table>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="NLMISC_1_1CRefPtra2" doxytag="NLMISC::CRefPtr::CRefPtr" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::<a class="el" href="a03321.html">CRefPtr</a> </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Init a NULL Ptr. 
<p>

<p>
Definition at line <a class="el" href="a06403.html#l00153">153</a> of file <a class="el" href="a06403.html">smart_ptr_inline.h</a>.
<p>
References <a class="el" href="a06402.html#l00097">REF_TRACE</a>.
<p>
<div class="fragment"><pre>00154 { 
00155         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>= &amp;CRefCount::NullPtrInfo;
00156         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a>= NULL;
00157 
00158         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"Smart()"</span>);
00159 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CRefPtra1" doxytag="NLMISC::CRefPtr::CRefPtr" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::<a class="el" href="a03321.html">CRefPtr</a> </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">T *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>v</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Attach a ptr to a RefPtr. 
<p>

<p>
Definition at line <a class="el" href="a06403.html#l00160">160</a> of file <a class="el" href="a06403.html">smart_ptr_inline.h</a>.
<p>
References <a class="el" href="a06402.html#l00097">REF_TRACE</a>, <a class="el" href="a06402.html#l00056">NLMISC::CRefCount::CPtrInfo::RefCount</a>, and <a class="el" href="a05646.html#l00237">v</a>.
<p>
<div class="fragment"><pre>00161 {
00162         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a>= <a class="code" href="a04223.html#a576">v</a>;
00163     <span class="keywordflow">if</span>(<a class="code" href="a04223.html#a576">v</a>)
00164         {
00165                 <span class="comment">// If no CRefPtr handles v, create a pinfo ref...</span>
00166                 <span class="keywordflow">if</span>(<a class="code" href="a04223.html#a576">v</a>-&gt;pinfo-&gt;IsNullPtrInfo)
00167                         <a class="code" href="a04223.html#a576">v</a>-&gt;pinfo=<span class="keyword">new</span> CRefCount::CPtrInfo(v);
00168                 <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>=<a class="code" href="a04223.html#a576">v</a>-&gt;pinfo;
00169                 <span class="comment">// v is now used by this.</span>
00170                 <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;RefCount++;
00171         }
00172         <span class="keywordflow">else</span>
00173                 <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>= &amp;CRefCount::NullPtrInfo;
00174 
00175         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"Smart(T*)"</span>);
00176 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CRefPtra0" doxytag="NLMISC::CRefPtr::CRefPtr" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::<a class="el" href="a03321.html">CRefPtr</a> </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03321.html">CRefPtr</a>&lt; T &gt; &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>copy</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Copy constructor. 
<p>

<p>
Definition at line <a class="el" href="a06403.html#l00177">177</a> of file <a class="el" href="a06403.html">smart_ptr_inline.h</a>.
<p>
References <a class="el" href="a06402.html#l00259">NLMISC::CRefPtr&lt; T &gt;::pinfo</a>, <a class="el" href="a06402.html#l00055">NLMISC::CRefCount::CPtrInfo::Ptr</a>, <a class="el" href="a06402.html#l00097">REF_TRACE</a>, and <a class="el" href="a06402.html#l00056">NLMISC::CRefCount::CPtrInfo::RefCount</a>.
<p>
<div class="fragment"><pre>00178 {
00179         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>=copy.pinfo;
00180         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;RefCount++;
00181         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a>= (T*)<a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;Ptr;
00182 
00183         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"SmartCopy()"</span>);
00184 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CRefPtra9" doxytag="NLMISC::CRefPtr::~CRefPtr" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::~<a class="el" href="a03321.html">CRefPtr</a> </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Release the RefPtr. 
<p>

<p>
Definition at line <a class="el" href="a06403.html#l00185">185</a> of file <a class="el" href="a06403.html">smart_ptr_inline.h</a>.
<p>
References <a class="el" href="a06402.html#l00097">REF_TRACE</a>, and <a class="el" href="a06403.html#l00121">NLMISC::CRefPtr&lt; T &gt;::unRef()</a>.
<p>
<div class="fragment"><pre>00186 {
00187         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"~Smart()"</span>);
00188 
00189         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrd0">unRef</a>();
00190         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>= &amp;CRefCount::NullPtrInfo;
00191         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a>= NULL;
00192 }
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NLMISC_1_1CRefPtra3" doxytag="NLMISC::CRefPtr::kill" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> void <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::kill </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
kill/delete the object pointed by the pointer, and inform the other RefPtr of this. "rp.kill()" and "delete (T*)rp" do the same thing, except that rp NULLity is updated with <a class="el" href="a03321.html#NLMISC_1_1CRefPtra3">kill()</a>. RefPtr which point to the same object could know if the object is valid, by just testing it ( by an implicit call to the cast operator to T*). But any calls to <a class="el" href="a03321.html#NLMISC_1_1CRefPtra6">operator-&gt;()</a> or <a class="el" href="a03321.html#NLMISC_1_1CRefPtra4">operator*()</a> will have unpredictible effects (may crash... :) ).
<p>
Definition at line <a class="el" href="a06403.html#l00241">241</a> of file <a class="el" href="a06403.html">smart_ptr_inline.h</a>.
<p>
References <a class="el" href="a06402.html#l00055">NLMISC::CRefCount::CPtrInfo::Ptr</a>, <a class="el" href="a06402.html#l00097">REF_TRACE</a>, and <a class="el" href="a06403.html#l00121">NLMISC::CRefPtr&lt; T &gt;::unRef()</a>.
<p>
<div class="fragment"><pre>00242 {
00243         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"SmartKill"</span>);
00244 
00245         T       *ptr= (T*)<a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;Ptr;
00246 
00247         <span class="comment">// First, release the refptr.</span>
00248         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrd0">unRef</a>();
00249         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>= &amp;CRefCount::NullPtrInfo;
00250         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a>= NULL;
00251 
00252         <span class="comment">// Then delete the pointer.</span>
00253         <span class="keywordflow">if</span>(ptr)
00254                 <span class="keyword">delete</span> ptr;
00255 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CRefPtra4" doxytag="NLMISC::CRefPtr::operator *" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> T &amp; <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::operator * </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Indirection operator. Doesn't test if ptr has been deleted somewhere, and doesn't check NULL. 
<p>

<p>
Definition at line <a class="el" href="a06403.html#l00272">272</a> of file <a class="el" href="a06403.html">smart_ptr_inline.h</a>.
<p>
References <a class="el" href="a06402.html#l00097">REF_TRACE</a>.
<p>
<div class="fragment"><pre>00273 { 
00274         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"Smart *()"</span>);
00275         <span class="keywordflow">return</span> *<a class="code" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a>; 
00276 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CRefPtra5" doxytag="NLMISC::CRefPtr::operator T *" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::operator T * </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Cast operator. Check if the object has been deleted somewhere, and return NULL if this is the case. 
<p>

<p>
Definition at line <a class="el" href="a06403.html#l00260">260</a> of file <a class="el" href="a06403.html">smart_ptr_inline.h</a>.
<p>
References <a class="el" href="a06402.html#l00055">NLMISC::CRefCount::CPtrInfo::Ptr</a>, and <a class="el" href="a06402.html#l00097">REF_TRACE</a>.
<p>
<div class="fragment"><pre>00261 {
00262         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"SmartCast T*()"</span>);
00263 
00264         <span class="comment">// Refresh Ptr.</span>
00265         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a>= (T*)<a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;Ptr;
00266         <span class="keywordflow">return</span> <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a>;
00267 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CRefPtra6" doxytag="NLMISC::CRefPtr::operator->" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> T * <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::operator-&gt; </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Selection operator. Doesn't test if ptr has been deleted somewhere, and doesn't check NULL. 
<p>

<p>
Definition at line <a class="el" href="a06403.html#l00277">277</a> of file <a class="el" href="a06403.html">smart_ptr_inline.h</a>.
<p>
References <a class="el" href="a06402.html#l00097">REF_TRACE</a>.
<p>
<div class="fragment"><pre>00278 { 
00279         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"Smart -&gt;()"</span>);
00280         <span class="keywordflow">return</span> <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a>;  
00281 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CRefPtra7" doxytag="NLMISC::CRefPtr::operator=" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a03321.html">CRefPtr</a>&lt; T &gt; &amp; <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::operator= </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03321.html">CRefPtr</a>&lt; T &gt; &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>copy</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
operator=. Giving a NULL pointer is a valid operation. 
<p>

<p>
Definition at line <a class="el" href="a06403.html#l00223">223</a> of file <a class="el" href="a06403.html">smart_ptr_inline.h</a>.
<p>
References <a class="el" href="a06402.html#l00259">NLMISC::CRefPtr&lt; T &gt;::pinfo</a>, <a class="el" href="a06402.html#l00055">NLMISC::CRefCount::CPtrInfo::Ptr</a>, <a class="el" href="a06402.html#l00097">REF_TRACE</a>, <a class="el" href="a06402.html#l00056">NLMISC::CRefCount::CPtrInfo::RefCount</a>, and <a class="el" href="a06403.html#l00121">NLMISC::CRefPtr&lt; T &gt;::unRef()</a>.
<p>
<div class="fragment"><pre>00224 {
00225         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"ope=(Smart)Start"</span>);
00226 
00227         <span class="comment">// The auto equality test is implicitly done by upcounting first "copy", then downcounting "this".</span>
00228         copy.pinfo-&gt;RefCount++;
00229         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrd0">unRef</a>();
00230         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>=copy.pinfo;
00231         <span class="comment">// Must Refresh the ptr.</span>
00232         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a>= (T*)<a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;Ptr;
00233 
00234         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"ope=(Smart)End"</span>);
00235         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
00236 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CRefPtra8" doxytag="NLMISC::CRefPtr::operator=" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a03321.html">CRefPtr</a>&lt; T &gt; &amp; <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::operator= </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">T *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>v</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
operator=. Giving a NULL pointer is a valid operation. 
<p>

<p>
Definition at line <a class="el" href="a06403.html#l00196">196</a> of file <a class="el" href="a06403.html">smart_ptr_inline.h</a>.
<p>
References <a class="el" href="a06402.html#l00097">REF_TRACE</a>, <a class="el" href="a06403.html#l00121">NLMISC::CRefPtr&lt; T &gt;::unRef()</a>, and <a class="el" href="a05646.html#l00237">v</a>.
<p>
<div class="fragment"><pre>00197 {
00198         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"ope=(T*)Start"</span>);
00199 
00200 
00201         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a>= <a class="code" href="a04223.html#a576">v</a>;
00202         <span class="keywordflow">if</span>(<a class="code" href="a04223.html#a576">v</a>)
00203         {
00204                 <span class="comment">// If no CRefPtr handles v, create a pinfo ref...</span>
00205                 <span class="keywordflow">if</span>(<a class="code" href="a04223.html#a576">v</a>-&gt;pinfo-&gt;IsNullPtrInfo)
00206                         <a class="code" href="a04223.html#a576">v</a>-&gt;pinfo=<span class="keyword">new</span> CRefCount::CPtrInfo(v);
00207                 <span class="comment">// The auto equality test is implicitly done by upcounting first "v", then downcounting "this".</span>
00208                 <a class="code" href="a04223.html#a576">v</a>-&gt;pinfo-&gt;RefCount++;
00209                 <a class="code" href="a03321.html#NLMISC_1_1CRefPtrd0">unRef</a>();
00210                 <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>= <a class="code" href="a04223.html#a576">v</a>-&gt;pinfo;
00211         }
00212         <span class="keywordflow">else</span>
00213         {
00214                 <a class="code" href="a03321.html#NLMISC_1_1CRefPtrd0">unRef</a>();
00215                 <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>= &amp;CRefCount::NullPtrInfo;
00216         }
00217 
00218 
00219         <a class="code" href="a04979.html#a1">REF_TRACE</a>(<span class="stringliteral">"ope=(T*)End"</span>);
00220 
00221         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
00222 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CRefPtrd0" doxytag="NLMISC::CRefPtr::unRef" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> void <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::unRef </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline, private]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06403.html#l00121">121</a> of file <a class="el" href="a06403.html">smart_ptr_inline.h</a>.
<p>
References <a class="el" href="a06402.html#l00058">NLMISC::CRefCount::CPtrInfo::IsNullPtrInfo</a>, <a class="el" href="a06402.html#l00055">NLMISC::CRefCount::CPtrInfo::Ptr</a>, <a class="el" href="a06402.html#l00056">NLMISC::CRefCount::CPtrInfo::RefCount</a>, and <a class="el" href="a06403.html#l00039">SMART_INLINE</a>.
<p>
Referenced by <a class="el" href="a06403.html#l00241">NLMISC::CRefPtr&lt; T &gt;::kill()</a>, <a class="el" href="a06403.html#l00196">NLMISC::CRefPtr&lt; T &gt;::operator=()</a>, and <a class="el" href="a06403.html#l00185">NLMISC::CRefPtr&lt; T &gt;::~CRefPtr()</a>.
<p>
<div class="fragment"><pre>00122 {
00123         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;RefCount--;
00124         <span class="keywordflow">if</span>(<a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;RefCount==0)
00125         {
00126                 <span class="comment">// In CRefPtr, Never delete the object.</span>
00127 
00128                 <span class="comment">// We may be in the case that this==NullPtrInfo, and our NullPtrInfo has done a total round. Test it.</span>
00129                 <span class="keywordflow">if</span>(<a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;IsNullPtrInfo)
00130                 {
00131                         <span class="comment">// This should not happens, but I'm not sure :) ...</span>
00132                         <span class="comment">// Reset the NullPtrInfo to a middle round.</span>
00133                         <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;RefCount= 0x7FFFFFFF;
00134                 }
00135                 <span class="keywordflow">else</span>
00136                 {
00137                         <span class="comment">// If the CRefPtr still point to a valid object.</span>
00138                         <span class="keywordflow">if</span>(<a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;Ptr)
00139                         {
00140                                 <span class="comment">// Inform the Object that no more CRefPtr points on it.</span>
00141                                 ((T*)(<a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>-&gt;Ptr))-&gt;pinfo= &amp;CRefCount::NullPtrInfo;
00142                         }
00143                         <span class="comment">// Then delete the pinfo.</span>
00144                         <span class="keyword">delete</span> <a class="code" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a>;
00145                 }
00146 
00147         }
00148 }
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Field Documentation</h2>
<a class="anchor" name="NLMISC_1_1CRefPtrr0" doxytag="NLMISC::CRefPtr::pinfo" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a03320.html">CRefCount::CPtrInfo</a>* <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::<a class="el" href="a03321.html#NLMISC_1_1CRefPtrr0">pinfo</a><code> [private]</code>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06402.html#l00259">259</a> of file <a class="el" href="a06402.html">smart_ptr.h</a>.
<p>
Referenced by <a class="el" href="a06403.html#l00177">NLMISC::CRefPtr&lt; T &gt;::CRefPtr()</a>, and <a class="el" href="a06403.html#l00223">NLMISC::CRefPtr&lt; T &gt;::operator=()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CRefPtrr1" doxytag="NLMISC::CRefPtr::Ptr" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" colspan="4">
template&lt;class T&gt; </td>
        </tr>
        <tr>
          <td class="md" nowrap valign="top"> T* <a class="el" href="a03321.html">NLMISC::CRefPtr</a>&lt; T &gt;::<a class="el" href="a03321.html#NLMISC_1_1CRefPtrr1">Ptr</a><code> [mutable, private]</code>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06402.html#l00260">260</a> of file <a class="el" href="a06402.html">smart_ptr.h</a>.    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a06402.html">smart_ptr.h</a><li><a class="el" href="a06403.html">smart_ptr_inline.h</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 13:31:38 2004 for NeL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
</a>1.3.6 </small></address>
</body>
</html>