GNU Radio Manual and C++ API Reference  v3.9.2.0-89-gb7c7001e
The Free & Open Software Radio Ecosystem
file_sink_base.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004,2007,2008,2013 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 #ifndef INCLUDED_GR_FILE_SINK_BASE_H
12 #define INCLUDED_GR_FILE_SINK_BASE_H
13 
14 #include <gnuradio/blocks/api.h>
15 #include <gnuradio/logger.h>
16 #include <boost/thread.hpp>
17 #include <cstdio>
18 
19 namespace gr {
20 namespace blocks {
21 
22 /*!
23  * \brief Common base class for file sinks
24  */
26 {
27 protected:
28  FILE* d_fp; // current FILE pointer
29  FILE* d_new_fp; // new FILE pointer
30  bool d_updated; // is there a new FILE pointer?
34  bool d_append;
36 
37 protected:
38  file_sink_base(const char* filename, bool is_binary, bool append);
39 
40 public:
43 
44  /*!
45  * \brief Open filename and begin output to it.
46  */
47  bool open(const char* filename);
48 
49  /*!
50  * \brief Close current output file.
51  *
52  * Closes current output file and ignores any output until
53  * open is called to connect to another file.
54  */
55  void close();
56 
57  /*!
58  * \brief if we've had an update, do it now.
59  */
60  void do_update();
61 
62  /*!
63  * \brief turn on unbuffered writes for slower outputs
64  */
65  void set_unbuffered(bool unbuffered);
66 };
67 
68 } /* namespace blocks */
69 } /* namespace gr */
70 
71 #endif /* INCLUDED_GR_FILE_SINK_BASE_H */
Common base class for file sinks.
Definition: file_sink_base.h:26
bool d_updated
Definition: file_sink_base.h:30
bool open(const char *filename)
Open filename and begin output to it.
void close()
Close current output file.
void set_unbuffered(bool unbuffered)
turn on unbuffered writes for slower outputs
FILE * d_fp
Definition: file_sink_base.h:28
bool d_unbuffered
Definition: file_sink_base.h:33
bool d_is_binary
Definition: file_sink_base.h:31
file_sink_base()
Definition: file_sink_base.h:41
boost::mutex d_mutex
Definition: file_sink_base.h:32
file_sink_base(const char *filename, bool is_binary, bool append)
FILE * d_new_fp
Definition: file_sink_base.h:29
bool d_append
Definition: file_sink_base.h:34
void do_update()
if we've had an update, do it now.
gr::logger_ptr d_debug_logger
Definition: file_sink_base.h:35
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:18
boost::mutex mutex
Definition: thread.h:37
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:29
log4cpp::Category * logger_ptr
GR_LOG macros.
Definition: logger.h:60