vdj_pipe
pipeline for processing DNA sequence data
file_ostream_variant.hpp
Go to the documentation of this file.
1 
7 #ifndef FILE_OSTREAM_VARIANT_HPP_
8 #define FILE_OSTREAM_VARIANT_HPP_
9 #include <string>
10 #include <vector>
11 #include "boost/shared_ptr.hpp"
12 #include "vdj_pipe/config.hpp"
14 #include "vdj_pipe/exception.hpp"
15 #include "vdj_pipe/file.hpp"
16 #include "vdj_pipe/value_map.hpp"
17 
18 namespace vdj_pipe{
19 class File_ostream_queue;
20 class File_ostream;
21 
27 class VDJ_PIPE_DECL File_ostream_variant {
28  typedef detail::Queable_ofstream_types::value_type value_type;
29  typedef detail::Queable_ofstream_types::val_ref_vector val_ref_vector;
30  typedef detail::Queable_ofstream_types::path_template path_template;
31  typedef detail::Queable_ofstream_types::val_vector val_vector;
32 
33 public:
34  struct Err : public base_exception {};
35 
37  static std::string const& skip_empty() {
38  static const std::string s = "<?|>";
39  return s;
40  }
41 
43 
55  std::string const& path,
56  std::string const& unset_element,
57  Value_map const& vm,
58  std::string const& header = "",
59  const compression::Compression compr = compression::unknown,
60  format::Format fmt = format::unknown,
61  const std::size_t queue_size = 500
62  );
63 
65  std::vector<Val_id> const& var_ids,
66  path_template const& pt,
67  std::string const& unset_element,
68  std::string const& header = "",
69  const compression::Compression compr = compression::unknown,
70  format::Format fmt = format::unknown,
71  const std::size_t queue_size = 500
72  );
73 
74  File_ostream& ostream() {return *fos_;}
75  File_ostream& ostream(Value_map const& vm);
76  File_ostream& ostream(val_vector const& vv);
77 
79  std::size_t size() const;
80  std::vector<Val_id> const& variable_ids() const {return idv_;}
81 
82 private:
83  value_type unset_element_;
84 
85  //if true, no output if one of variables is blank
86  bool skip_empty_;
87 
88  std::vector<Val_id> idv_;
89  boost::shared_ptr<File_ostream> fos_;
90  boost::shared_ptr<File_ostream_queue> fosq_;
91 
92  void init_single(
93  std::string const& path,
94  std::string const& header,
95  const compression::Compression compr,
96  format::Format fmt
97  );
98 
99  void init_queue(
100  std::string const& path,
101  Value_map const& vm,
102  std::string const& header,
103  format::Format fmt,
104  const std::size_t queue_size
105  );
106 
107  void init_queue(
108  path_template const& pt,
109  std::string const& header,
110  format::Format fmt,
111  const std::size_t queue_size
112  );
113 };
114 
115 }//namespace vdj_pipe
116 #endif /* FILE_OSTREAM_VARIANT_HPP_ */
Format
File format types.
Definition: file_properties.hpp:42
static std::string const & skip_empty()
Definition: file_ostream_variant.hpp:37
Select output file based on variables in value map.
Definition: file_ostream_variant.hpp:27
Compression
File compression types.
Definition: file_properties.hpp:19
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Definition: file_ostream_variant.hpp:34
Definition: exception.hpp:23
Definition: file_stream.hpp:24
Store values mapped against name strings and value IDs.
Definition: value_map.hpp:23