bluetoothengine/bthid/keyboard/inc/finder.h
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Declares main application class.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __FINDER_H
       
    20 #define __FINDER_H
       
    21 
       
    22 #include <e32std.h>
       
    23 #include "hidreportroot.h"
       
    24 
       
    25 // ----------------------------------------------------------------------
       
    26 
       
    27 /**
       
    28  *  Field finder for the ordinary keyboard fields.
       
    29  */
       
    30 class TKeyboardFinder : public MHidFieldFinder
       
    31     {
       
    32 public:
       
    33     // From MHidFieldFinder
       
    34     virtual TBool BeginCollection(const CCollection *aCollection);
       
    35     virtual TBool EndCollection(const CCollection *aCollection);
       
    36     virtual void Field(const CField* aField);
       
    37 
       
    38 public:
       
    39     /** Constructor */
       
    40     TKeyboardFinder();
       
    41     /**
       
    42      *  Check whether the required fields have been found.
       
    43      *  @return ETrue if they have.
       
    44      */
       
    45     inline TBool Found() const;
       
    46 
       
    47     /**
       
    48      *  Get the field containing the standard keys, if found.
       
    49      *  @return CField* Pointer to the field, or NULL.
       
    50      */
       
    51     const CField* StandardKeyField() const;
       
    52     /**
       
    53      *  Get the field containing the modifier keys, if found.
       
    54      *  @return CField* Pointer to the field, or NULL.
       
    55      */
       
    56     const CField* ModifierKeyField() const;
       
    57     /**
       
    58      *  Get the field containing the LEDs, if found.
       
    59      *  @return CField* Pointer to the field, or NULL.
       
    60      */
       
    61     const CField* LedField() const;
       
    62 
       
    63 private:
       
    64     /**
       
    65      *  Check whether a given field contains the standard keys.
       
    66      *  @param aField Pointer to the field to test.
       
    67      *  @return ETrue if it does.
       
    68      */
       
    69     TBool IsStandardKeys(const CField* aField) const;
       
    70     /**
       
    71      *  Check whether a given field contains the modifier keys.
       
    72      *  @param aField Pointer to the field to test.
       
    73      *  @return ETrue if it does.
       
    74      */
       
    75     TBool IsModifiers(const CField* aField) const;
       
    76     /**
       
    77      *  Check whether a given field contains the LEDs.
       
    78      *  @param aField Pointer to the field to test.
       
    79      *  @return ETrue if it does.
       
    80      */
       
    81     TBool IsLeds(const CField* aField) const;
       
    82 
       
    83 private:
       
    84     /** Pointer to the field containing the standard keys. */
       
    85     const CField* iStandardKeys;
       
    86     /** Pointer to the field containing the modifier keys. */
       
    87     const CField* iModifierKeys;
       
    88     /** Pointer to the field containing the LEDs. */
       
    89     const CField* iLeds;
       
    90 
       
    91     /** Pointer to the top level application collection being searched. */
       
    92     const CCollection* iAppCollection;
       
    93     };
       
    94 
       
    95 /**
       
    96  *  Field finder for the consumer/multimedia keys field.
       
    97  */
       
    98 class TConsumerKeysFinder : public MHidFieldFinder
       
    99     {
       
   100 public:
       
   101     // From MHidFieldFinder
       
   102     virtual TBool BeginCollection(const CCollection *aCollection);
       
   103     virtual TBool EndCollection(const CCollection *aCollection);
       
   104     virtual void Field(const CField* aField);
       
   105 
       
   106 public:
       
   107     /** Constructor */
       
   108     TConsumerKeysFinder();
       
   109 
       
   110     /**
       
   111      *  Get the field containing the consumer keys, if found.
       
   112      *  @return CField* Pointer to the field, or NULL.
       
   113      */
       
   114     inline const CField* ConsumerKeysField() const;
       
   115     /**
       
   116      *  Check whether the consumer keys field has been found.
       
   117      *  @return ETrue if it has.
       
   118      */
       
   119     inline TBool Found() const;
       
   120 
       
   121 private:
       
   122     /** Pointer to the field containing the consumer keys. */
       
   123     const CField* iField;
       
   124     };
       
   125 
       
   126 /**
       
   127  *  Field finder for the power keys field.
       
   128  */
       
   129 class TPowerKeysFinder : public MHidFieldFinder
       
   130     {
       
   131 public:
       
   132     // From MHidFieldFinder
       
   133     virtual TBool BeginCollection(const CCollection *aCollection);
       
   134     virtual TBool EndCollection(const CCollection *aCollection);
       
   135     virtual void Field(const CField* aField);
       
   136 
       
   137 public:
       
   138     /** Constructor */
       
   139     TPowerKeysFinder();
       
   140 
       
   141     /**
       
   142      *  Get the field containing the power keys, if found.
       
   143      *  @return CField* Pointer to the field, or NULL.
       
   144      */
       
   145     inline const CField* PowerKeysField() const;
       
   146     /**
       
   147      *  Check whether the power keys field has been found.
       
   148      *  @return ETrue if it has.
       
   149      */
       
   150     inline TBool Found() const;
       
   151 
       
   152 private:
       
   153     /** Pointer to the field containing the power keys. */
       
   154     const CField* iField;
       
   155     };
       
   156 
       
   157 // ----------------------------------------------------------------------
       
   158 
       
   159 inline TBool TKeyboardFinder::Found() const
       
   160     {
       
   161     // Standard and modifier key fields are always necessary, but the
       
   162     // LED field is optional:
       
   163     //
       
   164     return iStandardKeys && iModifierKeys;
       
   165     }
       
   166 
       
   167 inline const CField* TKeyboardFinder::StandardKeyField() const
       
   168     {
       
   169     return iStandardKeys;
       
   170     }
       
   171 
       
   172 inline const CField* TKeyboardFinder::ModifierKeyField() const
       
   173     {
       
   174     return iModifierKeys;
       
   175     }
       
   176 
       
   177 inline const CField* TKeyboardFinder::LedField() const
       
   178     {
       
   179     return iLeds;
       
   180     }
       
   181 
       
   182 // ----------------------------------------------------------------------
       
   183 
       
   184 inline const CField* TConsumerKeysFinder::ConsumerKeysField() const
       
   185     {
       
   186     return iField;
       
   187     }
       
   188 
       
   189 inline TBool TConsumerKeysFinder::Found() const
       
   190     {
       
   191     return (iField != 0);
       
   192     }
       
   193 
       
   194 // ----------------------------------------------------------------------
       
   195 
       
   196 inline const CField* TPowerKeysFinder::PowerKeysField() const
       
   197     {
       
   198     return iField;
       
   199     }
       
   200 
       
   201 inline TBool TPowerKeysFinder::Found() const
       
   202     {
       
   203     return (iField != 0);
       
   204     }
       
   205 
       
   206 // ----------------------------------------------------------------------
       
   207 /**
       
   208  *  Field finder for the ordinary mouse fields.
       
   209  */
       
   210 class TMouseFinder : public MHidFieldFinder
       
   211     {
       
   212 public:
       
   213     // From MHidFieldFinder
       
   214     virtual TBool BeginCollection(const CCollection *aCollection);
       
   215     virtual TBool EndCollection(const CCollection *aCollection);
       
   216     virtual void Field(const CField* aField);
       
   217 
       
   218 public:
       
   219     /** Constructor */
       
   220     TMouseFinder();
       
   221 
       
   222     /**
       
   223      *  Get the field containing the standard keys, if found.
       
   224      *  @return CField* Pointer to the field, or NULL.
       
   225      */
       
   226     inline const CField* ButtonsField() const;
       
   227     /**
       
   228      *  Get the field containing the xy field, if found.
       
   229      *  @return CField* Pointer to the field, or NULL.
       
   230      */
       
   231     inline const CField* XYField() const;
       
   232     /**
       
   233      *  Get the field containing the wheel info, if found.
       
   234      *  @return CField* Pointer to the field, or NULL.
       
   235      */
       
   236     inline const CField* WheelField() const;
       
   237     /**
       
   238      *  Check whether the required fields have been found.
       
   239      *  @return ETrue if they have.
       
   240      */
       
   241     inline TBool Found() const;
       
   242 
       
   243     /**
       
   244      *  Check whether a given field contains the XY Coordinates
       
   245      *  @param aField Pointer to the field to test.
       
   246      *  @return ETrue if it does.
       
   247      */
       
   248     TBool IsXY(const CField* aField) const;
       
   249     /**
       
   250      *  Check whether a given field contains the Buttons.
       
   251      *  @param aField Pointer to the field to test.
       
   252      *  @return ETrue if it does.
       
   253      */
       
   254     TBool IsButtons(const CField* aField) const;
       
   255     /**
       
   256      *  Check whether a given field contains a wheel.
       
   257      *  @param aField Pointer to the field to test.
       
   258      *  @return ETrue if it does.
       
   259      */
       
   260     TBool IsWheel(const CField* aField) const;
       
   261 
       
   262 private:
       
   263     /** Pointer to the field containing the XY pointer info. */
       
   264     const CField* iXY;
       
   265 
       
   266     /** Pointer to the field containing the buttons. */
       
   267     const CField* iButtons;
       
   268 
       
   269     /** Pointer to the field containing the Wheel info. */
       
   270     const CField* iWheel;
       
   271 
       
   272     /** Pointer to the top level application collection being searched. */
       
   273     const CCollection* iAppCollection;
       
   274     };
       
   275 // ----------------------------------------------------------------------
       
   276 
       
   277 inline TBool TMouseFinder::Found() const
       
   278     {
       
   279     // Standard and modifier key fields are always necessary, but the
       
   280     // Wheel field is optional:
       
   281     //
       
   282     return iButtons && iXY;
       
   283     }
       
   284 
       
   285 inline const CField* TMouseFinder::ButtonsField() const
       
   286     {
       
   287     return iButtons;
       
   288     }
       
   289 
       
   290 inline const CField* TMouseFinder::XYField() const
       
   291     {
       
   292     return iXY;
       
   293     }
       
   294 
       
   295 inline const CField* TMouseFinder::WheelField() const
       
   296     {
       
   297     return iWheel;
       
   298     }
       
   299 #endif