|
1 /* |
|
2 * Copyright (c) 2007-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: Action Data class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef MULACTIONITEM_H |
|
20 #define MULACTIONITEM_H |
|
21 |
|
22 #include <mul/imulvarianttype.h> |
|
23 #include <alf/alfvarianttype.h> |
|
24 #include <memory> |
|
25 |
|
26 #include <osn/osndefines.h> |
|
27 #include <osn/ustring.h> |
|
28 |
|
29 namespace osncore |
|
30 { |
|
31 class UString; |
|
32 } |
|
33 using namespace osncore; |
|
34 |
|
35 |
|
36 namespace Alf |
|
37 { |
|
38 |
|
39 namespace mulactionitem |
|
40 { |
|
41 static const char* const KActionString = "actionItem"; |
|
42 } |
|
43 /*! @struct MulActionData |
|
44 * @brief Class holds the Action Data. Data varies on the basis of the type of |
|
45 * the action. Individual data items are public and can be accessed |
|
46 * once ref is obtained to the MulActionData structure. |
|
47 */ |
|
48 struct MulActionData |
|
49 { |
|
50 /*! @var Contains command id in case of simple command. */ |
|
51 int mCmdId; |
|
52 }; |
|
53 |
|
54 /*! @struct MulActionData |
|
55 * @brief Client need to use this class to add action item to data model. |
|
56 * Action can be of type simple command or a service api. |
|
57 * More data about the action is also encapsulated within the same class |
|
58 * Action item will represent one attribute within the visual item. |
|
59 * |
|
60 */ |
|
61 class MulActionItem : public IMulVariantType//public IAlfModelBase |
|
62 { |
|
63 public: |
|
64 |
|
65 /*! @enum TMulActionType |
|
66 * Action Type Definition. |
|
67 */ |
|
68 enum TMulActionType |
|
69 { |
|
70 EActionSimple /*!< Type specifies that the action is a simple command. */ |
|
71 }; |
|
72 |
|
73 public: //Constructor and Destructor |
|
74 |
|
75 /** |
|
76 * C++ constructor |
|
77 * |
|
78 * @param aType Action type. Possible options are defined by TMulActionType. |
|
79 * @param aData Action data based on type of the action. Ownership gets transfered. |
|
80 * @throw Invalid_argument, In case aData is NULL. |
|
81 */ |
|
82 OSN_IMPORT MulActionItem(TMulActionType aType, MulActionData* aData); |
|
83 |
|
84 /** |
|
85 * Copy constructor. |
|
86 */ |
|
87 OSN_IMPORT MulActionItem( const MulActionItem& aActionItem ); |
|
88 |
|
89 /** |
|
90 * Destructor. |
|
91 */ |
|
92 OSN_IMPORT ~MulActionItem(); |
|
93 |
|
94 public: // New methods |
|
95 |
|
96 /** |
|
97 * Set/Change the action type of an action item. |
|
98 * Default type of the action item is EActionSimple. |
|
99 * |
|
100 * @param aType Action type. Possible options are defined by TMulActionType. |
|
101 */ |
|
102 OSN_IMPORT void SetActionType( TMulActionType aType = EActionSimple ); |
|
103 |
|
104 /** |
|
105 * Returns the action type of the action item. |
|
106 * |
|
107 * @return Action type. Possible options are defined by TMulActionType. |
|
108 */ |
|
109 OSN_IMPORT MulActionItem::TMulActionType ActionType() const; |
|
110 |
|
111 /** |
|
112 * Set/Change the action data of an action item. |
|
113 * Ownership gets transfered. |
|
114 * |
|
115 * @param aData Action data based on type of the action. Ownership gets transfered. |
|
116 * @throw Invalid_argument, In case aData is NULL. |
|
117 */ |
|
118 OSN_IMPORT void SetActionData( MulActionData* aData ); |
|
119 |
|
120 /** |
|
121 * Returns the action data of the action item. |
|
122 * |
|
123 * @return Action data of the action item. A const reference is returned. |
|
124 */ |
|
125 OSN_IMPORT const MulActionData& ActionData() const; |
|
126 |
|
127 public: // from IAlfModelBase |
|
128 |
|
129 //virtual const UString& Type(); |
|
130 |
|
131 public: // from IMulVariantType |
|
132 |
|
133 OSN_IMPORT std::auto_ptr< IMulVariantType > Clone(); |
|
134 |
|
135 private: // form IAlfVAriantType |
|
136 |
|
137 void set(IAlfVariantType& aValue) ; |
|
138 |
|
139 Type type() const ; |
|
140 |
|
141 bool boolean() const ; |
|
142 |
|
143 int integer() const ; |
|
144 |
|
145 uint uinteger() const ; |
|
146 |
|
147 double real() const ; |
|
148 |
|
149 const UString& string() const ; |
|
150 |
|
151 IAlfContainer* container() ; |
|
152 |
|
153 IAlfMap* map() ; |
|
154 |
|
155 IAlfBranch* branch() ; |
|
156 |
|
157 IAlfModelBase* customData() ; |
|
158 |
|
159 private: // form IAlfVariantType |
|
160 |
|
161 private: // Class data |
|
162 |
|
163 /*! @var Type of the action data the class instance holds. */ |
|
164 TMulActionType mType; |
|
165 |
|
166 /*! @var Pointer to the action data. Data varies on the basis of the action type |
|
167 * Class owns the action data. */ |
|
168 auto_ptr<MulActionData> mData; |
|
169 |
|
170 /*! @var Pointer to the ActionString data. */ |
|
171 auto_ptr<UString> mActionString; |
|
172 }; |
|
173 |
|
174 } // namespace Alf |
|
175 |
|
176 #endif //MULACTIONITEM_H |
|
177 |
|
178 //End of file |