HidReport.h
author sl
Sat, 12 Jul 2014 13:15:31 +0200
changeset 7 8bac7aac665c
child 35 638eb0763e20
permissions -rw-r--r--
Display can now be opened, closed and reopened thanks to the following fixes.
Fixing issue with non-virtual destructor.
Fixing issue with deletion of void pointer.
sl@0
     1
#ifndef HID_REPORT_H
sl@0
     2
#define HID_REPORT_H
sl@0
     3
sl@0
     4
#include <string.h>
sl@0
     5
sl@0
     6
/**
sl@0
     7
Define an HID report.
sl@0
     8
Can be used as input and output.
sl@0
     9
*/
sl@0
    10
template <int S>
sl@0
    11
class HidReport
sl@0
    12
    {
sl@0
    13
public:
sl@0
    14
    HidReport(){Reset();}
sl@0
    15
    void Reset();
sl@0
    16
    inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];}
sl@0
    17
    const unsigned char* Buffer() const {return iBuffer;}
sl@0
    18
    unsigned char* Buffer() {return iBuffer;}
sl@0
    19
    int Size() {return S;}
sl@0
    20
protected:
sl@0
    21
    unsigned char iBuffer[S];
sl@0
    22
    };
sl@0
    23
sl@0
    24
template <int S>
sl@0
    25
void HidReport<S>::Reset()
sl@0
    26
    {
sl@0
    27
    memset(iBuffer,0,sizeof(iBuffer));
sl@0
    28
    }
sl@0
    29
sl@0
    30
sl@0
    31
#endif