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
13namespace BPrivate {
14
15
16class AbstractModuleDevice : public BaseDevice {
17public:
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
48protected:
49			status_t 		_DoIO(void* cookie, off_t pos,
50								void* buffer, size_t* _length, bool isWrite);
51
52protected:
53	device_node*			fNode;
54	int32					fInitialized;
55	device_module_info*		fDeviceModule;
56	void*					fDeviceData;
57};
58
59
60} // namespace BPrivate
61
62
63using BPrivate::AbstractModuleDevice;
64
65
66#endif	// ABSTRACT_MODULE_DEVICE_H
67