ROOT
v6-24
Reference Guide
Loading...
Searching...
No Matches
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
14
#include "
Rtypes.h
"
15
16
ClassImp
(
TGeoExtension
);
17
18
/** \class TGeoExtension
19
\ingroup Geometry_classes
20
21
ABC for user objects attached to TGeoVolume or TGeoNode.
22
Provides interface for getting a reference (grab) and
23
releasing the extension object (release), allowing for
24
derived classes to implement reference counted sharing.
25
The user who should attach extensions to logical volumes
26
or nodes BEFORE applying misalignment information so that
27
these will be available to all copies.
28
*/
29
30
ClassImp
(
TGeoRCExtension
);
31
32
/** \class TGeoRCExtension
33
\ingroup Geometry_classes
34
35
Reference counted extension which has a pointer to and
36
owns a user defined TObject. This class can be used as
37
model for a reference counted derivation from TGeoExtension.
38
39
Note: Creating a TGeoRCExtension with new() automatically grabs it, but the
40
creator has to Release it before the pointer gets out of scope.
41
The following sequence is valid:
42
43
~~~ {.cpp}
44
// producer:
45
TGeoRCExtension *ext = new TGeoRCExtension();
46
some_TGeoVolume->SetUserExtension(ext);
47
ext->Release();
48
// user:
49
TGeoRCExtension *ext = dynamic_cast<TGeoRCExtension*>(some_TGeoVolume->GrabUserExtension());
50
// ... use extension
51
ext->Release();
52
~~~
53
54
The extension is going to be released by the TGeoVolume holder at the destruction
55
or when calling SetUserExtension(0).
56
57
The following usage is not correct:
58
59
~~~ {.cpp}
60
some_TGeoVolume->SetUserExtension(new TGeoRCExtension())
61
~~~
62
63
since the producer code does not release the extension.
64
One cannot call directly "delete ext" nor allocate an extension on the stack,
65
since the destructor is protected. Use Release instead.
66
*/
Rtypes.h
ClassImp
#define ClassImp(name)
Definition
Rtypes.h:364
TGeoExtension.h
TGeoExtension
ABC for user objects attached to TGeoVolume or TGeoNode.
Definition
TGeoExtension.h:20
TGeoRCExtension
Reference counted extension which has a pointer to and owns a user defined TObject.
Definition
TGeoExtension.h:37
geom
geom
src
TGeoExtension.cxx
ROOT v6-24 - Reference Guide Generated on Tue Aug 22 2023 03:06:18 (GVA Time) using Doxygen 1.9.8