LRAUV  revA
DeviceIOStream.h
Go to the documentation of this file.
1 
10 #ifndef DEVICEIOSTREAM_H_
11 #define DEVICEIOSTREAM_H_
12 
13 #include <cstdio>
14 
15 #include "data/ElementURI.h"
16 #include "io/IOStream.h"
17 #include "logger/Logger.h"
23 class DeviceIOStream : public IOStream
24 {
25 public:
26 
29  DeviceIOStream( const char* filename, bool useHardware );
30 
34  DeviceIOStream( const ConfigURI& configUri, bool useHardware, Logger& logger );
35 
36  virtual ~DeviceIOStream();
37 
39  virtual IOStream& read( char* buffer, size_t num );
40 
41  bool isReadable()
42  {
43  return -1 != file_;
44  }
45 
47  virtual bool eof()
48  {
49  return -1 != file_;
50  }
51 
53  virtual OutStream& write( const char* buffer, size_t num );
54 
56  virtual bool isWritable()
57  {
58  return -1 != file_;
59  }
60 
61  const char* getName()
62  {
63  return name_.cStr();
64  }
65 
66 protected:
67  int file_;
68 
69 private:
70  // Note that the copy constructor below is private and not given a body.
71  // Any attempt to call it will return a compiler error.
72  DeviceIOStream( const DeviceIOStream& old ); // disallow copy constructor
73 
74  static Str GetFilename( const ConfigURI& configUri, Logger& logger );
75 
77  const Str name_;
78 
79 };
80 
81 #endif /*DEVICEIOSTREAM_H_*/
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
virtual bool isWritable()
indicates that the stream can actually be written to.
Definition: DeviceIOStream.h:56
This is a rather abstract class that can be implemented by classes that want to send and receive stre...
Definition: IOStream.h:30
virtual OutStream & write(const char *buffer, size_t num)
Writes num bytes from buffer to the output buffer/stream.
Definition: DeviceIOStream.cpp:72
const Str name_
Definition: DeviceIOStream.h:77
DeviceIOStream(const char *filename, bool useHardware)
Constructor 1 argument filename: device filename.
Definition: DeviceIOStream.cpp:20
static Str GetFilename(const ConfigURI &configUri, Logger &logger)
Definition: DeviceIOStream.cpp:81
const char * getName()
returns name of the stream
Definition: DeviceIOStream.h:61
Contains the IOStream and NullIOStream class declarations.
Definition: ElementURI.h:166
virtual ~DeviceIOStream()
Definition: DeviceIOStream.cpp:49
int file_
Definition: DeviceIOStream.h:67
bool useHardware_
Definition: DeviceIOStream.h:76
Replacement for standard template class string.
Definition: Str.h:12
Contains the ElementURI class definition.
const char * cStr() const
Definition: Str.h:188
virtual bool eof()
Indicates that the end of file can not be reached.
Definition: DeviceIOStream.h:47
bool isReadable()
indicates whether the stream can actually be read from.
Definition: DeviceIOStream.h:41
Contains the Logger class definition.
This is a very abstract class that can be implemented by classes that want to send stream output...
Definition: OutStream.h:41
Wraps a linux device with an IOStream class.
Definition: DeviceIOStream.h:23
virtual IOStream & read(char *buffer, size_t num)
reads num bytes from buffer to the output buffer/stream
Definition: DeviceIOStream.cpp:58