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 toolx_raxml 4 #ifndef toolx_raxml 5 #define toolx_raxml 5 #define toolx_raxml 6 6 7 #include <tools/xml/aidas> 7 #include <tools/xml/aidas> 8 8 9 #include "xml/loader" 9 #include "xml/loader" 10 10 11 namespace toolx { 11 namespace toolx { 12 12 13 class raxml : public tools::xml::aidas, public 13 class raxml : public tools::xml::aidas, public xml::loader { 14 typedef tools::xml::aidas parent_aidas; 14 typedef tools::xml::aidas parent_aidas; 15 typedef xml::loader parent; 15 typedef xml::loader parent; 16 public: 16 public: 17 raxml(tools::xml::factory& a_fac,std::ostrea 17 raxml(tools::xml::factory& a_fac,std::ostream& a_out,bool a_verbose = false) 18 :parent_aidas() 18 :parent_aidas() 19 ,parent(a_fac,a_out,a_verbose) 19 ,parent(a_fac,a_out,a_verbose) 20 ,m_read_tag(0) 20 ,m_read_tag(0) 21 { 21 { 22 set_default_tags(parent::m_tags); 22 set_default_tags(parent::m_tags); 23 } 23 } 24 virtual ~raxml() {} 24 virtual ~raxml() {} 25 public: 25 public: 26 void set_read_tag(void* a_tag) {m_read_tag = 26 void set_read_tag(void* a_tag) {m_read_tag = a_tag;} 27 protected: 27 protected: 28 raxml(const raxml& a_from) 28 raxml(const raxml& a_from) 29 :parent_aidas(a_from) 29 :parent_aidas(a_from) 30 ,parent(a_from) 30 ,parent(a_from) 31 {} 31 {} 32 raxml& operator=(const raxml& a_from){ 32 raxml& operator=(const raxml& a_from){ 33 parent_aidas::operator=(a_from); 33 parent_aidas::operator=(a_from); 34 parent::operator=(a_from); 34 parent::operator=(a_from); 35 return *this; 35 return *this; 36 } 36 } 37 public: 37 public: 38 bool load_file(const std::string& a_file,boo 38 bool load_file(const std::string& a_file,bool a_compressed){ 39 m_objects.clear(); 39 m_objects.clear(); 40 if(!parent::load_file(a_file,a_compressed) 40 if(!parent::load_file(a_file,a_compressed)) return false; 41 tools::xml::tree* top = top_item(); 41 tools::xml::tree* top = top_item(); 42 if(!top) return false; 42 if(!top) return false; 43 const std::string& tag_name = top->tag_nam 43 const std::string& tag_name = top->tag_name(); 44 if(tag_name!=s_aida()) return false; 44 if(tag_name!=s_aida()) return false; 45 45 46 {tools::xml::looper _for(*top); 46 {tools::xml::looper _for(*top); 47 while(tools::xml::tree* _tree = _for.next_ 47 while(tools::xml::tree* _tree = _for.next_tree()) { 48 48 49 const std::string& _tag_name = _tree->ta 49 const std::string& _tag_name = _tree->tag_name(); 50 reader rder = find_reader(_tag_name); 50 reader rder = find_reader(_tag_name); 51 if(!rder) { 51 if(!rder) { 52 m_out << "toolx::raxml::load_file :" 52 m_out << "toolx::raxml::load_file :" 53 << " reader not found for " << t 53 << " reader not found for " << tools::sout(_tag_name) 54 << std::endl; 54 << std::endl; 55 //m_objects.clear(); //keep already lo 55 //m_objects.clear(); //keep already loaded objects. 56 return false; 56 return false; 57 } else { 57 } else { 58 tools::raxml_out ro = rder(*_tree,m_ou 58 tools::raxml_out ro = rder(*_tree,m_out,m_verbose,m_read_tag); 59 if(ro.object()) m_objects.push_back(ro 59 if(ro.object()) m_objects.push_back(ro); 60 } 60 } 61 61 62 }} 62 }} 63 63 64 return true; 64 return true; 65 } 65 } 66 protected: 66 protected: 67 void* m_read_tag; 67 void* m_read_tag; 68 }; 68 }; 69 69 70 } 70 } 71 71 72 #endif 72 #endif