g4tools  5.4.0
streamer_fac
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_rroot_streamer_fac
5 #define tools_rroot_streamer_fac
6 
7 #include "info"
8 #include "iros"
9 
10 namespace tools {
11 namespace rroot {
12 
13 class streamer_fac : public virtual ifac {
14 public: //ifac
15  virtual std::ostream& out() const {return m_out;}
16  virtual iro* create(const std::string& a_class,const args& a_args) {
17  // for read_sinfos() :
18  if(rcmp(a_class,"TStreamerInfo")) {
19  return new streamer_info(*this);
20  } else if(rcmp(a_class,"TObjArray")) {
21  std::string* sc = ifac::arg_class(a_args);
22  if(sc) {
23  if((*sc)==streamer_element::s_class()){
24  return new obj_array<streamer_element>(*this);
25  } else {
26  m_out << "tools::rroot::streamer_fac::create :"
27  << " Can't create TObjArray of " << *sc << "."
28  << std::endl;
29  return 0;
30  }
31  } else {
32  return new iros(*this);
33  }
34  } else if(rcmp(a_class,"TStreamerBase")
35  ||rcmp(a_class,"TStreamerBasicType")
36  ||rcmp(a_class,"TStreamerBasicPointer")
37  ||rcmp(a_class,"TStreamerObjectAny")
38  ||rcmp(a_class,"TStreamerObject")
39  ||rcmp(a_class,"TStreamerObjectPointer")
40  ||rcmp(a_class,"TStreamerString")
41  ||rcmp(a_class,"TStreamerSTL")
42  ||rcmp(a_class,"TStreamerLoop")
43  ||rcmp(a_class,"TList")
44  ) {
45  return new dummy_streamer_element();
46 
47  } else {
48  m_out << "tools::rroot::streamer_fac::create :"
49  << " dummy. Can't create object of class " << sout(a_class) << "."
50  << std::endl;
51  }
52  return 0;
53  }
54 public:
55  streamer_fac(std::ostream& a_out):m_out(a_out){}
56  virtual ~streamer_fac(){}
57 protected:
58  streamer_fac(const streamer_fac& a_from): ifac(a_from),m_out(a_from.m_out){}
59  streamer_fac& operator=(const streamer_fac&){return *this;}
60 protected:
61  std::ostream& m_out;
62 };
63 
64 }}
65 
66 #endif
tools::rroot::streamer_info
Definition: info:153
tools::rroot::streamer_fac::create
virtual iro * create(const std::string &a_class, const args &a_args)
Definition: streamer_fac:16
iros
tools::rroot::streamer_element::s_class
static const std::string & s_class()
Definition: info:22
tools::rroot::streamer_fac::m_out
std::ostream & m_out
Definition: streamer_fac:61
tools::rroot::streamer_fac::out
virtual std::ostream & out() const
Definition: streamer_fac:15
tools::rroot::streamer_fac::streamer_fac
streamer_fac(std::ostream &a_out)
Definition: streamer_fac:55
tools::sout
Definition: sout:17
tools::rroot::dummy_streamer_element
Definition: info:125
tools::rroot::streamer_fac::streamer_fac
streamer_fac(const streamer_fac &a_from)
Definition: streamer_fac:58
tools::rroot::streamer_fac::~streamer_fac
virtual ~streamer_fac()
Definition: streamer_fac:56
tools::rcmp
bool rcmp(const char *a_1, const char *a_2)
Definition: rcmp:14
tools::rroot::streamer_fac
Definition: streamer_fac:13
tools::rroot::iros
Definition: iros:17
tools::rroot::ifac
Definition: ifac:19
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
info
tools::rroot::ifac::arg_class
static char arg_class()
Definition: ifac:34
tools::rroot::iro
Definition: iro:19
tools::rroot::ifac::args
std::map< char, void * > args
Definition: ifac:21
tools::rroot::streamer_fac::operator=
streamer_fac & operator=(const streamer_fac &)
Definition: streamer_fac:59
tools::rroot::obj_array
Definition: obj_array:17