FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairSink.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 // -----------------------------------------------------------------------------
9 // ----- -----
10 // ----- FairSink -----
11 // ----- Created 22.12.2017 by R. Karabowicz -----
12 // ----- -----
13 // -----------------------------------------------------------------------------
14 
15 #ifndef FAIRSINK_H
16 #define FAIRSINK_H
17 
18 #include <Rtypes.h>
19 #include <TString.h>
20 #include <map> // map
21 #include <memory> // unique_ptr
22 #include <string> // string
23 #include <typeinfo> // type_info
24 
25 class TObject;
26 class TFolder;
27 class TTree;
28 
30 {
33 };
34 
35 class FairSink
36 {
37  public:
38  FairSink();
39  FairSink(const FairSink& sink);
40  virtual ~FairSink();
41 
42  virtual Bool_t InitSink() = 0;
43  virtual void Close() = 0;
44  virtual void Reset() = 0;
45 
46  virtual Sink_Type GetSinkType() = 0;
47  virtual TString GetFileName() { return ""; }
48 
49  void SetRunId(Int_t runId) { fRunId = runId; }
50  Int_t GetRunId() const { return fRunId; }
51 
52  virtual void SetOutTree(TTree* fTree) = 0;
53 
54  virtual void Fill() = 0;
55 
56  virtual Int_t Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) = 0;
57 
58  virtual void RegisterImpl(const char*, const char*, void*) = 0;
59  virtual void RegisterAny(const char* brname, const std::type_info& oi, const std::type_info& pi, void* obj) = 0;
60 
61  virtual void WriteFolder() = 0;
62  virtual bool CreatePersistentBranchesAny() = 0;
63 
64  virtual void WriteObject(TObject* f, const char*, Int_t option = 0) = 0;
65  virtual void WriteGeometry() = 0;
66 
67  virtual FairSink* CloneSink() = 0;
68 
69  protected:
71  {
72  TypeAddressPair(const std::type_info& oi, const std::type_info& pi, void* a)
73  : origtypeinfo(oi)
74  , persistenttypeinfo(pi)
75  , ptraddr(a)
76  {}
77  const std::type_info& origtypeinfo; // type_info of type addr points to
78  const std::type_info& persistenttypeinfo; // type_info of ROOT persistent branch (drops pointers)
79  void* ptraddr; // address of a pointer (pointing to origtypeinfo);
80  };
81 
82  Int_t fRunId;
83 
85  TFolder* fOutFolder;
89  std::map<std::string, std::unique_ptr<TypeAddressPair const>> fPersistentBranchesMap;
90 
91  public:
92  ClassDef(FairSink, 1);
93 };
94 
95 #endif
Sink_Type
Definition: FairSink.h:29
virtual void RegisterAny(const char *brname, const std::type_info &oi, const std::type_info &pi, void *obj)=0
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)=0
virtual bool CreatePersistentBranchesAny()=0
FairSink()
Definition: FairSink.cxx:20
virtual void WriteFolder()=0
virtual void Reset()=0
ClassDef(FairSink, 1)
const std::type_info & persistenttypeinfo
Definition: FairSink.h:78
void SetRunId(Int_t runId)
Definition: FairSink.h:49
virtual ~FairSink()
Definition: FairSink.cxx:30
virtual Sink_Type GetSinkType()=0
TypeAddressPair(const std::type_info &oi, const std::type_info &pi, void *a)
Definition: FairSink.h:72
virtual void Close()=0
Int_t fRunId
Definition: FairSink.h:82
virtual Bool_t InitSink()=0
Int_t GetRunId() const
Definition: FairSink.h:50
virtual void Fill()=0
virtual FairSink * CloneSink()=0
virtual void SetOutTree(TTree *fTree)=0
virtual void RegisterImpl(const char *, const char *, void *)=0
const std::type_info & origtypeinfo
Definition: FairSink.h:77
virtual void WriteGeometry()=0
virtual void WriteObject(TObject *f, const char *, Int_t option=0)=0
std::map< std::string, std::unique_ptr< TypeAddressPair const > > fPersistentBranchesMap
Definition: FairSink.h:89
virtual TString GetFileName()
Definition: FairSink.h:47
TFolder * fOutFolder
Definition: FairSink.h:85