uiacceltk/hitchcock/tsrc/alfdebugextension/src/alfdebug.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c)  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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "alfdebugimpl.h"
       
    20 #include "alfdebugextensionconstants.h"
       
    21 #include "alfdebuguid.h"
       
    22 #include <alf/alfgencomponent.h>
       
    23 #include <alf/alfenv.h>
       
    24 
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // ?description_if_needed
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CAlfDebugExtensionImpl::CAlfDebugExtensionImpl()
       
    33     {
       
    34     }
       
    35 
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // ?description_if_needed
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 void CAlfDebugExtensionImpl::ConstructL( CAlfEnv& aEnv )
       
    42     {
       
    43     iEnv = &aEnv;
       
    44     
       
    45     TRAP_IGNORE( 
       
    46       iComms =
       
    47         CAlfGenComponent::NewL( 
       
    48             aEnv,
       
    49             EAlfDebugExtensionCreateDebug,
       
    50             KAlfDebugExtensionImplementationId,
       
    51             KNullDesC8 ) );
       
    52     }
       
    53 
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // ?description_if_needed
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CAlfDebugExtensionImpl* CAlfDebugExtensionImpl::NewL( CAlfEnv& aEnv )
       
    60     {
       
    61     CAlfDebugExtensionImpl* self = new( ELeave ) CAlfDebugExtensionImpl;
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL(aEnv);
       
    64     CleanupStack::Pop( self );
       
    65     return self;
       
    66     }
       
    67 
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // ?description_if_needed
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CAlfDebugExtensionImpl::~CAlfDebugExtensionImpl()
       
    74     {
       
    75     delete iComms;
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // ?implementation_description
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CAlfDebugExtensionImpl::SetTimeFactor(TReal32 aTimeFactor)
       
    83     {
       
    84     TPckgC<TReal32> inParams(aTimeFactor);
       
    85     if ( iComms )
       
    86         {
       
    87         iComms->DoCmdNoReply( EAlfDebugCmdSetTimeFactor, inParams );
       
    88         }
       
    89     return;
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // ?implementation_description
       
    94 // ---------------------------------------------------------------------------
       
    95 //    
       
    96 TReal32 CAlfDebugExtensionImpl::TimeFactor()
       
    97     {
       
    98     TReal32 result(1.f);
       
    99     if ( iComms )
       
   100         {
       
   101         TPckg<TReal32> outParams(result);
       
   102         iComms->DoSynchronousCmd( EAlfDebugCmdGetTimeFactor, KNullDesC8(), outParams );
       
   103         }
       
   104     return result;
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // ?implementation_description
       
   109 // ---------------------------------------------------------------------------
       
   110 //    
       
   111 TUint CAlfDebugExtensionImpl::FrameCount()
       
   112     {
       
   113     TUint result(0);
       
   114     if ( iComms )
       
   115         {
       
   116         TPckg<TUint> outParams(result);
       
   117         iComms->DoSynchronousCmd( EAlfDebugCmdGetFrameCount, KNullDesC8(), outParams );
       
   118         }
       
   119     return result;
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // ?implementation_description
       
   124 // ---------------------------------------------------------------------------
       
   125 //    
       
   126 TReal32 CAlfDebugExtensionImpl::FrameRate()
       
   127     {
       
   128     TReal32 result(0.f);
       
   129     if ( iComms )
       
   130         {
       
   131         TPckg<TReal32> outParams(result);
       
   132         iComms->DoSynchronousCmd( EAlfDebugCmdGetFrameRate, KNullDesC8(), outParams );
       
   133         }
       
   134     return result;
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // ?implementation_description
       
   139 // ---------------------------------------------------------------------------
       
   140 //     
       
   141 void CAlfDebugExtensionImpl::ShowFrameRate( TInt aInterval )
       
   142     {
       
   143     TPckgC<TInt> inParams(aInterval);
       
   144     if ( iComms )
       
   145         {
       
   146         iComms->DoCmdNoReply( EAlfDebugCmdShowFrameRate, inParams );
       
   147         }
       
   148     return;
       
   149     }
       
   150     
       
   151 void CAlfDebugExtensionImpl::ShowServerHeapUsage( TBool aShow )
       
   152     {
       
   153     TPckgC<TBool> inParams(aShow);
       
   154     if ( iComms )
       
   155         {
       
   156         iComms->DoCmdNoReply( EAlfDebugCmdShowServerHeap, inParams );
       
   157         }
       
   158     return;
       
   159     }
       
   160     
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // Get measurements from the server side.
       
   164 // ---------------------------------------------------------------------------
       
   165 //     
       
   166 TInt CAlfDebugExtensionImpl::GetMeasurements( 
       
   167         TAlfDebugServerMeasurements& aResult )
       
   168     {
       
   169     TInt err = KErrServerTerminated;
       
   170     
       
   171     if ( iComms )
       
   172         {
       
   173         TPckg<TAlfDebugServerMeasurements> outParams( aResult );
       
   174         err = iComms->DoSynchronousCmd( 
       
   175             EAlfDebugCmdMeasure, 
       
   176             KNullDesC8(), 
       
   177             outParams );
       
   178         }
       
   179         
       
   180     return err;
       
   181     }
       
   182     
       
   183 CAlfDebugFactoryImpl::~CAlfDebugFactoryImpl()
       
   184     {
       
   185     delete iOwnEnv;
       
   186     }
       
   187     
       
   188 CAlfDebugExtension* CAlfDebugFactoryImpl::CreateDebugExtensionL( CAlfEnv* aEnv )
       
   189     {
       
   190     CAlfEnv* usedEnv = aEnv;
       
   191     
       
   192     if ( !usedEnv )
       
   193         {
       
   194         // check static
       
   195         usedEnv = CAlfEnv::Static();
       
   196         if ( !usedEnv )
       
   197             {
       
   198             // create own
       
   199             iOwnEnv = CAlfEnv::NewL();
       
   200             usedEnv = iOwnEnv;
       
   201             }
       
   202         }
       
   203     
       
   204     return CAlfDebugExtensionImpl::NewL( *usedEnv );
       
   205     }
       
   206 
       
   207 
       
   208 EXPORT_C CAlfDebugFactory* CreateDebugExtensionFactoryL()
       
   209     {
       
   210     return new (ELeave) CAlfDebugFactoryImpl;
       
   211     }