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 |
|
19 #ifndef __SAMPLERCONTROLLER_H__ |
|
20 #define __SAMPLERCONTROLLER_H__ |
|
21 |
|
22 // system includes |
|
23 #include <utf.h> |
|
24 #include <e32cmn.h> |
|
25 |
|
26 |
|
27 // The user-interface to the sampling device driver sued by the profiling engine |
|
28 // user includes |
|
29 #include <piprofiler/ProfilerConfig.h> |
|
30 #include <piprofiler/ProfilerVersion.h> |
|
31 #include <piprofiler/SamplerPluginInterface.h> |
|
32 |
|
33 #include "SamplerPluginLoader.h" |
|
34 |
|
35 /* |
|
36 * Forward declarations |
|
37 */ |
|
38 class TBapBuf; |
|
39 class CProfilerSampleStream; |
|
40 class CSamplerPluginLoader; |
|
41 class CSamplerPluginInterface; |
|
42 class MSamplerControllerObserver; |
|
43 /** |
|
44 * The sampler controller for handling the actual sampler plugins. |
|
45 */ |
|
46 |
|
47 class CSamplerController : public CBase, MSamplerPluginLoadObserver |
|
48 { |
|
49 |
|
50 public: |
|
51 static CSamplerController* NewL(CProfilerSampleStream& aStream); |
|
52 void ConstructL(); |
|
53 |
|
54 CSamplerController(CProfilerSampleStream& aStream); |
|
55 ~CSamplerController(); |
|
56 |
|
57 /** |
|
58 * |
|
59 * Methods for user mode sampling |
|
60 * |
|
61 **/ |
|
62 |
|
63 /** Initialise the user mode samplers **/ |
|
64 void InitialiseSamplerListL(); |
|
65 |
|
66 /* Overrider of MSamplerPluginLoaderObserver class **/ |
|
67 void HandlePluginLoaded( KSamplerPluginLoaderStatus aStatus ); |
|
68 |
|
69 /* returns the name matching plugin Uid */ |
|
70 TUid GetPluginUID(TDesC8& name); |
|
71 |
|
72 /** Start enabled samplers **/ |
|
73 void StartSamplerPluginsL(); |
|
74 |
|
75 /** Stop enabled samplers **/ |
|
76 TInt StopSamplerPlugins(); |
|
77 |
|
78 public: |
|
79 |
|
80 CSamplerPluginInterface* GetPlugin(TUid aUid); |
|
81 |
|
82 TInt GetPluginList(TDes* aList); |
|
83 |
|
84 TInt SetSamplerSettingsL(TInt aUid, TSamplerAttributes aAttributes); |
|
85 |
|
86 void GetSamplerAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributes); |
|
87 |
|
88 TInt UpdateSavedSamplerAttributesL(CDesC8ArrayFlat* aSavedLineArray, CArrayFixFlat<TSamplerAttributes>* aAttributes); |
|
89 |
|
90 /* |
|
91 * Compose all sampler (sampler or sub-sampler) attributes as text array for saving to settings file, |
|
92 * called by CSamplerController (and Profiler Engine) |
|
93 * |
|
94 * @param aFile settings file where to write the settings |
|
95 */ |
|
96 void ComposeAttributesToSettingsFileFormat(RFile& aFile, CArrayFixFlat<TSamplerAttributes>* aAttributes); |
|
97 |
|
98 /* |
|
99 * Compose all sampler (sampler or sub-sampler) attributes as text array for saving to settings file, |
|
100 * called by CSamplerController (and Profiler Engine) |
|
101 * |
|
102 * @param aFile settings file where to write the settings |
|
103 * @param aAttrArray is container for saving the text to |
|
104 */ |
|
105 void ComposeSettingsText(RFile& aFile, CArrayFixFlat<TSamplerAttributes>* aAttrArray); |
|
106 |
|
107 void SetObserver(MSamplerControllerObserver* aObserver); |
|
108 |
|
109 void Str2Bool(const TDesC8& aBuf, TBool& aValue); |
|
110 |
|
111 void Str2Int(const TDesC8& aBuf, TInt& aValue); |
|
112 |
|
113 void Str2Int(const TDesC8& aBuf, TUint32& aValue); |
|
114 |
|
115 TBuf8<16> Bool2Str(const TBool& aValue); |
|
116 |
|
117 TBuf8<16> Int2Str(const TInt& aValue); |
|
118 public: |
|
119 |
|
120 CArrayPtrFlat<CSamplerPluginInterface>* iPluginArray; |
|
121 |
|
122 // Asynchronous loader for the sampler plug-ins. |
|
123 CSamplerPluginLoader* iPluginLoader; |
|
124 |
|
125 // UID of the selected plugin in the container's lbx. |
|
126 TUid iSelectedPluginUid; |
|
127 |
|
128 // shared sample stream for all plugin samplers |
|
129 CProfilerSampleStream& iStream; |
|
130 |
|
131 private: |
|
132 MSamplerControllerObserver* iObserver; |
|
133 }; |
|
134 |
|
135 /** |
|
136 * Interface for SamplerPluginLoader observer. MSamplerPluginLoadObserver gets |
|
137 * notifications when plugins are loaded. |
|
138 * |
|
139 * @lib ProfilerEngine.exe/.lib |
|
140 * @since Series60_30.1 |
|
141 */ |
|
142 |
|
143 class MSamplerControllerObserver |
|
144 { |
|
145 public: // New |
|
146 |
|
147 //CSamplerController calls this function when each plug-in is loaded or |
|
148 //loading is finished.. |
|
149 |
|
150 virtual void HandleSamplerControllerReadyL() = 0; |
|
151 virtual void HandleError(TInt aError) = 0; |
|
152 }; |
|
153 |
|
154 #endif // __SAMPLERCONTROLLER_H__ |
|