memspy/Engine/Source/SysMemTracker/MemSpyEngineHelperSysMemTracker.cpp
changeset 0 a03f92240627
child 30 86a2e675b80a
equal deleted inserted replaced
-1:000000000000 0:a03f92240627
       
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <memspy/engine/memspyenginehelpersysmemtracker.h>
       
    19 
       
    20 // User includes
       
    21 #include <memspy/engine/memspyengine.h>
       
    22 #include "MemSpyEngineHelperSysMemTrackerImp.h"
       
    23 #include <memspy/engine/memspyenginehelpersysmemtrackercycle.h>
       
    24 #include <memspy/engine/memspyenginehelpersysmemtrackerobserver.h>
       
    25 #include "MemSpyEngineHelperSysMemTrackerOutputFormatter.h"
       
    26 
       
    27 
       
    28 CMemSpyEngineHelperSysMemTracker::CMemSpyEngineHelperSysMemTracker()
       
    29     {
       
    30     }
       
    31 
       
    32     
       
    33 CMemSpyEngineHelperSysMemTracker::~CMemSpyEngineHelperSysMemTracker()
       
    34     {
       
    35     delete iOutputFormatter;
       
    36     delete iImp;
       
    37     }
       
    38 
       
    39 
       
    40 void CMemSpyEngineHelperSysMemTracker::ConstructL( CMemSpyEngine& aEngine )
       
    41     {
       
    42     iOutputFormatter = CMemSpyEngineHelperSysMemTrackerOutputFormatter::NewL( aEngine );
       
    43     //
       
    44     iImp = CMemSpyEngineHelperSysMemTrackerImp::NewL( aEngine );
       
    45     iImp->SetObserver( this );
       
    46     }
       
    47 
       
    48 
       
    49 CMemSpyEngineHelperSysMemTracker* CMemSpyEngineHelperSysMemTracker::NewL( CMemSpyEngine& aEngine )
       
    50     {
       
    51     CMemSpyEngineHelperSysMemTracker* self = new(ELeave) CMemSpyEngineHelperSysMemTracker();
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL( aEngine );
       
    54     CleanupStack::Pop( self );
       
    55     return self;
       
    56     }
       
    57 
       
    58 
       
    59 EXPORT_C TBool CMemSpyEngineHelperSysMemTracker::IsActive() const
       
    60     {
       
    61     return iImp->IsActive();
       
    62     }
       
    63 
       
    64 
       
    65 EXPORT_C void CMemSpyEngineHelperSysMemTracker::StartL()
       
    66     {
       
    67     const TMemSpyEngineHelperSysMemTrackerConfig& config = iOutputFormatter->Config();
       
    68     iImp->StartL( config );
       
    69     }
       
    70 
       
    71 
       
    72 EXPORT_C void CMemSpyEngineHelperSysMemTracker::StartL( const TMemSpyEngineHelperSysMemTrackerConfig& aConfig )
       
    73     {
       
    74     SetConfigL( aConfig );
       
    75     StartL();
       
    76     }
       
    77 
       
    78 
       
    79 EXPORT_C void CMemSpyEngineHelperSysMemTracker::StopL()
       
    80     {
       
    81     iImp->StopL();
       
    82     }
       
    83 
       
    84 
       
    85 EXPORT_C void CMemSpyEngineHelperSysMemTracker::SetConfigL( const TMemSpyEngineHelperSysMemTrackerConfig& aConfig )
       
    86     {
       
    87     TMemSpyEngineHelperSysMemTrackerConfig config( aConfig );
       
    88 
       
    89     // Cap the value to ensure it doesn't fall beneath minimum value.
       
    90     const TInt timeInSeconds = config.TimerPeriod().Int() / 1000000;
       
    91     if  ( timeInSeconds < KMemSpySysMemTrackerConfigMinTimerPeriod )
       
    92         {
       
    93         config.iTimerPeriod = KMemSpySysMemTrackerConfigMinTimerPeriod * 1000000;
       
    94         }
       
    95     iOutputFormatter->SetConfig( config );
       
    96     }
       
    97 
       
    98 
       
    99 EXPORT_C void CMemSpyEngineHelperSysMemTracker::GetConfig( TMemSpyEngineHelperSysMemTrackerConfig& aConfig )
       
   100     {
       
   101     aConfig = iOutputFormatter->Config();
       
   102     }
       
   103 
       
   104 
       
   105 EXPORT_C void CMemSpyEngineHelperSysMemTracker::SetObserver( MMemSpyEngineHelperSysMemTrackerObserver* aObserver )
       
   106     {
       
   107     iRealObserver = aObserver;
       
   108     }
       
   109 
       
   110 
       
   111 EXPORT_C void CMemSpyEngineHelperSysMemTracker::RemoveObserver( MMemSpyEngineHelperSysMemTrackerObserver* aObserver )
       
   112     {
       
   113     if ( iRealObserver == aObserver )
       
   114         {
       
   115         iRealObserver = NULL;
       
   116         }
       
   117     }
       
   118 
       
   119 
       
   120 EXPORT_C const RPointerArray< CMemSpyEngineHelperSysMemTrackerCycle >& CMemSpyEngineHelperSysMemTracker::CompletedCycles() const
       
   121     {
       
   122     return iImp->CompletedCycles();
       
   123     }
       
   124 
       
   125 
       
   126 void CMemSpyEngineHelperSysMemTracker::Reset()
       
   127     {
       
   128     iImp->Reset();
       
   129     }
       
   130 
       
   131 
       
   132 void CMemSpyEngineHelperSysMemTracker::CheckForChangesNowL()
       
   133     {
       
   134     iImp->CheckForChangesNowL();
       
   135     }
       
   136 
       
   137 
       
   138 EXPORT_C TInt CMemSpyEngineHelperSysMemTracker::MdcaCount() const
       
   139     {
       
   140     return iImp->MdcaCount();
       
   141     }
       
   142 
       
   143 
       
   144 EXPORT_C TPtrC CMemSpyEngineHelperSysMemTracker::MdcaPoint( TInt aIndex ) const
       
   145     {
       
   146     return iImp->MdcaPoint( aIndex );
       
   147     }
       
   148 
       
   149 
       
   150 void CMemSpyEngineHelperSysMemTracker::HandleCyclesResetL()
       
   151     {
       
   152     if  ( iRealObserver )
       
   153         {
       
   154         TRAP_IGNORE( iRealObserver->HandleCyclesResetL() );
       
   155         }
       
   156     }
       
   157 
       
   158 
       
   159 void CMemSpyEngineHelperSysMemTracker::HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle )
       
   160     {
       
   161     if  ( iRealObserver )
       
   162         {
       
   163         TRAP_IGNORE( iRealObserver->HandleCycleStartedL( aCycle ) );
       
   164         }
       
   165     }
       
   166 
       
   167 void CMemSpyEngineHelperSysMemTracker::HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle )
       
   168     {
       
   169     iOutputFormatter->OutputL( aCycle );
       
   170     //
       
   171     if  ( iRealObserver )
       
   172         {
       
   173         TRAP_IGNORE( iRealObserver->HandleCycleFinishedL( aCycle ) );
       
   174         }
       
   175     }
       
   176 
       
   177 
       
   178 
       
   179