ATLAS Offline Software
Loading...
Searching...
No Matches
D3PD::Root::Clearinfo Class Reference

Hold information on how to clear one variable. More...

Collaboration diagram for D3PD::Root::Clearinfo:

Public Member Functions

 Clearinfo ()
 Constructor.
StatusCode init (TBranch *br, char *defval, size_t defsize)
 Initialize for clearing a variable.
void clear ()
 Clear the variable.
void free ()
 Free allocated memory.

Private Types

enum  Cleartype {
  INVALID , ZERO , COLLECTION , CLEAR ,
  RESET , COPY
}
 The method to use to clear this variable. More...

Private Attributes

enum D3PD::Root::Clearinfo::Cleartype m_type
TLeaf * m_leaf
 The leaf for this variable. Used for ZERO.
TBranchElement * m_bre
 The branch element for this variable, Used for COLLECTION, CLEAR, RESET.
TVirtualCollectionProxy * m_proxy
 The collection proxy for this variable. Used for COLLECTION.
TMethodCall m_meth
 The clear method for this variable. Used for CLEAR.
char * m_default
 Default value for COPY. We own this.
size_t m_defsize
 Default value size for COPY.

Detailed Description

Hold information on how to clear one variable.

Definition at line 129 of file RootD3PD.cxx.

Member Enumeration Documentation

◆ Cleartype

The method to use to clear this variable.

Enumerator
INVALID 

Not set yet.

ZERO 

Clear variable by filling with zeros.

COLLECTION 

Clear variable via collection proxy.

CLEAR 

Clear variable by calling clear().

RESET 

Clear variable by deleting and recreating.

COPY 

Copy from a default (only for basic types).

Definition at line 160 of file RootD3PD.cxx.

160 {
162 INVALID,
163
165 ZERO,
166
169
171 CLEAR,
172
174 RESET,
175
177 COPY
178 }
@ CLEAR
Clear variable by calling clear().
Definition RootD3PD.cxx:171
@ COLLECTION
Clear variable via collection proxy.
Definition RootD3PD.cxx:168
@ COPY
Copy from a default (only for basic types).
Definition RootD3PD.cxx:177
@ INVALID
Not set yet.
Definition RootD3PD.cxx:162
@ ZERO
Clear variable by filling with zeros.
Definition RootD3PD.cxx:165
@ RESET
Clear variable by deleting and recreating.
Definition RootD3PD.cxx:174

Constructor & Destructor Documentation

◆ Clearinfo()

D3PD::Root::Clearinfo::Clearinfo ( )

Constructor.

Default constructor.

You must call init() before this object is usable.

Definition at line 206 of file RootD3PD.cxx.

207 : m_type (INVALID),
208 m_leaf (0),
209 m_bre (0),
210 m_proxy (0),
211 m_default (0),
212 m_defsize (0)
213{
214}
enum D3PD::Root::Clearinfo::Cleartype m_type
TVirtualCollectionProxy * m_proxy
The collection proxy for this variable. Used for COLLECTION.
Definition RootD3PD.cxx:188
TBranchElement * m_bre
The branch element for this variable, Used for COLLECTION, CLEAR, RESET.
Definition RootD3PD.cxx:185
size_t m_defsize
Default value size for COPY.
Definition RootD3PD.cxx:197
char * m_default
Default value for COPY. We own this.
Definition RootD3PD.cxx:194
TLeaf * m_leaf
The leaf for this variable. Used for ZERO.
Definition RootD3PD.cxx:182

Member Function Documentation

◆ clear()

void D3PD::Root::Clearinfo::clear ( )

Clear the variable.

Clear this variable.

Definition at line 301 of file RootD3PD.cxx.

302{
303 switch (m_type) {
304 case ZERO:
305 // Fill with zeros.
306 std::memset (m_leaf->GetValuePointer(), 0,
307 m_leaf->GetLen() * m_leaf->GetLenType());
308 break;
309
310 case COLLECTION:
311 // Clear via collection proxy.
312 {
313 void* obj = m_bre->GetObject();
314 TVirtualCollectionProxy::TPushPop pushcont(m_proxy, obj);
315 m_proxy->Clear();
316 break;
317 }
318
319 case CLEAR:
320 // Clear by calling @c clear().
321 {
322 void* obj = m_bre->GetObject();
323 m_meth.Execute (obj);
324 break;
325 }
326
327 case RESET:
328 // Free and reallocate object.
329 m_bre->SetAddress(0);
330 break;
331
332 case COPY:
333 // Copy from default.
334 std::memcpy (m_leaf->GetValuePointer(), m_default, m_defsize);
335 break;
336
337 default:
338 std::abort();
339
340 }
341}
TMethodCall m_meth
The clear method for this variable. Used for CLEAR.
Definition RootD3PD.cxx:191

◆ free()

void D3PD::Root::Clearinfo::free ( )

Free allocated memory.

(Not done in the destructor to make it easier to hold these in a vector.)

Definition at line 346 of file RootD3PD.cxx.

347{
348 delete [] m_default;
349}

◆ init()

StatusCode D3PD::Root::Clearinfo::init ( TBranch * br,
char * defval,
size_t defsize )

Initialize for clearing a variable.

Parameters
brThe branch containing the variable.
defvalPointer to the default value to use for this variable. Null for no default (generally means to fill with zeros). Of the type given by ti. Only works for basic types. We take ownership of this.
defsizeSize of the object pointed at by defval.

Definition at line 227 of file RootD3PD.cxx.

228{
229 if (typeid (*br) == typeid (TBranch)) {
230 // Atomic type
231 TLeaf* leaf = br->GetLeaf (br->GetName());
232 if (!leaf) {
233 REPORT_MESSAGE (MSG::ERROR) << "For tree " << br->GetTree()->GetName()
234 << " can't find leaf for branch "
235 << br->GetName();
236 return StatusCode::FAILURE;
237 }
238
239 if (defval) {
240 m_type = COPY;
241 m_default = defval;
242 m_defsize = defsize;
243 }
244 else
245 m_type = ZERO;
246
247 m_leaf = leaf;
248 }
249
250 else if (TBranchElement* bre = dynamic_cast<TBranchElement*> (br)) {
251 assert (defval == 0);
252
253 // Class type. See if it seems to be a container.
254 if (TVirtualCollectionProxy* collprox = bre->GetCollectionProxy()) {
255 // A collection.
257 m_bre = bre;
258 m_proxy = collprox;
259 }
260 else {
261 // See if the class has a clear() method.
262 TClass* cl = gROOT->GetClass (bre->GetClassName());
263 if (!cl) {
264 REPORT_MESSAGE (MSG::ERROR) << "For tree " << br->GetTree()->GetName()
265 << " branch " << br->GetName()
266 << " can't find class "
267 << bre->GetClassName();
268 return StatusCode::FAILURE;
269 }
270
271 TMethodCall meth (cl, "clear", "");
272 if (meth.IsValid()) {
273 // There's a @c clear() method. Use that.
274 m_type = CLEAR;
275 m_bre = bre;
276 m_meth = meth;
277 }
278 else {
279 // Free and reallocate object.
280 m_type = RESET;
281 m_bre = bre;
282 }
283 }
284 }
285 else {
286 // Someone else must have made this?
287 REPORT_MESSAGE (MSG::ERROR) << "For tree " << br->GetTree()->GetName()
288 << " branch " << br->GetName()
289 << " has unknown type "
290 << typeid(*br).name();
291 return StatusCode::FAILURE;
292 }
293
294 return StatusCode::SUCCESS;
295}
#define REPORT_MESSAGE(LVL)
Report a message.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]

Member Data Documentation

◆ m_bre

TBranchElement* D3PD::Root::Clearinfo::m_bre
private

The branch element for this variable, Used for COLLECTION, CLEAR, RESET.

Definition at line 185 of file RootD3PD.cxx.

◆ m_default

char* D3PD::Root::Clearinfo::m_default
private

Default value for COPY. We own this.

Definition at line 194 of file RootD3PD.cxx.

◆ m_defsize

size_t D3PD::Root::Clearinfo::m_defsize
private

Default value size for COPY.

Definition at line 197 of file RootD3PD.cxx.

◆ m_leaf

TLeaf* D3PD::Root::Clearinfo::m_leaf
private

The leaf for this variable. Used for ZERO.

Definition at line 182 of file RootD3PD.cxx.

◆ m_meth

TMethodCall D3PD::Root::Clearinfo::m_meth
private

The clear method for this variable. Used for CLEAR.

Definition at line 191 of file RootD3PD.cxx.

◆ m_proxy

TVirtualCollectionProxy* D3PD::Root::Clearinfo::m_proxy
private

The collection proxy for this variable. Used for COLLECTION.

Definition at line 188 of file RootD3PD.cxx.

◆ m_type

enum D3PD::Root::Clearinfo::Cleartype D3PD::Root::Clearinfo::m_type
private

The documentation for this class was generated from the following file: