Symbian3/SDK/Source/GUID-047E3462-F806-4C54-9DC5-6B78907CA949.dita
changeset 0 89d6a7a84779
equal deleted inserted replaced
-1:000000000000 0:89d6a7a84779
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE task
       
    11   PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
       
    12 <task id="GUID-047E3462-F806-4C54-9DC5-6B78907CA949" xml:lang="en"><title>Derive
       
    13 a class and implement the appropriate observer functions</title><prolog><metadata><keywords/></metadata></prolog><taskbody>
       
    14 <context>       <p>Derive a class from one or more of the observer interfaces
       
    15 above, and implement the appropriate observer functions.</p><p>The following
       
    16 code snippet demonstrates how to derive a class and implement the appropriate
       
    17 functions.</p><codeblock id="GUID-FF4BD289-9ECC-5E01-A38C-3E428817883E" xml:space="preserve">#include HWRMPower.h
       
    18 Class CPowerApp : public CBase,
       
    19                   public MHWRMBatteryPowerObserver,
       
    20                   public MHWRMBatteryChargingStatusObserver
       
    21 {
       
    22 public:
       
    23     CPowerApp(); //constructor
       
    24     ~CPowerApp();  //destructor
       
    25     void ConstructL();
       
    26     static CPowerApp* NewL();
       
    27     // from MHWRMBatteryPowerObserver
       
    28     virtual void PowerMeasurement( TInt aErr,
       
    29                                    TInt aMeasurement );
       
    30     // from MHWRMBatteryChargingStatusObserver
       
    31     virtual void ChargingStatusChange( Tint aErrCode,
       
    32                                        CHWRMPower::TBatteryChargingStatus aChrgStatus );
       
    33 
       
    34 private:
       
    35     CHWRMPower* iPower;
       
    36 };
       
    37 
       
    38 
       
    39 //Implementation of MHWRMBatteryPowerObserver::PowerMeasurement()
       
    40 
       
    41 void CPowerApp::PowerMeasurement( TInt aErr,
       
    42                                   TInt aMeasurement )
       
    43     {
       
    44     if( aErrorCode == KErrNone )
       
    45          {
       
    46          INFO_PRINTF2( _L( "INFO: Power Consumption Measurement Received,
       
    47                             measurement=%d" ), aMeasurement );
       
    48          }
       
    49     else
       
    50          {
       
    51          INFO_PRINTF2( _L( "INFO: Power Consumption Measurement Error,
       
    52                             error=%d" ), aErr );
       
    53          }
       
    54     }</codeblock></context>
       
    55 </taskbody></task>