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