Logo ROOT   6.08/07
Reference Guide
TGeoExtension.cxx
Go to the documentation of this file.
1 // Author: Andrei.Gheata@cern.ch 29/05/2013
2 // Following proposal by Markus Frank
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TGeoExtension.h"
13 
15 
16 /** \class TGeoExtension
17 \ingroup Geometry_classes
18 
19 ABC for user objects attached to TGeoVolume or TGeoNode.
20 Provides interface for getting a reference (grab) and
21 releasing the extension object (release), allowing for
22 derived classes to implement reference counted sharing.
23 The user who should attach extensions to logical volumes
24 or nodes BEFORE applying misalignment information so that
25 these will be available to all copies.
26 */
27 
29 
30 /** \class TGeoRCExtension
31 \ingroup Geometry_classes
32 
33 Reference counted extension which has a pointer to and
34 owns a user defined TObject. This class can be used as
35 model for a reference counted derivation from TGeoExtension.
36 
37 Note: Creating a TGeoRCExtension with new() automatically grabs it, but the
38 creator has to Release it before the pointer gets out of scope.
39 The following sequence is valid:
40 
41 ~~~ {.cpp}
42  // producer:
43  TGeoRCExtension *ext = new TGeoRCExtension();
44  some_TGeoVolume->SetUserExtension(ext);
45  ext->Release();
46  // user:
47  TGeoRCExtension *ext = dynamic_cast<TGeoRCExtension*>(some_TGeoVolume->GrabUserExtension());
48  // ... use extension
49  ext->Release();
50 ~~~
51 
52 The extension is going to be released by the TGeoVolume holder at the destruction
53 or when calling SetUserExtension(0).
54 
55 The following usage is not correct:
56 
57 ~~~ {.cpp}
58  some_TGeoVolume->SetUserExtension(new TGeoRCExtension())
59 ~~~
60 
61 since the producer code does not release the extension.
62 One cannot call directly "delete ext" nor allocate an extension on the stack,
63 since the destructor is protected. Use Release instead.
64 */
ABC for user objects attached to TGeoVolume or TGeoNode.
Definition: TGeoExtension.h:21
#define ClassImp(name)
Definition: Rtypes.h:279
Reference counted extension which has a pointer to and owns a user defined TObject.
Definition: TGeoExtension.h:38