|
1 /* |
|
2 * Copyright (c) 2004-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 the License "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 |
|
20 |
|
21 /** |
|
22 @file |
|
23 @publishedPartner |
|
24 @released |
|
25 */ |
|
26 |
|
27 |
|
28 #ifndef __ATTRIBUTESET_H__ |
|
29 #define __ATTRIBUTESET_H__ |
|
30 |
|
31 #include <e32base.h> |
|
32 #include <caf/caftypes.h> |
|
33 |
|
34 class RReadStream; |
|
35 class RWriteStream; |
|
36 |
|
37 namespace ContentAccess |
|
38 { |
|
39 |
|
40 /** Holds the values of a predefined set of attributes based upon |
|
41 ContentAccess::TAttribute |
|
42 |
|
43 It is also possible for an agent to provide an extended set of these |
|
44 attributes beyond EAgentSpecificAttributeBase but only applications written |
|
45 to support a that particular agent will support this. |
|
46 |
|
47 No duplicate attributes are allowed in the set |
|
48 |
|
49 @publishedPartner |
|
50 @released |
|
51 */ |
|
52 class RAttributeSet |
|
53 { |
|
54 /** Holds the value of an attribute along with any error encountered |
|
55 while retrieving the attribute |
|
56 */ |
|
57 class TAttributeValue |
|
58 { |
|
59 public: |
|
60 TInt iAttribute; |
|
61 TInt iValue; |
|
62 TInt iError; |
|
63 }; |
|
64 |
|
65 public: |
|
66 IMPORT_C RAttributeSet(); |
|
67 |
|
68 /** Release all resources used by the RAttributeSet |
|
69 |
|
70 This must be called before the RAttribute set goes out of scope |
|
71 */ |
|
72 IMPORT_C void Close(); |
|
73 |
|
74 /** Add a new attribute to the set |
|
75 The attribute is initalised with a default value of EAttributeNotSupported |
|
76 |
|
77 @param aAttribute The attribute to add to the set |
|
78 */ |
|
79 IMPORT_C void AddL(TInt aAttribute); |
|
80 |
|
81 /** Get the value of a specified attribute |
|
82 @param aAttribute The attribute to query |
|
83 @param aValue The value of the attribute |
|
84 @return Whether the value parameter was updated |
|
85 @return KErrNone The attribute value was updated |
|
86 @return KErrNotFound The attribute is not part of the set |
|
87 */ |
|
88 IMPORT_C TInt GetValue(TInt aAttribute, TInt& aValue) const; |
|
89 |
|
90 /** Set the value of an attribute within the set |
|
91 @param aAttribute The attribute to set |
|
92 @param aValue The value of the attribute |
|
93 @param aErrorCode The error code to return when this attribute is requested via the GetValue() function |
|
94 @return Whether the new attribute value was set |
|
95 @return KErrNone if the value was set |
|
96 @return KErrNotFound if the attribute is not part of the set |
|
97 */ |
|
98 IMPORT_C TInt SetValue(TInt aAttribute, TInt aValue, TInt aErrorCode); |
|
99 |
|
100 /** Find the attribute stored at a particular index in the set |
|
101 @param aIndex The index of the attribute |
|
102 @return The attribute, NOT the value of the attribute |
|
103 */ |
|
104 IMPORT_C TInt operator [] (TInt aIndex) const; |
|
105 |
|
106 /** The number of attributes in the set |
|
107 @return The number of attributes in the set |
|
108 */ |
|
109 IMPORT_C TInt Count() const; |
|
110 |
|
111 /** Write the RAttributeSet to a stream |
|
112 @param aStream The stream to write the attribute set to |
|
113 */ |
|
114 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
115 |
|
116 /** Read the RAttributeSet from a stream |
|
117 This does not clear the contents of the attribute set before reading. The |
|
118 values of any attributes already in the set are updated with new values |
|
119 from the stream. New attributes from the stream and their values are added |
|
120 to the set. |
|
121 @param aStream The stream to read the attribute set from |
|
122 */ |
|
123 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
124 |
|
125 private: |
|
126 void AddL(TInt aAttribute, TInt aValue, TInt aErrorCode); |
|
127 |
|
128 RArray <TAttributeValue> iAttributes; |
|
129 }; |
|
130 } |
|
131 #endif |