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