Update contrib.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32utils\profiler\profiler.h
16 // WARNING: This file contains some APIs which are internal and are subject
17 // to change without notice. Such APIs should therefore not be used
18 // outside the Kernel and Hardware Services package.
27 _LIT(KProfilerName,"Profiler");
30 The Profiler class provides a functional interface to the sampling profiler. <p>
31 The engine must already be running for this interface to work, this can be
32 achieved by executing PROFILER.EXE. The control methods are all static, and
33 require no other context.
37 class Profiler : private RSessionBase
40 enum TState {EStart, EStop, EClose, EUnload};
42 /** Start the sampler */
43 static inline TInt Start();
44 /** Stop the sampler */
45 static inline TInt Stop();
46 /** Release the sample trace file */
47 static inline TInt Close();
48 /** Unload the profile engine from memory */
49 static inline TInt Unload();
51 /** Issue a control request to the engine */
52 static inline TInt Control(TState aRequest);
57 inline Profiler::Profiler()
60 inline TInt Profiler::Control(TState aRequest)
62 // Connect to the profiler engine, and issue the control request if successful
66 TInt r = p.CreateSession(KProfilerName, TVersion(), 0);
69 p.SendReceive(aRequest);
70 p.RSessionBase::Close();
75 inline TInt Profiler::Start()
76 {return Control(EStart);}
78 inline TInt Profiler::Stop()
79 {return Control(EStop);}
81 inline TInt Profiler::Close()
82 {return Control(EClose);}
84 inline TInt Profiler::Unload()
85 {return Control(EUnload);}
90 * This is an internal interface to the profiling engine which allows
91 * an additional control DLL to be loaded, replacing the profiler's
96 Implementation class providing access to the profiler engine
100 class MProfilerEngine
103 virtual TInt Control(Profiler::TState aCommand) =0;
104 virtual Profiler::TState State() const =0;
108 The interface that the extra controller must implement to access the profiler.
112 class MProfilerController
115 /** Release the controller from the profiler. This is invoked when the profiler is unloading. */
116 virtual void Release() =0;
117 /** Ask the profiler to change state */
118 inline TInt Control(Profiler::TState aCommand) const;
119 /* Query the profiler state */
120 inline Profiler::TState GetState() const;
122 inline MProfilerController(MProfilerEngine& aEngine);
124 MProfilerEngine& iEngine;
127 /** The signature of ordinal 1 in the controller DLL */
128 typedef MProfilerController* (*TProfilerControllerFactoryL)(TInt aPriority, MProfilerEngine& aEngine);
130 /** The second UID required by the controller DLL */
131 const TUid KUidProfilerKeys={0x1000945c};
134 inline MProfilerController::MProfilerController(MProfilerEngine& aEngine)
137 inline TInt MProfilerController::Control(Profiler::TState aCommand) const
138 {return iEngine.Control(aCommand);}
139 inline Profiler::TState MProfilerController::GetState() const
140 {return iEngine.State();}