FairMQ  1.2.1
C++ Message Passing Framework
FairMQParserExample.h
1 /*
2  * File: FairMQParserExample.h
3  * Author: winckler
4  *
5  * Created on May 14, 2015, 5:01 PM
6  */
7 
8 #ifndef FAIRMQPARSEREXAMPLE_H
9 #define FAIRMQPARSEREXAMPLE_H
10 
11 // FairRoot
12 #include "FairMQChannel.h"
13 #include "FairMQParser.h"
14 
15 // Boost
16 #include <boost/property_tree/ptree.hpp>
17 
18 // std
19 #include <string>
20 #include <vector>
21 #include <map>
22 
23 
24 namespace FairMQParser
25 {
26 
30 
31  // xml example 2
33  struct MQXML2
34  {
35  boost::property_tree::ptree UserParser(const std::string& filename);
36  };
37 
38  // xml example 3
40  struct MQXML3
41  {
42  boost::property_tree::ptree UserParser(const std::string& filename, const std::string& root_node);
43  };
44 
45 
46 
47 
49  // template function iterating over the whole boost property tree
50  template <typename Input_tree_It, typename Output_tree_It, typename Compare_key>
51  void ProcessTree(Input_tree_It first, Input_tree_It last, Output_tree_It dest, Compare_key compare)
52  {
53  //typedef typename std::iterator_traits<Input_tree_It>::reference reference;
54 
55  if (first == last)
56  {
57  return;
58  }
59 
60  auto begin = first->second.begin ();
61  auto end = first->second.end ();
62 
63  if (begin != end)
64  {
65  ProcessTree (begin, end, dest, compare);
66  }
67 
68  if (compare (first->first))
69  {
70  dest = *first;
71  }
72 
73  ProcessTree (++first, last, dest, compare);
74  }
75 
76  class no_id_exception: public std::exception
77  {
78  virtual const char* what() const throw()
79  {
80  return "Empty string for the device-id in FairMQParser::ptreeToMQMap(...) function";
81  }
82  };
83 
84 } // end FairMQParser namespace
85 #endif /* FAIRMQPARSEREXAMPLE_H */
86 
Definition: FairMQParserExample.cxx:13
Definition: FairMQParserExample.h:33
Definition: FairMQParserExample.h:76
Definition: FairMQParserExample.h:40