Belle II Software light-2406-ragdoll
Mergeable Class Referenceabstract

Abstract base class for objects that can be merged. More...

#include <Mergeable.h>

Inheritance diagram for Mergeable:
Collaboration diagram for Mergeable:

Public Member Functions

virtual void merge (const Mergeable *other)=0
 Merge object 'other' into this one.
 
virtual void clear ()=0
 Clear content of this object (e.g.
 
virtual void removeSideEffects ()
 An ugly little method that is called before event() for input and worker processes.
 
virtual Long64_t Merge (TCollection *hlist)
 Allow merging using TFileMerger if saved directly to a file.
 
virtual void Reset ()
 Root-like Reset function for "template compatibility" with ROOT objects.
 
virtual void SetDirectory (TDirectory *)
 Root-like SetDirectory function for "template compatibility" with ROOT objects.
 

Private Member Functions

 ClassDef (Mergeable, 0)
 Abstract base class for objects that can be merged.
 

Detailed Description

Abstract base class for objects that can be merged.

This is mainly intended for objects of c_Persistent durability in the data store, where those inheriting from this class will be merged when using parallel processing.

For storing TH1F, TNtuple and similar things, see RootMergeable<T>. For STL maps, see MapMergeable<T>.

The special handling for these objects is performed in DataStoreStreamer.

Definition at line 31 of file Mergeable.h.

Constructor & Destructor Documentation

◆ Mergeable()

Mergeable ( )
inline

Definition at line 33 of file Mergeable.h.

33{ }

◆ ~Mergeable()

virtual ~Mergeable ( )
inlinevirtual

Definition at line 34 of file Mergeable.h.

34{ }

Member Function Documentation

◆ clear()

virtual void clear ( )
pure virtual

Clear content of this object (e.g.

set to zeroes).

Called after sending the objects to another process and after forking processes to ensure there is at most one copy of the same data. If no clearing is performed, the same data (e.g. histogram entries) might be added again and again in each event.

Implemented in MapMergeable< T >, ProcessStatistics, BackgroundInfo, BackgroundMetaData, RootMergeable< T >, and SetMergeable< T >.

◆ merge()

virtual void merge ( const Mergeable other)
pure virtual

Merge object 'other' into this one.

Your derived class must implement this function. You can static_cast 'other' to your own type (when called, this and other are guaranteed to point to objects of the same type).

Note that 'other' will be deleted after the merge, so make sure you copy all data from it that you will need.

Implemented in MapMergeable< T >, ProcessStatistics, BackgroundInfo, BackgroundMetaData, RootMergeable< T >, and SetMergeable< T >.

◆ Merge()

Long64_t Merge ( TCollection *  hlist)
virtual

Allow merging using TFileMerger if saved directly to a file.

Note
dictionaries containing your Mergeable class need to be loaded, so 'hadd' will not work currently.

Definition at line 14 of file Mergeable.cc.

15{
16 Long64_t nMerged = 0;
17 if (hlist) {
18 const Mergeable* xh = nullptr;
19 TIter nxh(hlist);
20 while ((xh = dynamic_cast<Mergeable*>(nxh()))) {
21 // Add xh to me
22 merge(xh);
23 ++nMerged;
24 }
25 }
26 return nMerged;
27}
Abstract base class for objects that can be merged.
Definition: Mergeable.h:31
virtual void merge(const Mergeable *other)=0
Merge object 'other' into this one.

◆ removeSideEffects()

virtual void removeSideEffects ( )
inlinevirtual

An ugly little method that is called before event() for input and worker processes.

Main use case is to detach any attached TFile from this object. In the output process, it can stay attached (and grow as much as it likes).

Reimplemented in RootMergeable< T >.

Definition at line 58 of file Mergeable.h.

58{}

◆ Reset()

virtual void Reset ( )
inlinevirtual

Root-like Reset function for "template compatibility" with ROOT objects.

Alias for clear().

Definition at line 66 of file Mergeable.h.

66{clear();}
virtual void clear()=0
Clear content of this object (e.g.

◆ SetDirectory()

virtual void SetDirectory ( TDirectory *  )
inlinevirtual

Root-like SetDirectory function for "template compatibility" with ROOT objects.

Does nothing.

Definition at line 68 of file Mergeable.h.

68{}

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