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