|
1 /* |
|
2 * Copyright (c) 2008-2008 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: Manages MCP plugins, and content publishing. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_MUSICCONTENTMAP_H |
|
19 #define C_MUSICCONTENTMAP_H |
|
20 |
|
21 #include <liwvariant.h> |
|
22 #include <e32hashtab.h> |
|
23 |
|
24 // CLASS DECLARATION |
|
25 |
|
26 /** |
|
27 * Data class to construct and hold variant values persistently. |
|
28 */ |
|
29 class RMusicContentVariant { |
|
30 public: |
|
31 |
|
32 /** |
|
33 * Constructor |
|
34 * |
|
35 * Constructs a null variant value. |
|
36 */ |
|
37 RMusicContentVariant(); |
|
38 |
|
39 /** |
|
40 * Reset variant to null value. |
|
41 * Frees content. |
|
42 */ |
|
43 void Reset(); |
|
44 |
|
45 /** |
|
46 * Set variant to integer value. |
|
47 * @param New value. |
|
48 * @return Whether the value was changed. |
|
49 * Frees content of previous value. |
|
50 */ |
|
51 TBool SetL( TInt aInt); |
|
52 |
|
53 /** |
|
54 * Set variant to string value. |
|
55 * @param New value. An internal copy of the string is made. |
|
56 * @return Whether the value was changed. |
|
57 * Frees content of previous value. |
|
58 */ |
|
59 TBool SetL( const TDesC& aDesc ); |
|
60 |
|
61 /** |
|
62 * Set variant to map value. |
|
63 * @param New value. Reference counter of the map is increased. |
|
64 * @return Whether the value was changed. |
|
65 * Frees content of previous value. |
|
66 */ |
|
67 TBool SetL( CLiwMap * aMap ); |
|
68 |
|
69 /** |
|
70 * Check whether value has been modified since the last ResetModified. |
|
71 * @return ETrue if value has been modified. |
|
72 */ |
|
73 TBool IsModified() const; |
|
74 |
|
75 /** |
|
76 * Reset modified flag. |
|
77 * After calling this method IsModified returns EFalse. |
|
78 */ |
|
79 void ResetModified(); |
|
80 |
|
81 /** |
|
82 * Return whether the value is null. |
|
83 * @return ETrue if value is null. |
|
84 */ |
|
85 TBool IsNull() const; |
|
86 |
|
87 /** |
|
88 * Return the value as TLiwVariant |
|
89 * @return Value encapsulated in TLiwVariant. |
|
90 */ |
|
91 TLiwVariant LiwVariant() const; |
|
92 |
|
93 private: |
|
94 |
|
95 enum TType {ETypeNull, ETypeInt, ETypeBufC, ETypeMap}; |
|
96 |
|
97 TType iType; // type of the value |
|
98 TBool iModified; // whether value has been modified |
|
99 |
|
100 // Data area |
|
101 union { |
|
102 TInt iInt; |
|
103 HBufC * iBufC; // owned |
|
104 CLiwMap * iMap; // reference counted |
|
105 } iValue; |
|
106 |
|
107 }; |
|
108 |
|
109 // CLASS DECLARATION |
|
110 |
|
111 /** |
|
112 * Persistent map of variable content |
|
113 * |
|
114 * @lib musiccontentpublisher.dll |
|
115 * @since S60 S60 v5.0 |
|
116 */ |
|
117 |
|
118 class RMusicContentMap { |
|
119 public: |
|
120 |
|
121 /** |
|
122 * Constructs an empty map |
|
123 */ |
|
124 RMusicContentMap(); |
|
125 |
|
126 /** |
|
127 * Resets a single value in the map in case it exists |
|
128 * @param aKey The key of the value to be reset |
|
129 * Does nothing if the value does not exist |
|
130 */ |
|
131 void Reset( TPtrC8 aKey ); |
|
132 |
|
133 /** |
|
134 * Sets a string value in the map |
|
135 * @param aKey The key of the value |
|
136 * @param aValue The value for the key. The string is copied. |
|
137 */ |
|
138 void SetL( TPtrC8 aKey, const TDesC& aValue ); |
|
139 |
|
140 /** |
|
141 * Sets an integer value in the map |
|
142 * @param aKey The key of the value |
|
143 * @param aValue The value for the key. |
|
144 */ |
|
145 void SetL( TPtrC8 aKey, const TInt& aValue ); |
|
146 |
|
147 /** |
|
148 * Sets an map value in the map |
|
149 * @param aKey The key of the value |
|
150 * @param aValue The value for the key. The reference count of the map is increased. |
|
151 */ |
|
152 void SetL( TPtrC8 aKey, CLiwMap * aMap ); |
|
153 |
|
154 /** |
|
155 * Check whether value has been modified since last reading the values. |
|
156 * @return ETrue if value has been modified. |
|
157 */ |
|
158 TBool IsModified() const; |
|
159 |
|
160 /** |
|
161 * Reads all those entries from the map that have been modified |
|
162 * since previous reading of values. Null values are not read. |
|
163 * |
|
164 * @return A freshly allocated map with modified values. Null is returned if there are no modifications. |
|
165 */ |
|
166 CLiwMap * GetModifiedLC (); |
|
167 |
|
168 /** |
|
169 * Reads all non-null entries from the map. |
|
170 * |
|
171 * @return aMap A freshly allocated map with entries. Null is returned if map is empty. |
|
172 */ |
|
173 CLiwMap * GetAllLC(); |
|
174 |
|
175 /** |
|
176 * Closes the map discarding all its content. |
|
177 */ |
|
178 void Close(); |
|
179 |
|
180 private: |
|
181 |
|
182 RMusicContentVariant& AtL (TPtrC8 aKey); |
|
183 |
|
184 RHashMap<TPtrC8, RMusicContentVariant> iMap; |
|
185 TBool iModified; |
|
186 }; |
|
187 |
|
188 #endif |