Project

General

Profile

Support Request #14449 » iodevice.h

hidden, 2021-06-09 06:06

 
1
/**
2
 *
3
 * Base I/O device implementation.
4
 *
5
 * @file
6
 * Copyright © Audi Electronics Venture GmbH. All rights reserved.
7
 *
8
 * $Author: A1RHEND $
9
 * $Date: 2013-04-11 13:09:49 +0200 (Thu, 11 Apr 2013) $
10
 * $Revision: 37962 $
11
 * @remarks
12
 *
13
 */
14
#ifndef _BASE_IO_DEVICE_
15
#define _BASE_IO_DEVICE_
16

    
17
namespace adtf
18
{
19

    
20
/**
21
 *
22
 * Generic I/O device event interface.
23
 *
24
 * Implementation is provided. 
25
 *
26
 * @see iodevice.cpp.
27
 */
28
class DOEXPORT IDeviceEventHandler
29
{
30
    public:
31
        /**
32
         *  Enumeration for device events.
33
         */
34
        typedef enum
35
        {
36
            ///unkown event.
37
            DE_Unknown      = 0,
38
            ///new data received.
39
            DE_NewData      = 1, 
40
            
41
            ///user event offset.
42
            DE_User         = 0x0100
43
        } tDeviceEventId;
44

    
45
    public:
46
        /**
47
         *
48
         * Device event handler. The OnDeviceEvent method handles incoming device events.
49
         *
50
         * @param    nEventId    [in] Event identifier (@ref tDeviceEventId).
51
         * @param    nParam1     [in] Event specific parameter.
52
         * @param    nParam2     [in] Event specific parameter.
53
         * @param    pvData      [in,out] Pointer to event specific data block. Can be NULL.
54
         * @param    nDataSize   [in] Size of event specific data block.
55
         * @return   Returns a standard result code.
56
         *
57
         */
58
        virtual tResult OnDeviceEvent(tInt nEventId, tInt nParam1, tInt nParam2, tVoid* pvData, tInt nDataSize) = 0;
59
};
60

    
61
/**
62
 *
63
 * Generic I/O device implementation.
64
 *
65
 */
66
class DOEXPORT cBaseIODevice : public ucom::IDevice
67
{
68
    ADTF_D(cBaseIODevice)
69

    
70
    protected:
71
        IDeviceEventHandler*    m_pEventHandler;    //!< @todo
72

    
73
    public:
74
        cBaseIODevice();
75
        virtual ~cBaseIODevice();
76

    
77
    public: // implements IDevice
78
        /**
79
         * @copydoc ucom::IDevice::Open()
80
         * @remarks Implements the IDevice::Open()
81
         */
82
        tResult Open(const tChar* strDeviceName, tInt nMode=0, ucom::IException** __exception_ptr=NULL);
83
        
84
        /**
85
         * @copydoc ucom::IDevice::Close()
86
         */
87
        tResult Close(ucom::IException** __exception_ptr=NULL);
88
        
89
        tInt Read(tVoid* pvBuffer, tInt nBufferSize);
90
        tInt Write(const tVoid* pvBuffer, tInt nBufferSize);
91
        /**
92
         * @copydoc ucom::IDevice::IOCtl()
93
         * @remarks Implements the IDevice::Open()
94
         */
95
        tInt IOCtl(tInt nCommand, tVoid* pvData=NULL, tInt nDataSize=0);
96

    
97
    public: // implements IObject
98
        tResult GetInterface(const tChar* idInterface, void ** ppvObject);
99
        tUInt Ref();
100
        tUInt Unref();
101
        tVoid Destroy();
102

    
103
    protected:
104
        /**
105
         *
106
         * Forward device specific event to handler. This methods is responsible to forward
107
         * device specific notification to the device event handler. Usually the device event
108
         * handler is implemented by the device filter.
109
         *
110
         * @param    nEventId     [in] Event identifier.
111
         * @param    nParam1      [in] Event specific parameter.
112
         * @param    nParam2      [in] Event specific parameter.
113
         * @param    pvData       [in,out] Pointer to event specific data.
114
         * @param    nDataSize    [in] Size of event specific data block.
115
         *
116
         * @return   Returns a standard result code.
117
         *
118
         */
119
        virtual tResult SetDeviceEvent(tInt nEventId,
120
                                       tInt nParam1=0,
121
                                       tInt nParam2=0,
122
                                       tVoid* pvData=NULL,
123
                                       tInt nDataSize=0);
124
};
125

    
126
} // namespace adtf
127

    
128
//*************************************************************************************************
129
#endif // _BASE_IO_DEVICE_
(5-5/7)