localconnectivityservice/generichid/inc/hidreportgenerator.h
branchRCL_3
changeset 19 0aa8cc770c8a
equal deleted inserted replaced
18:453dfc402455 19:0aa8cc770c8a
       
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Report generator
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_REPORT_GENERATOR_H
       
    19 #define C_REPORT_GENERATOR_H
       
    20 
       
    21 #include "hidreportroot.h"
       
    22 #include "hidtranslate.h"
       
    23 
       
    24 /**
       
    25  * HID report generator
       
    26  *
       
    27  * Class used for generating output or feature reports to send to the device.
       
    28  *
       
    29  * @lib  generichid.lib
       
    30  * @since S60 v5.0
       
    31  */
       
    32 class CReportGenerator : public CBase
       
    33     {
       
    34 public:
       
    35     /**
       
    36      * Constructs a CReportGenerator.
       
    37      *
       
    38      * @since S60 v5.0
       
    39      * @param aReportRoot Tree generated by CParser from the report
       
    40      *                    descriptor.
       
    41      * @param aReportId Report ID of the report to generate.
       
    42      * @param aType Type of report to generate (output or feature).
       
    43      */
       
    44     IMPORT_C static CReportGenerator* NewLC(const CReportRoot* aReportRoot,
       
    45         TInt aReportId, CField::TType aType);
       
    46 
       
    47     /**
       
    48      * Constructs a CReportGenerator.
       
    49      *
       
    50      * @since S60 v5.0
       
    51      * @param aReportRoot Tree generated by CParser from the report
       
    52      *                    descriptor.
       
    53      * @param aReportId Report ID of the report to generate.
       
    54      * @param aType Type of report to generate (output or feature).
       
    55      */
       
    56     IMPORT_C static CReportGenerator* NewL(const CReportRoot* aReportRoot,
       
    57         TInt aReportId, CField::TType aType);
       
    58 
       
    59     virtual ~CReportGenerator();
       
    60 
       
    61     /**
       
    62      * Sets the value of a single field in the report.  Stores the requested
       
    63      * control value in a field in the report buffer.  For array fields, adds
       
    64      * the requested usage ID to the array.
       
    65      *
       
    66      * @since S60 v5.0
       
    67      * @param aField Pointer to the field in which to set a value.
       
    68      * @param aUsageId Usage ID of the control to set.
       
    69      * @param aValue Value to write to the field, used for variable
       
    70      *               fields only.
       
    71      * @param aControlOffset Which control to set when more than one
       
    72      *                       have the same usage ID.
       
    73      * @return Error code indicating success or reason for failure.
       
    74      */
       
    75     IMPORT_C TInt SetField(const CField* aField, TInt aUsageId, TInt aValue,
       
    76         TInt aControlOffset = 0);
       
    77 
       
    78     /**
       
    79      * Get the buffer holding the generated report
       
    80      *
       
    81      * @since S60 v5.0
       
    82      * @return pointer to buffer
       
    83      */
       
    84     IMPORT_C TPtr8 Report();
       
    85 
       
    86 private:
       
    87     /**
       
    88      * Constructor for CReportGenerator.
       
    89      *
       
    90      * @since S60 v5.0
       
    91      * @param aReportId Report ID of the report to generate.
       
    92      * @param aType Type of report to generate (output or feature).
       
    93      */
       
    94     CReportGenerator(TInt aReportId, CField::TType aType);
       
    95 
       
    96     /**
       
    97      * 2nd phase constructor for CReportGenerator.  Allocates the
       
    98      * report buffer iBuf.
       
    99      *
       
   100      * @since S60 v5.0
       
   101      * @param aReportRoot Tree generated by CParser from the report
       
   102      *                    descriptor.
       
   103      */
       
   104     void ConstructL(const CReportRoot* aReportRoot);
       
   105 
       
   106     /**
       
   107      * Report ID of the report to generate
       
   108      */
       
   109     TInt iReportId;
       
   110 
       
   111     /**
       
   112      * Type of report to generate
       
   113      */
       
   114     CField::TType iType;
       
   115 
       
   116     /**
       
   117      * Tree of fields from the report descriptor
       
   118      * Not own.
       
   119      */
       
   120     const CReportRoot* iReportRoot;
       
   121 
       
   122     /**
       
   123      * Buffer to hold the generated report
       
   124      * Own.
       
   125      */
       
   126     HBufC8* iBuf;
       
   127     };
       
   128 
       
   129 #endif  // __REPORT_GENERATOR_H__