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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

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