Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef tools_rroot_fac 4 #ifndef tools_rroot_fac 5 #define tools_rroot_fac 5 #define tools_rroot_fac 6 6 7 #include "../sout" 7 #include "../sout" 8 #include "../S_STRING" 8 #include "../S_STRING" 9 9 10 #include "branch_element" 10 #include "branch_element" 11 #include "branch_object" 11 #include "branch_object" 12 #include "leaf" 12 #include "leaf" 13 #include "basket" 13 #include "basket" 14 #include "tree_index" 14 #include "tree_index" 15 #include "stl_vector" 15 #include "stl_vector" 16 #include "dummy" 16 #include "dummy" 17 #include "obj_list" 17 #include "obj_list" 18 #include "vector3" 18 #include "vector3" 19 #include "matrix" 19 #include "matrix" 20 20 21 #ifdef TOOLS_MEM 21 #ifdef TOOLS_MEM 22 #include "../mem" 22 #include "../mem" 23 #endif 23 #endif 24 24 25 namespace tools { 25 namespace tools { 26 namespace rroot { 26 namespace rroot { 27 27 28 class fac : public virtual ifac { 28 class fac : public virtual ifac { 29 public: 29 public: 30 TOOLS_SCLASS(tools::rroot::fac) 30 TOOLS_SCLASS(tools::rroot::fac) 31 public: //ifac 31 public: //ifac 32 virtual std::ostream& out() const {return m_ 32 virtual std::ostream& out() const {return m_out;} 33 virtual iro* create(const std::string& a_cla 33 virtual iro* create(const std::string& a_class,const args&) { 34 //m_out << "tools::rroot::fac::create :" 34 //m_out << "tools::rroot::fac::create :" 35 // << " create object of class " << a 35 // << " create object of class " << a_class << "..." 36 // << std::endl; 36 // << std::endl; 37 if(a_class=="TBranch") { 37 if(a_class=="TBranch") { 38 return new branch(m_out,*this); 38 return new branch(m_out,*this); 39 } else if(a_class=="TBranchElement") { 39 } else if(a_class=="TBranchElement") { 40 return new branch_element(m_out,*this); 40 return new branch_element(m_out,*this); 41 } else if(a_class=="TBranchObject") { 41 } else if(a_class=="TBranchObject") { 42 return new branch_object(m_out,*this); 42 return new branch_object(m_out,*this); 43 43 44 } else if(a_class=="TLeafB") { 44 } else if(a_class=="TLeafB") { 45 return new leaf<char>(m_out,*this); 45 return new leaf<char>(m_out,*this); 46 46 47 } else if(a_class=="TLeafS") { 47 } else if(a_class=="TLeafS") { 48 return new leaf<short>(m_out,*this); 48 return new leaf<short>(m_out,*this); 49 49 50 } else if(a_class=="TLeafI") { 50 } else if(a_class=="TLeafI") { 51 return new leaf<int>(m_out,*this); 51 return new leaf<int>(m_out,*this); 52 52 53 } else if(a_class=="TLeafF") { 53 } else if(a_class=="TLeafF") { 54 return new leaf<float>(m_out,*this); 54 return new leaf<float>(m_out,*this); 55 55 56 } else if(a_class=="TLeafD") { 56 } else if(a_class=="TLeafD") { 57 return new leaf<double>(m_out,*this); 57 return new leaf<double>(m_out,*this); 58 58 59 } else if(a_class=="TLeafO") { 59 } else if(a_class=="TLeafO") { 60 return new leaf<bool>(m_out,*this); 60 return new leaf<bool>(m_out,*this); 61 61 62 } else if(a_class=="TLeafC") { 62 } else if(a_class=="TLeafC") { 63 return new leaf_string(m_out,*this); 63 return new leaf_string(m_out,*this); 64 64 65 } else if(a_class=="TLeafElement") { 65 } else if(a_class=="TLeafElement") { 66 return new leaf_element(m_out,*this); 66 return new leaf_element(m_out,*this); 67 67 68 } else if(a_class=="TLeafObject") { 68 } else if(a_class=="TLeafObject") { 69 return new leaf_object(m_out,*this); 69 return new leaf_object(m_out,*this); 70 70 71 } else if(a_class=="TBasket") { 71 } else if(a_class=="TBasket") { 72 return new basket(m_out); 72 return new basket(m_out); 73 73 74 // L.Duflot ATLAS file : 74 // L.Duflot ATLAS file : 75 } else if(a_class=="TTreeIndex") { 75 } else if(a_class=="TTreeIndex") { 76 return new tree_index(); 76 return new tree_index(); 77 77 78 } else if(a_class=="TList") { 78 } else if(a_class=="TList") { 79 return new obj_list(*this); 79 return new obj_list(*this); 80 } else if(a_class=="TVector3") { 80 } else if(a_class=="TVector3") { 81 return new vector3(); 81 return new vector3(); 82 } else if(a_class=="TMatrix") { 82 } else if(a_class=="TMatrix") { 83 return new matrix(); 83 return new matrix(); 84 84 85 } else if(a_class=="TNamed") { 85 } else if(a_class=="TNamed") { 86 return new named(); 86 return new named(); 87 87 88 } else if(a_class=="vector<unsigned short> 88 } else if(a_class=="vector<unsigned short>") { 89 return new stl_vector<unsigned short>(); 89 return new stl_vector<unsigned short>(); 90 } else if(a_class=="vector<short>") { 90 } else if(a_class=="vector<short>") { 91 return new stl_vector<short>(); 91 return new stl_vector<short>(); 92 } else if(a_class=="vector<unsigned int>") 92 } else if(a_class=="vector<unsigned int>") { 93 return new stl_vector<unsigned int>(); 93 return new stl_vector<unsigned int>(); 94 } else if(a_class=="vector<int>") { 94 } else if(a_class=="vector<int>") { 95 return new stl_vector<int>(); 95 return new stl_vector<int>(); 96 } else if(a_class=="vector<float>") { 96 } else if(a_class=="vector<float>") { 97 return new stl_vector<float>(); 97 return new stl_vector<float>(); 98 } else if(a_class=="vector<double>") { 98 } else if(a_class=="vector<double>") { 99 return new stl_vector<double>(); 99 return new stl_vector<double>(); 100 100 101 } else if(a_class=="vector<unsigned long>" 101 } else if(a_class=="vector<unsigned long>") { //beurk 102 return new stl_vector<uint64>(); //is it 102 return new stl_vector<uint64>(); //is it ok to map to an uint64 ? 103 103 104 } else if(a_class=="vector<string>") { 104 } else if(a_class=="vector<string>") { 105 return new stl_vector_string(); 105 return new stl_vector_string(); 106 106 107 } else if(a_class=="vector<vector<unsigned 107 } else if(a_class=="vector<vector<unsigned short> >") { 108 return new stl_vector_vector<unsigned sh 108 return new stl_vector_vector<unsigned short>(); 109 } else if(a_class=="vector<vector<short> > 109 } else if(a_class=="vector<vector<short> >") { 110 return new stl_vector_vector<short>(); 110 return new stl_vector_vector<short>(); 111 } else if(a_class=="vector<vector<unsigned 111 } else if(a_class=="vector<vector<unsigned int> >") { 112 return new stl_vector_vector<unsigned in 112 return new stl_vector_vector<unsigned int>(); 113 } else if(a_class=="vector<vector<int> >") 113 } else if(a_class=="vector<vector<int> >") { 114 return new stl_vector_vector<int>(); 114 return new stl_vector_vector<int>(); 115 } else if(a_class=="vector<vector<float> > 115 } else if(a_class=="vector<vector<float> >") { 116 return new stl_vector_vector<float>(); 116 return new stl_vector_vector<float>(); 117 } else if(a_class=="vector<vector<double> 117 } else if(a_class=="vector<vector<double> >") { 118 return new stl_vector_vector<double>(); 118 return new stl_vector_vector<double>(); 119 119 120 } else if(a_class=="TBranchRef") { 120 } else if(a_class=="TBranchRef") { 121 return new dummy(); 121 return new dummy(); 122 122 123 } else { 123 } else { 124 m_out << "tools::rroot::fac::create :" 124 m_out << "tools::rroot::fac::create :" 125 << " unknown class " << sou 125 << " unknown class " << sout(a_class) << "." 126 << " Create a tools::rroot: 126 << " Create a tools::rroot::dummy object." 127 << std::endl; 127 << std::endl; 128 return new dummy(); 128 return new dummy(); 129 } 129 } 130 } 130 } 131 public: 131 public: 132 fac(std::ostream& a_out):m_out(a_out){ 132 fac(std::ostream& a_out):m_out(a_out){ 133 #ifdef TOOLS_MEM 133 #ifdef TOOLS_MEM 134 mem::increment(s_class().c_str()); 134 mem::increment(s_class().c_str()); 135 #endif 135 #endif 136 } 136 } 137 virtual ~fac(){ 137 virtual ~fac(){ 138 #ifdef TOOLS_MEM 138 #ifdef TOOLS_MEM 139 mem::decrement(s_class().c_str()); 139 mem::decrement(s_class().c_str()); 140 #endif 140 #endif 141 } 141 } 142 public: 142 public: 143 fac(const fac& a_from):ifac(a_from),m_out(a_ 143 fac(const fac& a_from):ifac(a_from),m_out(a_from.m_out){ 144 #ifdef TOOLS_MEM 144 #ifdef TOOLS_MEM 145 mem::increment(s_class().c_str()); 145 mem::increment(s_class().c_str()); 146 #endif 146 #endif 147 } 147 } 148 fac& operator=(const fac&){return *this;} 148 fac& operator=(const fac&){return *this;} 149 protected: 149 protected: 150 /* 150 /* 151 branch* arg_branch(const args& a_args) { 151 branch* arg_branch(const args& a_args) { 152 void* p = ifac::find_args(a_args,ifac::arg 152 void* p = ifac::find_args(a_args,ifac::arg_branch()); 153 if(!p) { 153 if(!p) { 154 m_out << "tools::rroot::fac::arg_branch 154 m_out << "tools::rroot::fac::arg_branch :" 155 << " branch not found in ar 155 << " branch not found in args." 156 << std::endl; 156 << std::endl; 157 return 0; 157 return 0; 158 } 158 } 159 return (branch*)p; 159 return (branch*)p; 160 } 160 } 161 */ 161 */ 162 protected: 162 protected: 163 std::ostream& m_out; 163 std::ostream& m_out; 164 }; 164 }; 165 165 166 }} 166 }} 167 167 168 #endif 168 #endif