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 PROFILERGENERICCLASSESUSR_H |
|
20 #define PROFILERGENERICCLASSESUSR_H |
|
21 |
|
22 #include <piprofiler/ProfilerConfig.h> |
|
23 #include <piprofiler/ProfilerVersion.h> |
|
24 #include <piprofiler/ProfilerGenericClassesCommon.h> |
|
25 #include <piprofiler/PluginSampler.h> |
|
26 #include <piprofiler/WriterPluginInterface.h> |
|
27 |
|
28 #include <e32cmn.h> |
|
29 #include <e32std.h> |
|
30 #include <f32file.h> |
|
31 |
|
32 |
|
33 /* |
|
34 * |
|
35 * Class MProfilerBufferHandlerObserver definition |
|
36 * |
|
37 */ |
|
38 class MProfilerBufferHandlerObserver |
|
39 { |
|
40 public: |
|
41 virtual TBapBuf* GetNextFreeBuffer() = 0; |
|
42 virtual void AddToFilledBuffers(TBapBuf* aFilledBuffer) = 0; |
|
43 }; |
|
44 |
|
45 /* |
|
46 * |
|
47 * Class CProfilerBufferHandler definition |
|
48 * |
|
49 */ |
|
50 // forward declarations |
|
51 class CProfilerSampleStream; |
|
52 |
|
53 class CProfilerBufferHandler : public CActive |
|
54 { |
|
55 public: |
|
56 static CProfilerBufferHandler* CProfilerBufferHandler::NewL(CProfilerSampleStream& aStream, RPluginSampler& aSampler); |
|
57 CProfilerBufferHandler(CProfilerSampleStream& aStream, RPluginSampler& aSampler); |
|
58 ~CProfilerBufferHandler(); |
|
59 |
|
60 void ConstructL(); |
|
61 |
|
62 // for plugins to start receiving trace data |
|
63 void StartReceivingData(); |
|
64 private: |
|
65 void RunL(); |
|
66 TInt RunError(TInt aError); |
|
67 void DoCancel(); |
|
68 void HandleEndOfStream(); |
|
69 public: |
|
70 TInt iFinished; |
|
71 private: |
|
72 RPluginSampler& iSampler; |
|
73 TBapBuf* iBufferInProcess; |
|
74 TBool iEndOfStreamDetected; |
|
75 |
|
76 CProfilerSampleStream& iObserver; |
|
77 }; |
|
78 |
|
79 /* |
|
80 * |
|
81 * Class CProfilerSampleStream definition |
|
82 * |
|
83 */ |
|
84 class CWriterPluginInterface; |
|
85 |
|
86 class CProfilerSampleStream : public CBase, MProfilerBufferHandlerObserver |
|
87 { |
|
88 public: |
|
89 static CProfilerSampleStream* CProfilerSampleStream::NewL(TInt aBufSize); |
|
90 ~CProfilerSampleStream(); |
|
91 |
|
92 void ConstructL(); |
|
93 |
|
94 void Finalise(); |
|
95 void EmptyBuffers(); |
|
96 inline void AddToFreeBuffers(TBapBuf* freeBuffer); |
|
97 void SetWriter(CWriterPluginInterface& aWriter); |
|
98 |
|
99 // from MProfilerBufferHandlerObserver |
|
100 TBapBuf* GetNextFreeBuffer(); |
|
101 void AddToFilledBuffers(TBapBuf* aFilledBuffer); |
|
102 inline TBapBuf* GetNextFilledBuffer(); |
|
103 void ResetBuffers(); |
|
104 void InitialiseBuffers(); |
|
105 inline void NotifyWriter(); |
|
106 private: |
|
107 CProfilerSampleStream(TInt aBufSize); |
|
108 |
|
109 |
|
110 public: |
|
111 TInt iFinished; |
|
112 CWriterPluginInterface* iWriter; |
|
113 private: |
|
114 TInt iBufferSize; |
|
115 TBapBuf* iFreeBuffers; |
|
116 TBapBuf* iFilledBuffers; |
|
117 }; |
|
118 |
|
119 #include <piprofiler/ProfilerGenericClassesUsr.inl> |
|
120 |
|
121 #endif |
|