整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
47
util/Device.h
Normal file
47
util/Device.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef C5ADE9DB_6B16_4E4F_8C58_0101E9832DE0
|
||||
#define C5ADE9DB_6B16_4E4F_8C58_0101E9832DE0
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include <string>
|
||||
#include <poll.h>
|
||||
|
||||
namespace Util
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DECLARE
|
||||
*******************************************************************************
|
||||
*/
|
||||
class Device
|
||||
{
|
||||
public:
|
||||
enum Mode
|
||||
{
|
||||
RD_ONLY,
|
||||
WR_ONLY,
|
||||
RDWR,
|
||||
};
|
||||
|
||||
public:
|
||||
Device(std::string path, Mode mode = Mode::RD_ONLY);
|
||||
~Device();
|
||||
|
||||
virtual void open();
|
||||
virtual int write(uint8_t* data, int size);
|
||||
virtual int read(uint8_t* buffer, int count);
|
||||
virtual void close();
|
||||
virtual int fcntl(int cmd);
|
||||
virtual int fcntl(int cmd, long arg);
|
||||
virtual int fcntl(int cmd, long arg, void* lock);
|
||||
virtual int poll(unsigned int& revents, int timeout);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
Mode _mode;
|
||||
int _fd;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue