Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TVirtualStreamerInfo.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Rene Brun 05/02/2007
3/*************************************************************************
4 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11/** \class TVirtualStreamerInfo
12Abstract Interface class describing Streamer information for one class.
13*/
14
15#include "TROOT.h"
16#include "TSystem.h"
17#include "TClass.h"
18#include "TVirtualMutex.h"
19#include "TInterpreter.h"
21#include "TPluginManager.h"
22#include "TStreamerElement.h"
23#include "TError.h"
24#include "TObjArray.h"
25
27
31
32
33////////////////////////////////////////////////////////////////////////////////
34/// Default constructor.
35
36TVirtualStreamerInfo::TVirtualStreamerInfo() : fOptimized(kFALSE), fIsBuilt(kFALSE), fIsCompiled(kFALSE)
37{
38}
39
40////////////////////////////////////////////////////////////////////////////////
41/// Default constructor.
42
44 : TNamed(cl->GetName(),""), fOptimized(kFALSE), fIsBuilt(kFALSE), fIsCompiled(kFALSE)
45{
46}
47
48////////////////////////////////////////////////////////////////////////////////
49///copy constructor
50
52 : TNamed(info), fOptimized(kFALSE), fIsBuilt(kFALSE), fIsCompiled(kFALSE)
53{
54}
55
56////////////////////////////////////////////////////////////////////////////////
57///assignment operator
58
66
67////////////////////////////////////////////////////////////////////////////////
68/// Destructor
69
73
74////////////////////////////////////////////////////////////////////////////////
75/// static function returning true if ReadBuffer can delete object
76
81
82////////////////////////////////////////////////////////////////////////////////
83/// static function returning true if optimization can be on
84
89
90////////////////////////////////////////////////////////////////////////////////
91/// Given a comment/title declaring an array counter, for example:
92/// ~~~ {.cpp}
93/// //[fArraySize] array of size fArraySize
94/// ~~~
95/// return the start of the array dimension declaration start in the string
96/// (so the location of the 'f'.
97
99{
100 for (const char *lbracket = dmTitle; *lbracket; ++lbracket) {
101 // = ::strchr(dmTitle, '[');
102 if ( (*lbracket) == '[' ) return lbracket;
103 if ( (*lbracket) != '/' && !isspace(*lbracket) ) {
104 // Allow only comment delimiters and white spaces
105 // before the array information.
106 return nullptr;
107 }
108 }
109 return nullptr;
110}
111
112////////////////////////////////////////////////////////////////////////////////
113/// Get pointer to a TStreamerBasicType in TClass *cl
114///static function
115
117{
119 {
121 const TObjArray *sinfos = cl->GetStreamerInfos();
123 }
124
125 if (!info || !info->IsCompiled()) {
126 // Even if the streamerInfo exist, it could still need to be 'build'
127 // It is important to figure this out, because
128 // a) if it is not build, we need to build
129 // b) if is build, we should not build it (or we could end up in an
130 // infinite loop, if the element and its counter are in the same
131 // class!
132 // Checking IsCompiled is sufficient here even-though it is set only at
133 // the end of the call to Build as this function has an
134 // internal recursion prevention (setting and testing kBuildRunning).
135 info = cl->GetStreamerInfo();
136 }
137 if (!info) return nullptr;
138 TStreamerElement *element = (TStreamerElement *)info->GetElements()->FindObject(countName);
139 if (!element) return nullptr;
141 return nullptr;
142}
143
144////////////////////////////////////////////////////////////////////////////////
145/// Return whether the TStreamerInfos will save the collections in
146/// "member-wise" order whenever possible. The default is to store member-wise.
147/// - kTRUE indicates member-wise storing
148/// - kFALSE inddicates object-wise storing
149///
150/// A collection can be saved member wise when it contain is guaranteed to be
151/// homogeneous. For example std::vector<THit> can be stored member wise,
152/// while std::vector<THit*> can not (possible use of polymorphism).
153
158
159////////////////////////////////////////////////////////////////////////////////
160/// This is a static function.
161/// Set optimization option.
162/// When this option is activated (default), consecutive data members
163/// of the same type are merged into an array (faster).
164/// Optimization must be off in TTree split mode.
165
167{
168 fgOptimize = opt;
169}
170
171////////////////////////////////////////////////////////////////////////////////
172/// Static function returning a pointer to a new TVirtualStreamerInfo object.
173/// If the Info factory does not exist, it is created via the plugin manager.
174/// In reality the factory is an empty TStreamerInfo object.
175
177{
178 if (!fgInfoFactory) {
181 if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualStreamerInfo","TStreamerInfo"))) {
182 if (h->LoadPlugin() == -1) {
183 ::Fatal("TVirtualStreamerInfo::Factory",
184 "The plugin handler for TVirtualStreamerInfo was found but failed to load!");
185 }
186 fgInfoFactory = (TVirtualStreamerInfo*) h->ExecPlugin(0);
187 if (fgInfoFactory == nullptr) {
188 ::Fatal("TVirtualStreamerInfo::Factory",
189 "The plugin handler for TVirtualStreamerInfo was found but failed to create the factory object!");
190 }
191 } else {
192 TString filename("$ROOTSYS/etc/plugins/TVirtualStreamerInfo");
195 ::Fatal("TVirtualStreamerInfo::Factory",
196 "Cannot find the plugin handler for TVirtualStreamerInfo! "
197 "$ROOTSYS/etc/plugins/TVirtualStreamerInfo does not exist "
198 "or is inaccessible.");
199 } else {
200 ::Fatal("TVirtualStreamerInfo::Factory",
201 "Cannot find the plugin handler for TVirtualStreamerInfo! "
202 "However $ROOTSYS/etc/plugins/TVirtualStreamerInfo is accessible, "
203 "Check the content of this directory!");
204 }
205 }
206 }
207
208 return fgInfoFactory;
209}
210
211////////////////////////////////////////////////////////////////////////////////
212/// This is a static function.
213/// Set object delete option.
214/// When this option is activated (default), ReadBuffer automatically
215/// delete objects when a data member is a pointer to an object.
216/// If your constructor is not presetting pointers to 0, you must
217/// call this static function TStreamerInfo::SetCanDelete(kFALSE);
218
223
224////////////////////////////////////////////////////////////////////////////////
225///static function: Set the StreamerInfo factory
226
228{
230 auto old = fgInfoFactory;
231 fgInfoFactory = factory;
232 if (old) delete old;
233}
234
235////////////////////////////////////////////////////////////////////////////////
236/// Set whether the TStreamerInfos will save the collections in
237/// "member-wise" order whenever possible. The default is to store member-wise.
238/// - kTRUE indicates member-wise storing
239/// - kFALSE indicates object-wise storing
240/// This function returns the previous value of fgStreamMemberWise.
241
243{
244 // A collection can be saved member wise when it contain is guaranteed to be
245 // homogeneous. For example std::vector<THit> can be stored member wise,
246 // while std::vector<THit*> can not (possible use of polymorphism).
247
250 return prev;
251}
252
253////////////////////////////////////////////////////////////////////////////////
254/// Stream an object of class TVirtualStreamerInfo.
255
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
R__EXTERN TVirtualMutex * gInterpreterMutex
#define gROOT
Definition TROOT.h:411
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define R__LOCKGUARD(mutex)
Buffer base class used for serializing objects.
Definition TBuffer.h:43
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
const TObjArray * GetStreamerInfos() const
Definition TClass.h:505
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0, Bool_t isTransient=kFALSE) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
Definition TClass.cxx:4626
Version_t GetClassVersion() const
Definition TClass.h:432
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
void Streamer(TBuffer &) override
Stream an object of class TObject.
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition TNamed.cxx:50
An array of TObjects.
Definition TObjArray.h:31
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1099
static TClass * Class()
Describe one element (data member) to be Streamed.
Basic string class.
Definition TString.h:138
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1285
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1307
Abstract Interface class describing Streamer information for one class.
static Bool_t GetStreamMemberWise()
Return whether the TStreamerInfos will save the collections in "member-wise" order whenever possible.
void Streamer(TBuffer &) override
Stream an object of class TVirtualStreamerInfo.
static void SetFactory(TVirtualStreamerInfo *factory)
static function: Set the StreamerInfo factory
TVirtualStreamerInfo()
Default constructor.
static const char * GetElementCounterStart(const char *dmTitle)
Given a comment/title declaring an array counter, for example:
static TVirtualStreamerInfo * fgInfoFactory
static Bool_t fgCanDelete
true if the StreamerInfo has been compiled (i.e. fully built, ready to use for streaming).
static Bool_t SetStreamMemberWise(Bool_t enable=kTRUE)
Set whether the TStreamerInfos will save the collections in "member-wise" order whenever possible.
static Bool_t CanOptimize()
static function returning true if optimization can be on
static TStreamerBasicType * GetElementCounter(const char *countName, TClass *cl)
Get pointer to a TStreamerBasicType in TClass *cl static function.
static void SetCanDelete(Bool_t opt=kTRUE)
This is a static function.
static Bool_t CanDelete()
static function returning true if ReadBuffer can delete object
static TVirtualStreamerInfo * Factory()
Static function returning a pointer to a new TVirtualStreamerInfo object.
TVirtualStreamerInfo & operator=(const TVirtualStreamerInfo &)
assignment operator
virtual ~TVirtualStreamerInfo()
Destructor.
static void Optimize(Bool_t opt=kTRUE)
This is a static function.