22#define _G3_DATAIO_H
33
44#include < string>
5- #include < vector>
6- #include < boost/iostreams/filtering_stream.hpp>
7-
8- typedef boost::iostreams::filtering_istream g3_istream;
9- typedef boost::iostreams::filtering_ostream g3_ostream;
5+ #include < memory>
6+ #include < iostream>
107
118/* *
129 * Configure a filtering stream for G3Frame decompression from a local or remote
1310 * file source.
1411 *
15- * @param stream A reference to the filtering istream that will be configured
16- * by this function. Must be instantiated prior to this
17- * function.
1812 * @param path A valid filename on disk, or a TCP socket address. If a
1913 * filename, the compression scheme is determined from the file
2014 * extension. Supported compression schemes are gzip or bzip2.
@@ -25,36 +19,52 @@ typedef boost::iostreams::filtering_ostream g3_ostream;
2519 * read until EOF.
2620 * @param timeout Timeout in seconds for socket connections.
2721 * @param buffersize Advisory buffer size in bytes for aggregating reads
28- * @return File descriptor for socket connections, or -1 for file input.
22+ * @return stream The input stream configured by this function.
23+ */
24+ std::shared_ptr<std::istream>
25+ g3_istream_from_path (const std::string &path, float timeout=-1.0 ,
26+ size_t buffersize=1024 *1024 );
27+
28+ /* *
29+ * Return the file descriptor handle for socket connections.
30+ *
31+ * @param stream A reference to the input stream, as configured by
32+ * g3_istream_from_path.
33+ * @return fd The socket file descriptor.
2934 */
30- int g3_istream_from_path (g3_istream &stream, const std::string &path,
31- float timeout=-1.0 , size_t buffersize=1024 *1024 );
35+ int g3_istream_handle (std::shared_ptr<std::istream> &stream);
3236
3337/* *
3438 * Configure a filtering stream for G3Frame compression to a local file.
3539 *
36- * @param stream A reference to the filtering ostream that will be configured
37- * by this function. Must be instantiated prior to this
38- * function.
3940 * @param path A valid filename on disk. If a filename, the compression
4041 * scheme is determined from the file extension. Supported
4142 * compression schemes are gzip or bzip2.
4243 * @param append If true, append to an existing file on disk. Otherwise,
4344 * Create a new file or overwrite an existing file.
4445 * @param counter If true, add a counter filter to the stream configuration,
4546 * for use by the g3_ostream_count function.
47+ * @return stream The output stream configured by this function.
4648 */
47- void g3_ostream_to_path (g3_ostream &stream, const std::string &path,
48- bool append=false , bool counter=false );
49+ std::shared_ptr<std::ostream>
50+ g3_ostream_to_path ( const std::string &path, bool append=false , bool counter=false );
4951
5052/* *
5153 * Count the number of bytes written to the output file stream.
5254 *
53- * @param stream A reference to the filtering ostream , as configured by
55+ * @param stream A reference to the output stream , as configured by
5456 * g3_ostream_to_path with the counter argument set to true.
5557 * @return Number of bytes written to disk.
5658 */
57- size_t g3_ostream_count (g3_ostream &stream);
59+ size_t g3_ostream_count (std::shared_ptr<std::ostream> &stream);
60+
61+ /* *
62+ * Flush the output file stream.
63+ *
64+ * @param stream A reference to the output stream, as configured by
65+ * g3_ostream_to_path.
66+ */
67+ void g3_ostream_flush (std::shared_ptr<std::ostream> &stream);
5868
5969/* *
6070 * Check that the input filename is a valid filename on disk.
0 commit comments