vdj_pipe
pipeline for processing DNA sequence data
file_ostream_queue.hpp
Go to the documentation of this file.
1 
7 #ifndef FILE_OSTREAM_QUEUE_HPP_
8 #define FILE_OSTREAM_QUEUE_HPP_
9 #include <iosfwd>
10 #include "boost/multi_index_container.hpp"
11 #include "boost/multi_index/hashed_index.hpp"
12 #include "boost/multi_index/member.hpp"
13 #include "boost/multi_index/sequenced_index.hpp"
14 #include "boost/range.hpp"
15 #include "boost/shared_ptr.hpp"
16 #include "vdj_pipe/config.hpp"
18 #include "vdj_pipe/exception.hpp"
19 #include "vdj_pipe/file_stream.hpp"
20 
21 namespace vdj_pipe{
22 
30 
31  struct Err : public base_exception {};
32 
33  static std::string make_path(
34  path_template const& templ,
35  val_ref_vector const& vals,
36  std::string const& header
37  );
38 
40  path_template const& templ,
41  val_ref_vector const& vals,
42  const format::Format fmt,
43  std::string const& header
44  );
45 
46  val_vector sv_;
47  mutable File_ostream fos_;
48 };
49 
50 
56 
57  typedef boost::multi_index_container<
59  boost::multi_index::indexed_by<
60  boost::multi_index::sequenced<>,
61  boost::multi_index::hashed_unique<
62  boost::multi_index::member<
63  Queable_ofstream, val_vector, &Queable_ofstream::sv_
64  >
65  >
66  >
67  > map_t;
68  typedef map_t::iterator seq_iterator;
69  typedef map_t::nth_index<1>::type index;
70  typedef index::iterator hash_iterator;
71  typedef index::const_iterator hash_citerator;
72 
73 public:
76 
77  struct Err : public base_exception {};
78 
79  template<class Range> explicit File_ostream_queue(
80  Range const& r,
81  std::string const& header = "",
82  const format::Format fmt = format::unknown,
83  const std::size_t sz = 100
84  )
85  : pt_(boost::begin(r), boost::end(r)),
86  header_(header),
87  vm_(),
88  fmt_(
89  fmt == format::unknown ?
90  guess_compression_format(pt_.back()).second :
91  fmt
92  ),
93  sz_(sz)
94  {}
95 
96  File_ostream& ostream(val_ref_vector const& v);
97  std::size_t size() const {return vm_.size();}
98 
99 private:
100  path_template pt_;
101  std::string header_;
104  std::size_t sz_;
105 };
106 
107 }//namespace vdj_pipe
108 #endif /* FILE_OSTREAM_QUEUE_HPP_ */
map_t::nth_index< 1 >::type index
Definition: file_ostream_queue.hpp:69
detail::Queable_ofstream_types::val_ref_vector val_ref_vector
Definition: file_ostream_queue.hpp:74
Definition: sanitize_string.cpp:15
val_vector sv_
Definition: file_ostream_queue.hpp:46
map_t::iterator seq_iterator
Definition: file_ostream_queue.hpp:68
detail::Queable_ofstream_types::value_type value_type
Definition: file_ostream_queue.hpp:75
std::string header_
Definition: file_ostream_queue.hpp:101
std::size_t size() const
Definition: file_ostream_queue.hpp:97
std::vector< std::string > path_template
Definition: queable_ofstream_types.hpp:25
index::const_iterator hash_citerator
Definition: file_ostream_queue.hpp:71
Definition: file_ostream_queue.hpp:31
detail::Queable_ofstream_types::val_vector val_vector
Definition: file_ostream_queue.hpp:27
detail::Queable_ofstream_types::val_ref_vector val_ref_vector
Definition: file_ostream_queue.hpp:28
format::Format fmt_
Definition: file_ostream_queue.hpp:103
File_ostream fos_
Definition: file_ostream_queue.hpp:47
std::size_t sz_
Definition: file_ostream_queue.hpp:104
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
File_ostream_queue(Range const &r, std::string const &header="", const format::Format fmt=format::unknown, const std::size_t sz=100)
Definition: file_ostream_queue.hpp:79
#define VDJ_PIPE_DECL
Definition: config.hpp:23
Definition: file_ostream_queue.hpp:25
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
Definition: file_ostream_queue.hpp:77
Queable_ofstream::val_vector val_vector
Definition: file_ostream_queue.cpp:52
stack of recently used output file streams
Definition: file_ostream_queue.hpp:53
value_variant value_type
Definition: queable_ofstream_types.hpp:19
detail::Queable_ofstream_types::value_type value_type
Definition: file_ostream_queue.hpp:26
std::pair< compression::Compression, format::Format > guess_compression_format(std::string const &path)
Definition: file.cpp:64
Definition: exception.hpp:23
detail::Queable_ofstream_types::path_template path_template
Definition: file_ostream_queue.hpp:55
boost::multi_index_container< Queable_ofstream, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::hashed_unique< boost::multi_index::member< Queable_ofstream, val_vector,&Queable_ofstream::sv_ > > > > map_t
Definition: file_ostream_queue.hpp:67
Definition: file_stream.hpp:24
std::vector< boost::reference_wrapper< value_type const > > val_ref_vector
Definition: queable_ofstream_types.hpp:23
index::iterator hash_iterator
Definition: file_ostream_queue.hpp:70
detail::Queable_ofstream_types::path_template path_template
Definition: file_ostream_queue.hpp:29
path_template pt_
Definition: file_ostream_queue.hpp:100
detail::Queable_ofstream_types::val_vector val_vector
Definition: file_ostream_queue.hpp:54
const std::size_t sz
Definition: vector_set_test.cpp:27
map_t vm_
Definition: file_ostream_queue.hpp:102
Definition: file_properties.hpp:20