vdj_pipe
pipeline for processing DNA sequence data
visitor.hpp
Go to the documentation of this file.
1 
7 #ifndef VISITOR_HPP_
8 #define VISITOR_HPP_
9 #include <ostream>
10 #include "boost/variant.hpp"
11 #include "vdj_pipe/exception.hpp"
12 
13 namespace vdj_pipe{
14 struct Seq_qual_record;
15 
18 struct Run_visitor : public boost::static_visitor<> {
19  template<typename Step> void operator()(Step& step) const {
20  try{
21  step.run();
22  } catch(std::exception const&) {
23  BOOST_THROW_EXCEPTION(
25  << base_exception::msg_t("processing step error")
26  << base_exception::str1_t(Step::name())
27  << base_exception::nested_t(boost::current_exception())
28  );
29  }
30  }
31 };
32 
35 struct Finish_visitor : public boost::static_visitor<> {
36  template<typename Step> void operator()(Step& step) const {
37  try{
38  step.finish();
39  } catch(std::exception const&) {
40  BOOST_THROW_EXCEPTION(
42  << base_exception::msg_t("error finalizing processing step")
43  << base_exception::str1_t(Step::name())
44  << base_exception::nested_t(boost::current_exception())
45  );
46  }
47  }
48 };
49 
52 class Summary_visitor : public boost::static_visitor<> {
53 public:
54  explicit Summary_visitor(std::ostream& os) : os_(os), n_(1) {
55  os_ << "Step summaries" << '\n';
56  }
57 
58  template<typename Step> void operator()(Step& step) {
59  os_
60  << '\n' << n_++ << ". " << Step::name() << '\n';
61  step.summary(os_);
62  }
63 
64 private:
65  std::ostream& os_;
66  std::size_t n_;
67 };
68 
71 class Summary_visitor2 : public boost::static_visitor<> {
72 public:
73  explicit Summary_visitor2(std::ostream& os) : os_(os) {}
74 
75  template<typename Step> void operator()(Step& step) {
76  step.summary(os_);
77  }
78 
79 private:
80  std::ostream& os_;
81 };
82 
83 }//namespace vdj_pipe
84 #endif /* VISITOR_HPP_ */
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Definition: visitor.hpp:71
Definition: visitor.hpp:18
Definition: visitor.hpp:52
Definition: exception.hpp:23
Definition: visitor.hpp:35