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_ */
void operator()(Step &step) const
Definition: visitor.hpp:36
void operator()(Step &step)
Definition: visitor.hpp:58
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
boost::errinfo_nested_exception nested_t
Definition: exception.hpp:32
Definition: visitor.hpp:71
Definition: visitor.hpp:18
std::ostream & os_
Definition: visitor.hpp:80
boost::error_info< struct errinfo_str1_, std::string > str1_t
Definition: exception.hpp:25
Definition: visitor.hpp:52
void operator()(Step &step)
Definition: visitor.hpp:75
Summary_visitor2(std::ostream &os)
Definition: visitor.hpp:73
std::size_t n_
Definition: visitor.hpp:66
Definition: exception.hpp:23
boost::error_info< struct errinfo_message_, std::string > msg_t
Definition: exception.hpp:24
std::ostream & os_
Definition: visitor.hpp:65
void operator()(Step &step) const
Definition: visitor.hpp:19
Summary_visitor(std::ostream &os)
Definition: visitor.hpp:54
Definition: visitor.hpp:35