Async
1.5.0
include
AsyncFileReader.h
Go to the documentation of this file.
1
31
#ifndef FILE_READER_INCLUDED
32
#define FILE_READER_INCLUDED
33
34
35
/****************************************************************************
36
*
37
* System Includes
38
*
39
****************************************************************************/
40
41
#include <sigc++/sigc++.h>
42
#include <unistd.h>
43
44
#include <string>
45
46
47
/****************************************************************************
48
*
49
* Project Includes
50
*
51
****************************************************************************/
52
53
54
55
/****************************************************************************
56
*
57
* Local Includes
58
*
59
****************************************************************************/
60
61
62
63
/****************************************************************************
64
*
65
* Forward declarations
66
*
67
****************************************************************************/
68
69
70
71
/****************************************************************************
72
*
73
* Namespace
74
*
75
****************************************************************************/
76
77
namespace
Async
78
{
79
80
81
/****************************************************************************
82
*
83
* Forward declarations of classes inside of the declared namespace
84
*
85
****************************************************************************/
86
87
class
FdWatch;
88
89
90
/****************************************************************************
91
*
92
* Defines & typedefs
93
*
94
****************************************************************************/
95
96
97
98
/****************************************************************************
99
*
100
* Exported Global Variables
101
*
102
****************************************************************************/
103
104
105
106
/****************************************************************************
107
*
108
* Class definitions
109
*
110
****************************************************************************/
111
112
class
FileReader :
public
sigc::trackable
113
{
114
public
:
115
124
FileReader
(
int
buf_size);
125
129
~FileReader
(
void
);
130
136
bool
open
(
const
std::string& name);
137
142
bool
close
(
void
);
143
150
bool
isOpen
(
void
)
const
{
return
(fd != -1); }
151
159
int
read
(
void
*buf,
int
len);
160
161
162
private
:
163
int
fd;
164
FdWatch *rd_watch;
165
char
*buffer;
166
int
head, tail;
167
int
buf_size;
168
bool
is_full;
169
bool
is_eof;
170
171
void
onDataAvail(FdWatch *watch);
172
bool
fillBuffer(
void
);
173
int
bytesInBuffer(
void
)
const
;
174
175
};
/* class FileReader */
176
177
178
}
/* namespace */
179
180
#endif
/* FILE_READER_INCLUDED */
181
182
183
184
/*
185
* This file has not been truncated
186
*/
187
Async::FileReader::read
int read(void *buf, int len)
Read data from a previously opened file.
Async::FileReader::close
bool close(void)
Close a previously opened file.
Async::FileReader::isOpen
bool isOpen(void) const
Check if a file is currently opened.
Definition:
AsyncFileReader.h:182
Async::FileReader::open
bool open(const std::string &name)
Open a file for binary reading.
Async::FileReader::FileReader
FileReader(int buf_size)
Constuctor.
Async
Namespace for the asynchronous programming classes.
Definition:
AsyncApplication.h:75
Async::FileReader::~FileReader
~FileReader(void)
Destructor.
Generated on Fri Jan 31 2020 00:00:00 for Async by
1.8.17