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 
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 = "",
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 = "",
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
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_ */
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
boost::shared_ptr< File_ostream_queue > fosq_
Definition: file_ostream_variant.hpp:90
std::vector< std::string > path_template
Definition: queable_ofstream_types.hpp:25
Compression
File compression types.
Definition: file_properties.hpp:19
detail::Queable_ofstream_types::path_template path_template
Definition: file_ostream_variant.hpp:30
detail::Queable_ofstream_types::value_type value_type
Definition: file_ostream_variant.hpp:28
detail::Queable_ofstream_types::val_ref_vector val_ref_vector
Definition: file_ostream_variant.hpp:29
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
#define VDJ_PIPE_DECL
Definition: config.hpp:23
Definition: file_ostream_variant.hpp:34
File_ostream & ostream()
Definition: file_ostream_variant.hpp:74
std::vector< value_type > val_vector
Definition: queable_ofstream_types.hpp:20
Definition: file_properties.hpp:43
Format
File format types.
Definition: file_properties.hpp:42
value_variant value_type
Definition: queable_ofstream_types.hpp:19
std::vector< Val_id > const & variable_ids() const
Definition: file_ostream_variant.hpp:80
bool skip_empty_
Definition: file_ostream_variant.hpp:86
Definition: exception.hpp:23
boost::shared_ptr< File_ostream > fos_
Definition: file_ostream_variant.hpp:89
Definition: file_stream.hpp:24
std::vector< boost::reference_wrapper< value_type const > > val_ref_vector
Definition: queable_ofstream_types.hpp:23
detail::Queable_ofstream_types::val_vector val_vector
Definition: file_ostream_variant.hpp:31
Store values mapped against name strings and value IDs.
Definition: value_map.hpp:23
std::vector< Val_id > idv_
Definition: file_ostream_variant.hpp:88
value_type unset_element_
Definition: file_ostream_variant.hpp:83
Definition: file_properties.hpp:20