Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
DeviceFile.hxx
Go to the documentation of this file.
1
36#ifndef _FREERTOS_DRIVERS_COMMON_DEVICEFILE_HXX_
37#define _FREERTOS_DRIVERS_COMMON_DEVICEFILE_HXX_
38
39#include <cstdint>
40
41#include "Devtab.hxx"
42
47class DeviceFile : public Node
48{
49protected:
53 DeviceFile(const char *name)
54 : Node(name)
55 {
56 }
57
61 {
62 }
63
72 virtual ssize_t write(unsigned int index, const void *buf, size_t len) = 0;
73
80 virtual ssize_t read(unsigned int index, void *buf, size_t len) = 0;
81
89 int open(File* file, const char *path, int flags, int mode) OVERRIDE;
90
91private:
98 ssize_t read(File *file, void *buf, size_t count) OVERRIDE;
99
106 ssize_t write(File *file, const void *buf, size_t count) OVERRIDE;
107
108 void enable() OVERRIDE {}
109 void disable() OVERRIDE {}
113
117
119};
120
121#endif /* _FREERTOS_DRIVERS_COMMON_DEVICEFILE_HXX_ */
122
Base class for implementing block devices and other file drivers which can be seeked and addressed by...
~DeviceFile()
Destructor.
virtual ssize_t read(unsigned int index, void *buf, size_t len)=0
Read from the DeviceFile.
void disable() OVERRIDE
function to disable device
int open(File *file, const char *path, int flags, int mode) OVERRIDE
Open a device.
DeviceFile(const char *name)
Constructor.
virtual ssize_t write(unsigned int index, const void *buf, size_t len)=0
Write to the DeviceFile.
DeviceFile()
Default constructor.
void enable() OVERRIDE
function to enable device
void flush_buffers() OVERRIDE
Discards all pending buffers.
const char * name
device name
Definition Devtab.hxx:266
Node information.
Definition Devtab.hxx:549
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
Definition macros.h:180
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
Definition macros.h:171
File information.
Definition Devtab.hxx:52