|
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: attribute value type header. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef ALFATTRIBUTEVALUETYPE_H |
|
20 #define ALFATTRIBUTEVALUETYPE_H |
|
21 |
|
22 #include <osn/osndefines.h> |
|
23 #include <memory> |
|
24 #include <alf/alfmetric.h> |
|
25 |
|
26 namespace osncore |
|
27 { |
|
28 class UString; |
|
29 } |
|
30 using namespace osncore; |
|
31 using std::auto_ptr; |
|
32 |
|
33 namespace Alf |
|
34 { |
|
35 |
|
36 class AlfAttributeValueTypeImpl; |
|
37 |
|
38 /** |
|
39 * @class AlfAttributeValueType alfattributevaluetype.h "alf/alfattributevaluetype.h" |
|
40 * A class for attribute value type. Attributes are constructed using |
|
41 * AlfAttributeValueType objects. AlfAttributeValueType can store integer,float,string, |
|
42 * enum and RGB data. |
|
43 * @see AlfAttribute |
|
44 * |
|
45 * @lib alfwidgetmodel.lib |
|
46 * @since S60 ?S60_version |
|
47 * @status Draft |
|
48 */ |
|
49 class AlfAttributeValueType |
|
50 { |
|
51 |
|
52 public: |
|
53 |
|
54 /** Type enumeration. */ |
|
55 enum Type |
|
56 { |
|
57 EInt, EFloat, EString |
|
58 }; |
|
59 |
|
60 /** |
|
61 * Constructor. |
|
62 * @exception std::bad_alloc |
|
63 * |
|
64 * @param aValue The value of the attribute. |
|
65 * @param aUnit Unit of the value. |
|
66 */ |
|
67 OSN_IMPORT AlfAttributeValueType(int aValue, |
|
68 TAlfUnit aUnit = EAlfUnitPixel); |
|
69 |
|
70 /** |
|
71 * Constructor. |
|
72 * @exception std::bad_alloc |
|
73 * |
|
74 * @param aValue The value of the attribute. |
|
75 * @param aUnit Unit of the value. |
|
76 */ |
|
77 OSN_IMPORT AlfAttributeValueType(float aValue, |
|
78 TAlfUnit aUnit = EAlfUnitNormalized); |
|
79 |
|
80 /** |
|
81 * Constructor. |
|
82 * @exception std::bad_alloc |
|
83 * |
|
84 * @param aValue The value of the attribute. Takes a copy of the object. |
|
85 */ |
|
86 OSN_IMPORT AlfAttributeValueType(const UString& aValue); |
|
87 |
|
88 /** |
|
89 * Destructor. |
|
90 */ |
|
91 OSN_IMPORT virtual ~AlfAttributeValueType(); |
|
92 |
|
93 /** |
|
94 * Gets the enum value. |
|
95 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidAttributeValue |
|
96 * if the attribute value type is not of enum type. |
|
97 * |
|
98 * @return The integer value. |
|
99 */ |
|
100 OSN_IMPORT virtual int enumValue() const; |
|
101 |
|
102 /** |
|
103 * Gets the string value. |
|
104 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidAttributeValue |
|
105 * if the attribute value type is not of string type. |
|
106 * |
|
107 * @return The string value. |
|
108 */ |
|
109 OSN_IMPORT virtual const UString& stringValue() const; |
|
110 |
|
111 /** |
|
112 * Gets the integer value. |
|
113 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidAttributeValue |
|
114 * if the attribute value type is not of integer type. |
|
115 * |
|
116 * @return The integer value. |
|
117 */ |
|
118 OSN_IMPORT virtual int intValue() const; |
|
119 |
|
120 /** |
|
121 * Gets the real value. |
|
122 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidAttributeValue |
|
123 * if the attribute value type is not of float type. |
|
124 * |
|
125 * @return The real value. |
|
126 */ |
|
127 OSN_IMPORT virtual float realValue() const; |
|
128 |
|
129 /** |
|
130 * Gets the RGB value. |
|
131 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidAttributeValue |
|
132 * if the attribute value type is not of float type. |
|
133 * |
|
134 * @return The RGB value. |
|
135 */ |
|
136 OSN_IMPORT virtual float rgbValue() const; |
|
137 |
|
138 /** |
|
139 * Gets the type of the attribute value. |
|
140 * |
|
141 * @return The type of the attribute value. |
|
142 */ |
|
143 OSN_IMPORT virtual Type type() const; |
|
144 |
|
145 /** |
|
146 * Gets the unit of the value. |
|
147 * |
|
148 * @return The unit of the value. |
|
149 */ |
|
150 OSN_IMPORT virtual TAlfUnit unit() const; |
|
151 |
|
152 protected: |
|
153 |
|
154 /** |
|
155 * Constructor. |
|
156 */ |
|
157 AlfAttributeValueType(); |
|
158 |
|
159 private: // data |
|
160 |
|
161 auto_ptr<AlfAttributeValueTypeImpl> mData; |
|
162 |
|
163 }; |
|
164 |
|
165 } // namespace Alf |
|
166 |
|
167 #endif // ALFATTRIBUTEVALUETYPE_H |