inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/rroot/fac
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_rroot_fac
00005 #define inlib_rroot_fac
00006 
00007 #include "../sout"
00008 
00009 #include "branch_element"
00010 #include "leaf"
00011 #include "basket"
00012 #include "dummy"
00013 
00014 namespace inlib {
00015 namespace rroot {
00016 
00017 class fac : public virtual ifac {
00018 public: //ifac
00019   virtual iro* create(const std::string& a_class,const args& a_args) {
00020     //m_file.out() << "inlib::rroot::fac::create :"
00021     //      << " create object of class " << a_class << "..."
00022     //      << std::endl;
00023     if(a_class=="TBranch") {
00024       return new branch(m_file,*this);
00025     } else if(a_class=="TBranchElement") {
00026       return new branch_element(m_file,*this);
00027 
00028     } else if(a_class=="TLeafB") {
00029       branch* b = arg_branch(a_args);
00030       if(!b) return 0;
00031       return new leaf<char>(m_file.out(),*b,*this);
00032 
00033     } else if(a_class=="TLeafS") {
00034       branch* b = arg_branch(a_args);
00035       if(!b) return 0;
00036       return new leaf<short>(m_file.out(),*b,*this);
00037 
00038     } else if(a_class=="TLeafI") {
00039       branch* b = arg_branch(a_args);
00040       if(!b) return 0;
00041       return new leaf<int>(m_file.out(),*b,*this);
00042 
00043     } else if(a_class=="TLeafF") {
00044       branch* b = arg_branch(a_args);
00045       if(!b) return 0;
00046       return new leaf<float>(m_file.out(),*b,*this);
00047 
00048     } else if(a_class=="TLeafD") {
00049       branch* b = arg_branch(a_args);
00050       if(!b) return 0;
00051       return new leaf<double>(m_file.out(),*b,*this);
00052 
00053     } else if(a_class=="TLeafC") {
00054       branch* b = arg_branch(a_args);
00055       if(!b) return 0;
00056       return new leaf_string(m_file.out(),*b,*this);
00057 
00058     } else if(a_class=="TLeafElement") {
00059       branch* b = arg_branch(a_args);
00060       if(!b) return 0;
00061       return new leaf_element(m_file.out(),*b,*this);
00062 
00063     } else if(a_class=="TBasket") {
00064       return new basket(m_file);
00065     } else {
00066       m_file.out() << "inlib::rroot::fac::create :"
00067                    << " unknown class " << sout(a_class) << "."
00068                    << " Create a inlib::rroot::dummy object."
00069                    << std::endl;
00070       return new dummy();
00071     }
00072   }
00073 public:
00074   fac(ifile& a_file):m_file(a_file){}
00075   virtual ~fac(){}
00076 public:
00077   fac(const fac& a_from): ifac(a_from),m_file(a_from.m_file){}
00078   fac& operator=(const fac&){return *this;}
00079 protected:
00080   branch* arg_branch(const args& a_args) {
00081     void* p = ifac::find_args(a_args,ifac::arg_branch());
00082     if(!p) {
00083       m_file.out() << "inlib::rroot::fac::arg_branch :"
00084                    << " branch not found in args."
00085                    << std::endl;
00086       return 0;
00087     }
00088     return (branch*)p;
00089   }
00090 protected:
00091   ifile& m_file;
00092 };
00093 
00094 }}
00095 
00096 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines