1 /* |
|
2 * Copyright (c) 2007 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: An interface for querying and setting attributes. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef I_ALFATTRIBUTEOWNER_H |
|
20 #define I_ALFATTRIBUTEOWNER_H |
|
21 |
|
22 #include <alf/ialfinterfacebase.h> |
|
23 #include <alf/alftypes.h> |
|
24 |
|
25 namespace osncore |
|
26 { |
|
27 class UString; |
|
28 } |
|
29 |
|
30 using namespace osncore; |
|
31 |
|
32 namespace Alf |
|
33 { |
|
34 |
|
35 class AlfAttribute; |
|
36 class AlfAttributeValueType; |
|
37 class AlfAttributeContainer; |
|
38 |
|
39 namespace alfattributeowner |
|
40 { |
|
41 static const IfId ident = |
|
42 { |
|
43 0, "alfattributeowner" |
|
44 }; |
|
45 } |
|
46 |
|
47 /** |
|
48 * An interface for querying and setting attributes. |
|
49 * The interface defines a generic functionality for setting |
|
50 * any attributes of the implementing class. It can be used |
|
51 * also to query the available set of attributes. |
|
52 * |
|
53 * The interface should by implemented by all widget classes. |
|
54 * It can be also used by element classes. |
|
55 * Widget attributes have often corresponding data fields in the |
|
56 * model. In this case, setting new values should also update |
|
57 * the model. If an attribute is related to the presentation of |
|
58 * the widget, the presentation is updated when a new value is set |
|
59 * for the attribute. |
|
60 * |
|
61 * @lib alfwidgetmodel.lib |
|
62 * @since S60 ?S60_version |
|
63 * @status Draft |
|
64 */ |
|
65 class IAlfAttributeOwner : public IAlfInterfaceBase |
|
66 { |
|
67 public: |
|
68 /** |
|
69 * Virtual destructor. |
|
70 */ |
|
71 virtual ~IAlfAttributeOwner() {} |
|
72 |
|
73 /** |
|
74 * Get the number of available attributes. |
|
75 * |
|
76 * @return The number of attributes. |
|
77 */ |
|
78 virtual int attributeCount() const = 0; |
|
79 |
|
80 /** |
|
81 * Gets the attribute with the given name. |
|
82 * The returned attribute instance is owned by the widget and |
|
83 * should not be deleted. |
|
84 * Also the returned attribute instance should not be modified. |
|
85 * Use SetAttribute for that. |
|
86 * |
|
87 * @param aAttribName The name of the attribute. |
|
88 * @return The attribute, or 0 if the attribute was not found. |
|
89 */ |
|
90 virtual const AlfAttribute* getAttribute( const UString& aAttribName ) const = 0; |
|
91 |
|
92 /** |
|
93 * Set a value of an attribute. |
|
94 * |
|
95 * If no value is present in passed attribute parameter, |
|
96 * an AlfAttributeException-exception |
|
97 * is thrown with EInvalidAttribute error code. |
|
98 * |
|
99 * @param aAttribute Reference attribute, the data is copied from it. |
|
100 * The ownership is not transferred. |
|
101 * @return True if the attribute was supported, false if not. |
|
102 * Attribute is added to container even if it not supported. |
|
103 */ |
|
104 virtual bool setAttribute( const AlfAttribute& aAttribute ) = 0; |
|
105 |
|
106 /** |
|
107 * Set a value of an attribute. |
|
108 * This SetAttribute variant is for simple non animated attributes |
|
109 * that only have name and value. |
|
110 * |
|
111 * If no value is present in passed attributevalue parameter, |
|
112 * an AlfAttributeException-exception |
|
113 * is thrown with EInvalidAttribute error code. |
|
114 * |
|
115 * @param aAttribName Name of the attribute. |
|
116 * @param aValue Value of the attribute. Ownership is transferred |
|
117 * @return True if the attribute was supported, false if not. |
|
118 * Attribute is added to container even if it not supported. |
|
119 */ |
|
120 virtual bool setAttribute( const UString& aAttribName, |
|
121 AlfAttributeValueType* aValue ) = 0; |
|
122 /** |
|
123 * Sets values of each attribute in given container |
|
124 * |
|
125 * If no value is present in an attribute in the container, |
|
126 * an AlfAttributeException-exception |
|
127 * is thrown with EInvalidAttribute error code. |
|
128 * |
|
129 * @param aAttributeContainer Reference attributeContainer, All attributes |
|
130 * in the container are handled. The ownership is not transferred. |
|
131 * @return True if all attributes were supported, false if at least 1 attribute was not supported |
|
132 */ |
|
133 virtual bool setAttributeContainer( AlfAttributeContainer& aAttributeContainer ) = 0; |
|
134 |
|
135 /** |
|
136 * Sets a value of an attribute to a specific target. |
|
137 * The target is identified by using aTargetId parameter. |
|
138 * |
|
139 * If no value is present in passed attribute parameter, |
|
140 * an AlfAttributeException-exception |
|
141 * is thrown with EInvalidAttribute error code. |
|
142 * |
|
143 * @param aTargetId Name of the target widget part, e.g element class tag. |
|
144 * @param aAttribute Reference attribute, the data is copied from it. |
|
145 * The ownership is not transferred. |
|
146 * @return True if the attribute was supported, false if not. |
|
147 */ |
|
148 virtual bool setAttribute( const UString& aTargetId , |
|
149 AlfAttribute& aAttribute ) = 0; |
|
150 |
|
151 |
|
152 |
|
153 /** |
|
154 * Sets a value of an static attribute. |
|
155 * This SetAttribute variant is for simple non animated attributes |
|
156 * that only have name and value. |
|
157 * |
|
158 * If no value is present in passed attributevalue parameter, |
|
159 * an AlfAttributeException-exception |
|
160 * is thrown with EInvalidAttribute error code. |
|
161 * |
|
162 * @param aTargetId The name of the target widget part, e.g. element class |
|
163 * @param aAttribName Name of the attribute. |
|
164 * @param aValue Value of the attribute. Ownership is transferred |
|
165 * @return True if the attribute was supported, false if not. |
|
166 */ |
|
167 virtual bool setAttribute( const UString& aTargetId, |
|
168 const UString& aAttribName, |
|
169 AlfAttributeValueType* aValue ) = 0; |
|
170 |
|
171 /** |
|
172 * Sets values of each attribute in given container to a specific target. |
|
173 * The target is identified by using aTargetId parameter. |
|
174 * |
|
175 * If no value is present in an attribute in the container, |
|
176 * an AlfAttributeException-exception |
|
177 * is thrown with EInvalidAttribute error code. |
|
178 * |
|
179 * @param aTargetId Name of the target widget part, e.g element class tag. |
|
180 * @param aAttributeContainer Reference attributeContainer, All attributes |
|
181 * in the container are handled. The ownership is not transferred. |
|
182 * @return True if all attributes were supported, false if at least 1 attribute was not supported |
|
183 */ |
|
184 virtual bool setAttributeContainer( const UString& aTargetId , |
|
185 AlfAttributeContainer& aAttributeContainer ) = 0; |
|
186 |
|
187 /** |
|
188 * Gets the attribute with the given name from specific target. |
|
189 * The returned attribute instance is owned by the widget and |
|
190 * should not be deleted. |
|
191 * Also the returned attribute instance should not be modified. |
|
192 * Use SetAttribute for that. |
|
193 * |
|
194 * @param aTargetId The name of the target widget part, e.g. element class |
|
195 * @param aAttribName The name of the attribute. |
|
196 * @return A pointer to the attribute, or 0 if the attribute was not found. |
|
197 */ |
|
198 virtual const AlfAttribute* getAttribute( const UString& aTargetId , |
|
199 const UString& aAttribName ) const = 0; |
|
200 |
|
201 |
|
202 |
|
203 /** |
|
204 * Getter for the type identifier of this interface. |
|
205 * |
|
206 * @since S60 ?S60_versio |
|
207 * @return Identifier of this interface. |
|
208 */ |
|
209 static inline const IfId& type() |
|
210 { |
|
211 return alfattributeowner::ident; |
|
212 } |
|
213 }; |
|
214 |
|
215 } // namespace Alf |
|
216 |
|
217 #endif // I_ALFATTRIBUTEOWNER_H |
|