Warning, /include/Geant4/tools/rroot/fac is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_rroot_fac
0005 #define tools_rroot_fac
0006
0007 #include "../sout"
0008 #include "../S_STRING"
0009
0010 #include "branch_element"
0011 #include "branch_object"
0012 #include "leaf"
0013 #include "basket"
0014 #include "tree_index"
0015 #include "stl_vector"
0016 #include "dummy"
0017 #include "obj_list"
0018 #include "vector3"
0019 #include "matrix"
0020
0021 #ifdef TOOLS_MEM
0022 #include "../mem"
0023 #endif
0024
0025 namespace tools {
0026 namespace rroot {
0027
0028 class fac : public virtual ifac {
0029 public:
0030 TOOLS_SCLASS(tools::rroot::fac)
0031 public: //ifac
0032 virtual std::ostream& out() const {return m_out;}
0033 virtual iro* create(const std::string& a_class,const args&) {
0034 //m_out << "tools::rroot::fac::create :"
0035 // << " create object of class " << a_class << "..."
0036 // << std::endl;
0037 if(a_class=="TBranch") {
0038 return new branch(m_out,*this);
0039 } else if(a_class=="TBranchElement") {
0040 return new branch_element(m_out,*this);
0041 } else if(a_class=="TBranchObject") {
0042 return new branch_object(m_out,*this);
0043
0044 } else if(a_class=="TLeafB") {
0045 return new leaf<char>(m_out,*this);
0046
0047 } else if(a_class=="TLeafS") {
0048 return new leaf<short>(m_out,*this);
0049
0050 } else if(a_class=="TLeafI") {
0051 return new leaf<int>(m_out,*this);
0052
0053 } else if(a_class=="TLeafF") {
0054 return new leaf<float>(m_out,*this);
0055
0056 } else if(a_class=="TLeafD") {
0057 return new leaf<double>(m_out,*this);
0058
0059 } else if(a_class=="TLeafO") {
0060 return new leaf<bool>(m_out,*this);
0061
0062 } else if(a_class=="TLeafC") {
0063 return new leaf_string(m_out,*this);
0064
0065 } else if(a_class=="TLeafElement") {
0066 return new leaf_element(m_out,*this);
0067
0068 } else if(a_class=="TLeafObject") {
0069 return new leaf_object(m_out,*this);
0070
0071 } else if(a_class=="TBasket") {
0072 return new basket(m_out);
0073
0074 // L.Duflot ATLAS file :
0075 } else if(a_class=="TTreeIndex") {
0076 return new tree_index();
0077
0078 } else if(a_class=="TList") {
0079 return new obj_list(*this);
0080 } else if(a_class=="TVector3") {
0081 return new vector3();
0082 } else if(a_class=="TMatrix") {
0083 return new matrix();
0084
0085 } else if(a_class=="TNamed") {
0086 return new named();
0087
0088 } else if(a_class=="vector<unsigned short>") {
0089 return new stl_vector<unsigned short>();
0090 } else if(a_class=="vector<short>") {
0091 return new stl_vector<short>();
0092 } else if(a_class=="vector<unsigned int>") {
0093 return new stl_vector<unsigned int>();
0094 } else if(a_class=="vector<int>") {
0095 return new stl_vector<int>();
0096 } else if(a_class=="vector<float>") {
0097 return new stl_vector<float>();
0098 } else if(a_class=="vector<double>") {
0099 return new stl_vector<double>();
0100
0101 } else if(a_class=="vector<unsigned long>") { //beurk
0102 return new stl_vector<uint64>(); //is it ok to map to an uint64 ?
0103
0104 } else if(a_class=="vector<string>") {
0105 return new stl_vector_string();
0106
0107 } else if(a_class=="vector<vector<unsigned short> >") {
0108 return new stl_vector_vector<unsigned short>();
0109 } else if(a_class=="vector<vector<short> >") {
0110 return new stl_vector_vector<short>();
0111 } else if(a_class=="vector<vector<unsigned int> >") {
0112 return new stl_vector_vector<unsigned int>();
0113 } else if(a_class=="vector<vector<int> >") {
0114 return new stl_vector_vector<int>();
0115 } else if(a_class=="vector<vector<float> >") {
0116 return new stl_vector_vector<float>();
0117 } else if(a_class=="vector<vector<double> >") {
0118 return new stl_vector_vector<double>();
0119
0120 } else if(a_class=="TBranchRef") {
0121 return new dummy();
0122
0123 } else {
0124 m_out << "tools::rroot::fac::create :"
0125 << " unknown class " << sout(a_class) << "."
0126 << " Create a tools::rroot::dummy object."
0127 << std::endl;
0128 return new dummy();
0129 }
0130 }
0131 public:
0132 fac(std::ostream& a_out):m_out(a_out){
0133 #ifdef TOOLS_MEM
0134 mem::increment(s_class().c_str());
0135 #endif
0136 }
0137 virtual ~fac(){
0138 #ifdef TOOLS_MEM
0139 mem::decrement(s_class().c_str());
0140 #endif
0141 }
0142 public:
0143 fac(const fac& a_from):ifac(a_from),m_out(a_from.m_out){
0144 #ifdef TOOLS_MEM
0145 mem::increment(s_class().c_str());
0146 #endif
0147 }
0148 fac& operator=(const fac&){return *this;}
0149 protected:
0150 /*
0151 branch* arg_branch(const args& a_args) {
0152 void* p = ifac::find_args(a_args,ifac::arg_branch());
0153 if(!p) {
0154 m_out << "tools::rroot::fac::arg_branch :"
0155 << " branch not found in args."
0156 << std::endl;
0157 return 0;
0158 }
0159 return (branch*)p;
0160 }
0161 */
0162 protected:
0163 std::ostream& m_out;
0164 };
0165
0166 }}
0167
0168 #endif