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.
     1 #ifndef HID_REPORT_H
     2 #define HID_REPORT_H
     3 
     4 #include <string.h>
     5 
     6 /**
     7 Define an HID report.
     8 Can be used as input and output.
     9 */
    10 template <int S>
    11 class HidReport
    12     {
    13 public:
    14     HidReport(){Reset();}
    15     void Reset();
    16     inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];}
    17     const unsigned char* Buffer() const {return iBuffer;}
    18     unsigned char* Buffer() {return iBuffer;}
    19     int Size() {return S;}
    20 protected:
    21     unsigned char iBuffer[S];
    22     };
    23 
    24 template <int S>
    25 void HidReport<S>::Reset()
    26     {
    27     memset(iBuffer,0,sizeof(iBuffer));
    28     }
    29 
    30 
    31 #endif