|
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 "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file MetaData.h |
|
24 @internalTechnology |
|
25 */ |
|
26 |
|
27 #if (!defined METADATA_H) |
|
28 #define METADATA_H |
|
29 |
|
30 #include <e32base.h> |
|
31 #include <e32std.h> |
|
32 #include "comms-infras/cftransportmacro.h" |
|
33 |
|
34 /** |
|
35 Macro used to declare virtual functions from MMetaData interface and the virtual data table |
|
36 */ |
|
37 #define TYPEID_TABLE \ |
|
38 static inline const Meta::STypeId TypeId() { const Meta::SVDataTableEntry* entry = GetVDataTableStatic(); return Meta::STypeId(entry->iOffset,reinterpret_cast<TInt32>(entry->iMetaNewL)); } \ |
|
39 static const Meta::SVDataTableEntry* GetVDataTableStatic(); \ |
|
40 static const Meta::SVDataTableEntry iVDataTable[]; |
|
41 |
|
42 #define EXPORT_TYPEID_TABLE \ |
|
43 static inline const Meta::STypeId TypeId() { const Meta::SVDataTableEntry* entry = GetVDataTableStatic(); return Meta::STypeId(entry->iOffset,reinterpret_cast<TInt32>(entry->iMetaNewL)); } \ |
|
44 IMPORT_C static const Meta::SVDataTableEntry* GetVDataTableStatic(); \ |
|
45 static const Meta::SVDataTableEntry iVDataTable[]; |
|
46 |
|
47 #define DATA_VTABLE \ |
|
48 static inline const Meta::STypeId TypeId() { const Meta::SVDataTableEntry* entry = GetVDataTableStatic(); return Meta::STypeId(entry->iOffset,reinterpret_cast<TInt32>(entry->iMetaNewL)); } \ |
|
49 virtual Meta::SVDataTableEntry const* GetVDataTable() const; \ |
|
50 virtual TUint8* GetAttribPtr(const TInt aOffset) const; \ |
|
51 static const Meta::SVDataTableEntry* GetVDataTableStatic(); \ |
|
52 static const Meta::SVDataTableEntry iVDataTable[]; |
|
53 |
|
54 #define EXPORT_DATA_VTABLE \ |
|
55 static inline const Meta::STypeId TypeId() { const Meta::SVDataTableEntry* entry = GetVDataTableStatic(); return Meta::STypeId(entry->iOffset,reinterpret_cast<TInt32>(entry->iMetaNewL)); } \ |
|
56 virtual Meta::SVDataTableEntry const* GetVDataTable() const; \ |
|
57 virtual TUint8* GetAttribPtr(const TInt aOffset) const; \ |
|
58 IMPORT_C static const Meta::SVDataTableEntry* GetVDataTableStatic(); \ |
|
59 static const Meta::SVDataTableEntry iVDataTable[]; |
|
60 |
|
61 #define EXPORT_DATA_VTABLE_AND_FN \ |
|
62 static inline const Meta::STypeId TypeId() { const Meta::SVDataTableEntry* entry = GetVDataTableStatic(); return Meta::STypeId(entry->iOffset,reinterpret_cast<TInt32>(entry->iMetaNewL)); } \ |
|
63 IMPORT_C virtual Meta::SVDataTableEntry const* GetVDataTable() const; \ |
|
64 IMPORT_C virtual TUint8* GetAttribPtr(const TInt aOffset) const; \ |
|
65 IMPORT_C static const Meta::SVDataTableEntry* GetVDataTableStatic(); \ |
|
66 static const Meta::SVDataTableEntry iVDataTable[]; |
|
67 |
|
68 /** |
|
69 Macros used to implement virtual functions from MMetaData interface and construct the v data table |
|
70 */ |
|
71 #define START_ATTRIBUTE_TABLE( thisMetaClass, uid, typeId ) \ |
|
72 Meta::SVDataTableEntry const* thisMetaClass::GetVDataTable() const { return &iVDataTable[0]; }; \ |
|
73 TUint8* thisMetaClass::GetAttribPtr(const TInt aOffset) const { return (TUint8*)this + aOffset; }; \ |
|
74 const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \ |
|
75 const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \ |
|
76 { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) }, |
|
77 |
|
78 #define EXPORT_START_ATTRIBUTE_TABLE( thisMetaClass, uid, typeId ) \ |
|
79 Meta::SVDataTableEntry const* thisMetaClass::GetVDataTable() const { return &iVDataTable[0]; }; \ |
|
80 TUint8* thisMetaClass::GetAttribPtr(const TInt aOffset) const { return (TUint8*)this + aOffset; }; \ |
|
81 EXPORT_C const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \ |
|
82 const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \ |
|
83 { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) }, |
|
84 |
|
85 #define EXPORT_START_ATTRIBUTE_TABLE_AND_FN( thisMetaClass, uid, typeId ) \ |
|
86 EXPORT_C Meta::SVDataTableEntry const* thisMetaClass::GetVDataTable() const { return &iVDataTable[0]; }; \ |
|
87 EXPORT_C TUint8* thisMetaClass::GetAttribPtr(const TInt aOffset) const { return (TUint8*)this + aOffset; }; \ |
|
88 EXPORT_C const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \ |
|
89 const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \ |
|
90 { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) }, |
|
91 |
|
92 #define REGISTER_ATTRIBUTE( thisMetaClass, var, metaType ) \ |
|
93 { _FOFF( thisMetaClass, var ), Meta::metaType::NewL }, |
|
94 |
|
95 #define END_ATTRIBUTE_TABLE() \ |
|
96 { 0, NULL }}; |
|
97 |
|
98 #define END_ATTRIBUTE_TABLE_BASE( baseMetaClass, baseId ) \ |
|
99 { (TInt)((TAny*)(baseMetaClass::GetVDataTableStatic)), NULL }}; |
|
100 |
|
101 #define REGISTER_TYPEID( thisMetaClass, uid, typeId ) \ |
|
102 const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \ |
|
103 const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \ |
|
104 { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) }, \ |
|
105 { 0, NULL }}; |
|
106 |
|
107 #define EXPORT_REGISTER_TYPEID( thisMetaClass, uid, typeId ) \ |
|
108 EXPORT_C const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \ |
|
109 const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \ |
|
110 { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) }, \ |
|
111 { 0, NULL }}; |
|
112 |
|
113 #define EXPORT_START_ATTRIBUTE_TABLE_NO_FN( thisMetaClass, uid, typeId ) \ |
|
114 EXPORT_C const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \ |
|
115 const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \ |
|
116 { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) }, |
|
117 |
|
118 |
|
119 namespace Meta |
|
120 { |
|
121 |
|
122 class MMetaType; |
|
123 typedef MMetaType* (*TMetaTypeNewL)(const TAny*, const TAny*); |
|
124 |
|
125 struct SVDataTableEntry |
|
126 /** |
|
127 |
|
128 Single entry of a virtual data table |
|
129 |
|
130 @internalComponent |
|
131 @released since v9.0 */ |
|
132 { |
|
133 TInt iOffset; |
|
134 TMetaTypeNewL iMetaNewL; |
|
135 }; |
|
136 |
|
137 const TInt32 KNetMetaTypeAny = 0; |
|
138 |
|
139 struct STypeId |
|
140 /** |
|
141 |
|
142 Used to uniquely identify the type of a (meta).object. |
|
143 |
|
144 @internalComponent |
|
145 @released since v9.0 */ |
|
146 { |
|
147 TUid iUid; |
|
148 TInt32 iType; |
|
149 inline TBool operator==(const STypeId& obj) const { return iUid==obj.iUid && iType==obj.iType; }; |
|
150 inline STypeId(); |
|
151 inline STypeId(TUint32 aUid, TUint32 aTypeId); |
|
152 IMPORT_C STypeId(TPtrC8& aStore); |
|
153 IMPORT_C TInt Check( TPtrC8& aDes ) const; |
|
154 }; |
|
155 |
|
156 class MMetaData |
|
157 /** |
|
158 |
|
159 MetaData interface |
|
160 |
|
161 @internalComponent |
|
162 @released since v9.0 */ |
|
163 { |
|
164 public: |
|
165 virtual SVDataTableEntry const* GetVDataTable() const = 0; |
|
166 virtual TUint8* GetAttribPtr(const TInt aOffset) const = 0; |
|
167 }; |
|
168 |
|
169 struct SMetaData : public MMetaData |
|
170 /** |
|
171 |
|
172 Meta object's base type |
|
173 |
|
174 Partially implements the MMetaData interface's pure virtual functions |
|
175 |
|
176 @internalComponent |
|
177 @released since v9.0 */ |
|
178 { |
|
179 public: |
|
180 IMPORT_C virtual ~SMetaData(); |
|
181 |
|
182 IMPORT_C TInt CheckTypeOf( TPtrC8& aDes ) const; |
|
183 IMPORT_C STypeId GetTypeId() const; |
|
184 IMPORT_C TInt IsTypeOf( const STypeId& aTypeId ) const; |
|
185 |
|
186 IMPORT_C void Copy(const SMetaData& aSource); |
|
187 IMPORT_C TInt Store(TDes8& aDes) const; |
|
188 IMPORT_C TInt Load(TPtrC8& aDes); |
|
189 |
|
190 IMPORT_C TInt Length() const; |
|
191 |
|
192 protected: |
|
193 IMPORT_C explicit SMetaData(); |
|
194 }; |
|
195 |
|
196 const TInt KUidEComMetaDataFactoryInterface = 0x101F7700; |
|
197 |
|
198 struct SMetaDataECom : public SMetaData |
|
199 /** |
|
200 |
|
201 Meta object based on ECom factory base type |
|
202 |
|
203 Implements static LoadL(TPtrC8& aDes) required by templated |
|
204 |
|
205 @internalTechnology |
|
206 @released since v9.0 */ |
|
207 { |
|
208 public: |
|
209 IMPORT_C static SMetaDataECom* LoadL(TPtrC8& aDes); |
|
210 IMPORT_C static SMetaDataECom* NewInstanceL(const STypeId& aTypeId); |
|
211 IMPORT_C virtual ~SMetaDataECom(); |
|
212 |
|
213 protected: |
|
214 IMPORT_C explicit SMetaDataECom(); |
|
215 |
|
216 private: |
|
217 TUid iDestroyUid; |
|
218 }; |
|
219 |
|
220 } //namespace Meta |
|
221 |
|
222 #include <comms-infras/metadata.inl> |
|
223 |
|
224 #endif //METADATA_H |