1 /* 2 * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2008-2009, Axel Dörfler, axeld@pinc-software.de. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef ABSTRACT_MODULE_DEVICE_H 7 #define ABSTRACT_MODULE_DEVICE_H 8 9 10 #include "BaseDevice.h" 11 12 13 namespace BPrivate { 14 15 16 class AbstractModuleDevice : public BaseDevice { 17 public: 18 AbstractModuleDevice(); 19 virtual ~AbstractModuleDevice(); 20 21 device_module_info* Module() const { return fDeviceModule; } 22 23 void* Data() const { return fDeviceData; } 24 device_node* Node() const { return fNode; } 25 26 virtual bool HasSelect() const; 27 virtual bool HasDeselect() const; 28 virtual bool HasRead() const; 29 virtual bool HasWrite() const; 30 virtual bool HasIO() const; 31 32 virtual status_t Open(const char* path, int openMode, 33 void** _cookie); 34 virtual status_t Read(void* cookie, off_t pos, void* buffer, 35 size_t* _length); 36 virtual status_t Write(void* cookie, off_t pos, const void* buffer, 37 size_t* _length); 38 virtual status_t IO(void* cookie, io_request* request); 39 virtual status_t Control(void* cookie, int32 op, void* buffer, 40 size_t length); 41 virtual status_t Select(void* cookie, uint8 event, selectsync* sync); 42 virtual status_t Deselect(void* cookie, uint8 event, 43 selectsync* sync); 44 45 virtual status_t Close(void* cookie); 46 virtual status_t Free(void* cookie); 47 48 protected: 49 device_node* fNode; 50 int32 fInitialized; 51 device_module_info* fDeviceModule; 52 void* fDeviceData; 53 }; 54 55 56 } // namespace BPrivate 57 58 59 using BPrivate::AbstractModuleDevice; 60 61 62 #endif // ABSTRACT_MODULE_DEVICE_H 63