1/* ---------------------------------------------------------------------------
2** This software is in the public domain, furnished "as is", without technical
3** support, and with no warranty, express or implied, as to its usefulness for
4** any purpose.
5**
6** DeviceInterface.h
7**
8** -------------------------------------------------------------------------*/
9
10
11#ifndef DEVICE_INTERFACE
12#define DEVICE_INTERFACE
13
14
15// ---------------------------------
16// Device Interface
17// ---------------------------------
18class DeviceInterface
19{
20 public:
21 virtual size_t read(char* buffer, size_t bufferSize) = 0;
22 virtual int getFd() = 0;
23 virtual unsigned long getBufferSize() = 0;
24 virtual int getWidth() = 0;
25 virtual int getHeight() = 0;
26 virtual int getCaptureFormat() = 0;
27 virtual ~DeviceInterface() {};
28};
29
30
31// -----------------------------------------
32// Device Capture Interface template
33// -----------------------------------------
34template<typename T>
35class DeviceCaptureAccess : public DeviceInterface
36{
37 public:
38 DeviceCaptureAccess(T* device) : m_device(device) {};
39 virtual ~DeviceCaptureAccess() { delete m_device; };
40
41 virtual size_t read(char* buffer, size_t bufferSize) { return m_device->read(buffer, bufferSize); }
42 virtual int getFd() { return m_device->getFd(); }
43 virtual unsigned long getBufferSize() { return m_device->getBufferSize(); }
44 virtual int getWidth() { return m_device->getWidth(); }
45 virtual int getHeight() { return m_device->getHeight(); }
46 virtual int getCaptureFormat() { return m_device->getFormat(); }
47
48 protected:
49 T* m_device;
50};
51
52#endif
53