1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/comms-infras/metadata.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,224 @@
1.4 +/**
1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* 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
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +
1.24 +
1.25 +/**
1.26 + @file MetaData.h
1.27 + @internalTechnology
1.28 +*/
1.29 +
1.30 +#if (!defined METADATA_H)
1.31 +#define METADATA_H
1.32 +
1.33 +#include <e32base.h>
1.34 +#include <e32std.h>
1.35 +#include "comms-infras/cftransportmacro.h"
1.36 +
1.37 +/**
1.38 +Macro used to declare virtual functions from MMetaData interface and the virtual data table
1.39 +*/
1.40 +#define TYPEID_TABLE \
1.41 + static inline const Meta::STypeId TypeId() { const Meta::SVDataTableEntry* entry = GetVDataTableStatic(); return Meta::STypeId(entry->iOffset,reinterpret_cast<TInt32>(entry->iMetaNewL)); } \
1.42 + static const Meta::SVDataTableEntry* GetVDataTableStatic(); \
1.43 + static const Meta::SVDataTableEntry iVDataTable[];
1.44 +
1.45 +#define EXPORT_TYPEID_TABLE \
1.46 + static inline const Meta::STypeId TypeId() { const Meta::SVDataTableEntry* entry = GetVDataTableStatic(); return Meta::STypeId(entry->iOffset,reinterpret_cast<TInt32>(entry->iMetaNewL)); } \
1.47 + IMPORT_C static const Meta::SVDataTableEntry* GetVDataTableStatic(); \
1.48 + static const Meta::SVDataTableEntry iVDataTable[];
1.49 +
1.50 +#define DATA_VTABLE \
1.51 + static inline const Meta::STypeId TypeId() { const Meta::SVDataTableEntry* entry = GetVDataTableStatic(); return Meta::STypeId(entry->iOffset,reinterpret_cast<TInt32>(entry->iMetaNewL)); } \
1.52 + virtual Meta::SVDataTableEntry const* GetVDataTable() const; \
1.53 + virtual TUint8* GetAttribPtr(const TInt aOffset) const; \
1.54 + static const Meta::SVDataTableEntry* GetVDataTableStatic(); \
1.55 + static const Meta::SVDataTableEntry iVDataTable[];
1.56 +
1.57 +#define EXPORT_DATA_VTABLE \
1.58 + static inline const Meta::STypeId TypeId() { const Meta::SVDataTableEntry* entry = GetVDataTableStatic(); return Meta::STypeId(entry->iOffset,reinterpret_cast<TInt32>(entry->iMetaNewL)); } \
1.59 + virtual Meta::SVDataTableEntry const* GetVDataTable() const; \
1.60 + virtual TUint8* GetAttribPtr(const TInt aOffset) const; \
1.61 + IMPORT_C static const Meta::SVDataTableEntry* GetVDataTableStatic(); \
1.62 + static const Meta::SVDataTableEntry iVDataTable[];
1.63 +
1.64 +#define EXPORT_DATA_VTABLE_AND_FN \
1.65 + static inline const Meta::STypeId TypeId() { const Meta::SVDataTableEntry* entry = GetVDataTableStatic(); return Meta::STypeId(entry->iOffset,reinterpret_cast<TInt32>(entry->iMetaNewL)); } \
1.66 + IMPORT_C virtual Meta::SVDataTableEntry const* GetVDataTable() const; \
1.67 + IMPORT_C virtual TUint8* GetAttribPtr(const TInt aOffset) const; \
1.68 + IMPORT_C static const Meta::SVDataTableEntry* GetVDataTableStatic(); \
1.69 + static const Meta::SVDataTableEntry iVDataTable[];
1.70 +
1.71 +/**
1.72 +Macros used to implement virtual functions from MMetaData interface and construct the v data table
1.73 +*/
1.74 +#define START_ATTRIBUTE_TABLE( thisMetaClass, uid, typeId ) \
1.75 + Meta::SVDataTableEntry const* thisMetaClass::GetVDataTable() const { return &iVDataTable[0]; }; \
1.76 + TUint8* thisMetaClass::GetAttribPtr(const TInt aOffset) const { return (TUint8*)this + aOffset; }; \
1.77 + const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \
1.78 + const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \
1.79 + { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) },
1.80 +
1.81 +#define EXPORT_START_ATTRIBUTE_TABLE( thisMetaClass, uid, typeId ) \
1.82 + Meta::SVDataTableEntry const* thisMetaClass::GetVDataTable() const { return &iVDataTable[0]; }; \
1.83 + TUint8* thisMetaClass::GetAttribPtr(const TInt aOffset) const { return (TUint8*)this + aOffset; }; \
1.84 + EXPORT_C const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \
1.85 + const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \
1.86 + { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) },
1.87 +
1.88 +#define EXPORT_START_ATTRIBUTE_TABLE_AND_FN( thisMetaClass, uid, typeId ) \
1.89 + EXPORT_C Meta::SVDataTableEntry const* thisMetaClass::GetVDataTable() const { return &iVDataTable[0]; }; \
1.90 + EXPORT_C TUint8* thisMetaClass::GetAttribPtr(const TInt aOffset) const { return (TUint8*)this + aOffset; }; \
1.91 + EXPORT_C const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \
1.92 + const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \
1.93 + { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) },
1.94 +
1.95 +#define REGISTER_ATTRIBUTE( thisMetaClass, var, metaType ) \
1.96 + { _FOFF( thisMetaClass, var ), Meta::metaType::NewL },
1.97 +
1.98 +#define END_ATTRIBUTE_TABLE() \
1.99 + { 0, NULL }};
1.100 +
1.101 +#define END_ATTRIBUTE_TABLE_BASE( baseMetaClass, baseId ) \
1.102 + { (TInt)((TAny*)(baseMetaClass::GetVDataTableStatic)), NULL }};
1.103 +
1.104 +#define REGISTER_TYPEID( thisMetaClass, uid, typeId ) \
1.105 + const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \
1.106 + const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \
1.107 + { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) }, \
1.108 + { 0, NULL }};
1.109 +
1.110 +#define EXPORT_REGISTER_TYPEID( thisMetaClass, uid, typeId ) \
1.111 + EXPORT_C const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \
1.112 + const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \
1.113 + { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) }, \
1.114 + { 0, NULL }};
1.115 +
1.116 +#define EXPORT_START_ATTRIBUTE_TABLE_NO_FN( thisMetaClass, uid, typeId ) \
1.117 + EXPORT_C const Meta::SVDataTableEntry* thisMetaClass::GetVDataTableStatic() { return &iVDataTable[0]; }; \
1.118 + const Meta::SVDataTableEntry thisMetaClass::iVDataTable[] = { \
1.119 + { uid, reinterpret_cast<Meta::TMetaTypeNewL>(typeId) },
1.120 +
1.121 +
1.122 +namespace Meta
1.123 +{
1.124 +
1.125 +class MMetaType;
1.126 +typedef MMetaType* (*TMetaTypeNewL)(const TAny*, const TAny*);
1.127 +
1.128 +struct SVDataTableEntry
1.129 +/**
1.130 +
1.131 +Single entry of a virtual data table
1.132 +
1.133 +@internalComponent
1.134 +@released since v9.0 */
1.135 + {
1.136 + TInt iOffset;
1.137 + TMetaTypeNewL iMetaNewL;
1.138 + };
1.139 +
1.140 +const TInt32 KNetMetaTypeAny = 0;
1.141 +
1.142 +struct STypeId
1.143 +/**
1.144 +
1.145 +Used to uniquely identify the type of a (meta).object.
1.146 +
1.147 +@internalComponent
1.148 +@released since v9.0 */
1.149 + {
1.150 + TUid iUid;
1.151 + TInt32 iType;
1.152 + inline TBool operator==(const STypeId& obj) const { return iUid==obj.iUid && iType==obj.iType; };
1.153 + inline STypeId();
1.154 + inline STypeId(TUint32 aUid, TUint32 aTypeId);
1.155 + IMPORT_C STypeId(TPtrC8& aStore);
1.156 + IMPORT_C TInt Check( TPtrC8& aDes ) const;
1.157 + };
1.158 +
1.159 +class MMetaData
1.160 +/**
1.161 +
1.162 +MetaData interface
1.163 +
1.164 +@internalComponent
1.165 +@released since v9.0 */
1.166 + {
1.167 +public:
1.168 + virtual SVDataTableEntry const* GetVDataTable() const = 0;
1.169 + virtual TUint8* GetAttribPtr(const TInt aOffset) const = 0;
1.170 + };
1.171 +
1.172 +struct SMetaData : public MMetaData
1.173 +/**
1.174 +
1.175 +Meta object's base type
1.176 +
1.177 +Partially implements the MMetaData interface's pure virtual functions
1.178 +
1.179 +@internalComponent
1.180 +@released since v9.0 */
1.181 + {
1.182 +public:
1.183 + IMPORT_C virtual ~SMetaData();
1.184 +
1.185 + IMPORT_C TInt CheckTypeOf( TPtrC8& aDes ) const;
1.186 + IMPORT_C STypeId GetTypeId() const;
1.187 + IMPORT_C TInt IsTypeOf( const STypeId& aTypeId ) const;
1.188 +
1.189 + IMPORT_C void Copy(const SMetaData& aSource);
1.190 + IMPORT_C TInt Store(TDes8& aDes) const;
1.191 + IMPORT_C TInt Load(TPtrC8& aDes);
1.192 +
1.193 + IMPORT_C TInt Length() const;
1.194 +
1.195 +protected:
1.196 + IMPORT_C explicit SMetaData();
1.197 + };
1.198 +
1.199 +const TInt KUidEComMetaDataFactoryInterface = 0x101F7700;
1.200 +
1.201 +struct SMetaDataECom : public SMetaData
1.202 +/**
1.203 +
1.204 +Meta object based on ECom factory base type
1.205 +
1.206 +Implements static LoadL(TPtrC8& aDes) required by templated
1.207 +
1.208 +@internalTechnology
1.209 +@released since v9.0 */
1.210 + {
1.211 +public:
1.212 + IMPORT_C static SMetaDataECom* LoadL(TPtrC8& aDes);
1.213 + IMPORT_C static SMetaDataECom* NewInstanceL(const STypeId& aTypeId);
1.214 + IMPORT_C virtual ~SMetaDataECom();
1.215 +
1.216 +protected:
1.217 + IMPORT_C explicit SMetaDataECom();
1.218 +
1.219 +private:
1.220 + TUid iDestroyUid;
1.221 + };
1.222 +
1.223 +} //namespace Meta
1.224 +
1.225 +#include <comms-infras/metadata.inl>
1.226 +
1.227 +#endif //METADATA_H