ATLAS Offline Software
Public Member Functions | Private Types | Private Attributes | List of all members
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. More...
 
StatusCode init (TBranch *br, char *defval, size_t defsize)
 Initialize for clearing a variable. More...
 
void clear ()
 Clear the variable. More...
 
void free ()
 Free allocated memory. More...
 

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. More...
 
TBranchElement * m_bre
 The branch element for this variable, Used for COLLECTION, CLEAR, RESET. More...
 
TVirtualCollectionProxy * m_proxy
 The collection proxy for this variable. Used for COLLECTION. More...
 
TMethodCall m_meth
 The clear method for this variable. Used for CLEAR. More...
 
char * m_default
 Default value for COPY. We own this. More...
 
size_t m_defsize
 Default value size for COPY. More...
 

Detailed Description

Hold information on how to clear one variable.

Definition at line 135 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 172 of file RootD3PD.cxx.

Constructor & Destructor Documentation

◆ Clearinfo()

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

Constructor.

Default constructor.

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

Definition at line 212 of file RootD3PD.cxx.

213 {
214 }
215 
216 

Member Function Documentation

◆ clear()

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

Clear the variable.

Clear this variable.

Definition at line 307 of file RootD3PD.cxx.

310  :
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 }
342 
343 
346 void Clearinfo::free()
347 {

◆ 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 352 of file RootD3PD.cxx.

356 {

◆ 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 233 of file RootD3PD.cxx.

239  {
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.
256  m_type = 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 }
296 
297 
301 void Clearinfo::clear()

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 197 of file RootD3PD.cxx.

◆ m_default

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

Default value for COPY. We own this.

Definition at line 206 of file RootD3PD.cxx.

◆ m_defsize

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

Default value size for COPY.

Definition at line 209 of file RootD3PD.cxx.

◆ m_leaf

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

The leaf for this variable. Used for ZERO.

Definition at line 194 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 203 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 200 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:
D3PD::Root::Clearinfo::m_defsize
size_t m_defsize
Default value size for COPY.
Definition: RootD3PD.cxx:209
D3PD::Root::Clearinfo::free
void free()
Free allocated memory.
Definition: RootD3PD.cxx:352
D3PD::Root::Clearinfo::m_meth
TMethodCall m_meth
The clear method for this variable. Used for CLEAR.
Definition: RootD3PD.cxx:203
D3PD::Root::Clearinfo::m_bre
TBranchElement * m_bre
The branch element for this variable, Used for COLLECTION, CLEAR, RESET.
Definition: RootD3PD.cxx:197
D3PD::Root::Clearinfo::m_type
enum D3PD::Root::Clearinfo::Cleartype m_type
D3PD::Root::Clearinfo::COPY
@ COPY
Copy from a default (only for basic types).
Definition: RootD3PD.cxx:189
D3PD::Root::Clearinfo::m_proxy
TVirtualCollectionProxy * m_proxy
The collection proxy for this variable. Used for COLLECTION.
Definition: RootD3PD.cxx:200
D3PD::Root::Clearinfo::CLEAR
@ CLEAR
Clear variable by calling clear().
Definition: RootD3PD.cxx:183
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:365
D3PD::Root::Clearinfo::ZERO
@ ZERO
Clear variable by filling with zeros.
Definition: RootD3PD.cxx:177
D3PD::Root::Clearinfo::clear
void clear()
Clear the variable.
Definition: RootD3PD.cxx:307
D3PD::Root::Clearinfo::COLLECTION
@ COLLECTION
Clear variable via collection proxy.
Definition: RootD3PD.cxx:180
D3PD::Root::Clearinfo::m_leaf
TLeaf * m_leaf
The leaf for this variable. Used for ZERO.
Definition: RootD3PD.cxx:194
D3PD::Root::Clearinfo::m_default
char * m_default
Default value for COPY. We own this.
Definition: RootD3PD.cxx:206
python.PyAthena.obj
obj
Definition: PyAthena.py:132
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
D3PD::Root::Clearinfo::RESET
@ RESET
Clear variable by deleting and recreating.
Definition: RootD3PD.cxx:186
PlotCalibFromCool.br
br
Definition: PlotCalibFromCool.py:355