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