|
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: Logic for bufferred publish and subcribe notifier |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_SPSBUFFEREDPUBLISHER_H |
|
19 #define C_SPSBUFFEREDPUBLISHER_H |
|
20 |
|
21 #include <e32base.h> |
|
22 |
|
23 /** |
|
24 * P&S ringbuffer implementation |
|
25 * |
|
26 * Ringbuffer size is 127 TUint32:s |
|
27 * |
|
28 * @code |
|
29 * Publisher: |
|
30 * CSpsBufferedPublisher::SetL( KCategory, KKey, data ); |
|
31 * |
|
32 * Subscriber: |
|
33 * - start to fill buffer |
|
34 * iMember = CSpsBufferedPublisher::NewL( KCategory, KKey ); |
|
35 * iMember->Start(); |
|
36 * |
|
37 * - when changed data is read |
|
38 * RArray<TUint32> array; |
|
39 * iMember->GetL( array ); |
|
40 * // Do something with data |
|
41 * array.Close(); |
|
42 * |
|
43 * @endcode |
|
44 * |
|
45 * @lib serviceprovidersettings.lib |
|
46 */ |
|
47 NONSHARABLE_CLASS( CSpsBufferedPublisher ): public CBase |
|
48 { |
|
49 public: // Publisher methods |
|
50 /** |
|
51 * ?description |
|
52 * |
|
53 * @param aCategory P&S Category |
|
54 * @param aKey P&S key |
|
55 * @param aData Data to be published |
|
56 */ |
|
57 static void SetL( TUid aCategory, TUint aKey, TUint32 aData ); |
|
58 |
|
59 public: // Subscriber methods |
|
60 |
|
61 /** |
|
62 * Creates P&S key if not yet created. |
|
63 * |
|
64 * Two-phased constructor. |
|
65 * @param aCategory P&S Category |
|
66 * @param aKey P&S key |
|
67 */ |
|
68 static CSpsBufferedPublisher* NewL( TUid aCategory, TUint aKey ); |
|
69 |
|
70 /** |
|
71 * Destructor. |
|
72 */ |
|
73 virtual ~CSpsBufferedPublisher(); |
|
74 |
|
75 /** |
|
76 * Start logging of buffer changes |
|
77 * Must be stopped before it can start from current position |
|
78 */ |
|
79 void Start(); |
|
80 |
|
81 /** |
|
82 * Stop logging of buffer changes |
|
83 */ |
|
84 void Stop(); |
|
85 |
|
86 /** |
|
87 * Get logged P&S data |
|
88 * |
|
89 * @param aData Changed data since last get |
|
90 * @leave KErrNotReady if not started |
|
91 */ |
|
92 void GetL( RArray<TUint32>& aData ); |
|
93 |
|
94 private: |
|
95 |
|
96 CSpsBufferedPublisher( TUid aCategory, TUint aKey ); |
|
97 |
|
98 void ConstructL(); |
|
99 |
|
100 private: |
|
101 |
|
102 static void SignalAndCloseSemaphore( TAny* aPtr ); |
|
103 |
|
104 static TUint32& At( TDes8& aData, TInt aIndex ); |
|
105 |
|
106 static TUint Max( TDesC8& aData ); |
|
107 |
|
108 static TInt32 Base( TDesC8& aData, TInt aIndex ); |
|
109 |
|
110 static TUint32& GlobalIndex( TDes8& aData ); |
|
111 |
|
112 private: // data |
|
113 |
|
114 TUid iCategory; |
|
115 TUint iKey; |
|
116 TInt iIndex; |
|
117 |
|
118 }; |
|
119 |
|
120 |
|
121 #endif // C_CSPSBUFFEREDPUBLISHER_H |