g4tools  5.4.0
raxml
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_raxml
5 #define tools_raxml
6 
7 #include <tools/xml/aidas>
8 
9 #include "xml/loader"
10 
11 namespace tools {
12 
13 class raxml : public tools::xml::aidas, public xml::loader {
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  {
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){
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;
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 << "tools::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
tools::raxml::operator=
raxml & operator=(const raxml &a_from)
Definition: raxml:32
tools::xml::loader::operator=
loader & operator=(const loader &a_from)
Definition: loader:92
tools::xml::aidas::find_reader
reader find_reader(const std::string &a_class) const
Definition: aidas:58
tools::raxml::raxml
raxml(const raxml &a_from)
Definition: raxml:28
tools::xml::aidas
Definition: aidas:31
tools::xml::loader::m_verbose
bool m_verbose
Definition: loader:566
tools::raxml_out
Definition: raxml_out:11
tools::xml::loader::m_out
std::ostream & m_out
Definition: loader:564
tools::raxml_out::object
void * object() const
Definition: raxml_out:39
tools::raxml
Definition: raxml:13
tools::xml::loader::m_tags
std::vector< std::string > m_tags
Definition: loader:569
tools::sg::top
@ top
Definition: enums:82
tools::xml::looper
Definition: tree:956
tools::xml::aidas::reader
raxml_out(* reader)(tree &, std::ostream &, bool, void *)
Definition: aidas:34
tools::raxml::m_read_tag
void * m_read_tag
Definition: raxml:67
tools::xml::factory
Definition: tree:38
tools::sout
Definition: sout:17
tools::raxml::~raxml
virtual ~raxml()
Definition: raxml:24
tools::xml::loader::load_file
bool load_file(const std::string &a_file, bool a_compressed)
Definition: loader:128
tools::xml::tree
Definition: tree:47
tools::xml::aidas::operator=
aidas & operator=(const aidas &)
Definition: aidas:46
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
aidas
tools::raxml::raxml
raxml(tools::xml::factory &a_fac, std::ostream &a_out, bool a_verbose=false)
Definition: raxml:17
tools::xml::aidas::set_default_tags
void set_default_tags(std::vector< std::string > &a_tags)
Definition: aidas:137
tools::xml::aidas::m_objects
std::vector< raxml_out > m_objects
Definition: aidas:1506
tools::xml::loader::top_item
const tools::xml::tree * top_item() const
Definition: loader:165
tools::raxml::set_read_tag
void set_read_tag(void *a_tag)
Definition: raxml:26
loader
tools::xml::looper::next_tree
tree * next_tree()
Definition: tree:970
tools::xml::loader
Definition: loader:42
tools::raxml::load_file
bool load_file(const std::string &a_file, bool a_compressed)
Definition: raxml:38