commsfwsupport/commselements/nodemessages/inc/nm_signatures.h
changeset 0 dfb7c4ff071f
child 23 ca99e4de25bf
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // nm_signature.h
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @publishedPartner
       
    21  @released
       
    22 */
       
    23 
       
    24 #ifndef SYMBIAN_NM_SIGNATURES_H
       
    25 #define SYMBIAN_NM_SIGNATURES_H
       
    26 
       
    27 #include <elements/nm_signals.h>
       
    28 #include <elements/nm_interfaces.h>
       
    29 #include <elements/metatype.h>
       
    30 
       
    31 
       
    32 #ifdef _DEBUG
       
    33 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module
       
    34 // (if it could happen through user error then you should give it an explicit, documented, category + code)
       
    35 _LIT(KSpecAssert_ElemNodeMessSigH, "ElemNodeMessSigH");
       
    36 #endif
       
    37 
       
    38 #define DECLARE_MESSAGE_SIG_1( sig, type, name ) \
       
    39 struct T##sig : public Messages::TSignatureBase \
       
    40     { \
       
    41 protected: \
       
    42     inline T##sig() {} \
       
    43     explicit T##sig( const Messages::TNodeSignal::TMessageId& aMessageId, type a##name ) : \
       
    44         Messages::TSignatureBase(aMessageId), \
       
    45         i##name(a##name) \
       
    46 	    {} \
       
    47 public: \
       
    48 	   DECLARE_MVIP_CTR( T##sig ) \
       
    49    	   EXPORT_DATA_VTABLE_AND_FN \
       
    50 	   type i##name; \
       
    51     }; \
       
    52 template<TInt id, TInt32 realm> \
       
    53 struct TMessage##sig : public T##sig, public Messages::TSignatureBase::TTypeToMessageId<id, realm> \
       
    54     { \
       
    55 	explicit TMessage##sig(type a##name ) : \
       
    56 	    T##sig(Messages::TNodeSignal::TMessageId(id, realm), a##name) \
       
    57 	    {} \
       
    58     };
       
    59 
       
    60 #define DECLARE_MESSAGE_SIG_2( sig, type, name, type2, name2 ) \
       
    61 struct T##sig : public Messages::TSignatureBase \
       
    62     { \
       
    63 protected: \
       
    64 	inline T##sig() {} \
       
    65 	explicit T##sig( const Messages::TNodeSignal::TMessageId& aMessageId, type a##name, type2 a##name2 ) : \
       
    66 	   Messages::TSignatureBase(aMessageId), \
       
    67 	   i##name(a##name), \
       
    68 	   i##name2(a##name2) \
       
    69 	    {} \
       
    70 public: \
       
    71 	   DECLARE_MVIP_CTR( T##sig ) \
       
    72    	   EXPORT_DATA_VTABLE_AND_FN \
       
    73 	   type i##name; \
       
    74 	   type2 i##name2; \
       
    75     }; \
       
    76 template<TInt id, TInt32 realm> \
       
    77 struct TMessage##sig : public T##sig, public Messages::TSignatureBase::TTypeToMessageId<id, realm> \
       
    78     { \
       
    79 	explicit TMessage##sig(type a##name, type2 a##name2 ) : \
       
    80 	    T##sig(Messages::TNodeSignal::TMessageId(id, realm), a##name, a##name2) \
       
    81         {} \
       
    82     };
       
    83 
       
    84 #define DECLARE_MESSAGE_SIG_3( sig, type, name, type2, name2, type3, name3 ) \
       
    85 struct T##sig : public Messages::TSignatureBase \
       
    86     { \
       
    87 protected: \
       
    88 	inline T##sig() {} \
       
    89 	explicit T##sig( const Messages::TNodeSignal::TMessageId& aMessageId, type a##name, type2 a##name2, type3 a##name3 ) : \
       
    90 	   Messages::TSignatureBase(aMessageId), \
       
    91 	   i##name(a##name), \
       
    92 	   i##name2(a##name2), \
       
    93 	   i##name3(a##name3) \
       
    94 	    {} \
       
    95 public: \
       
    96 	   DECLARE_MVIP_CTR( T##sig ) \
       
    97    	   EXPORT_DATA_VTABLE_AND_FN \
       
    98 	   type i##name; \
       
    99 	   type2 i##name2; \
       
   100 	   type3 i##name3; \
       
   101     }; \
       
   102 template<TInt id, TInt32 realm> \
       
   103 struct TMessage##sig : public T##sig, public Messages::TSignatureBase::TTypeToMessageId<id, realm> \
       
   104     { \
       
   105 	explicit TMessage##sig(type a##name, type2 a##name2, type3 a##name3 ) : \
       
   106 	    T##sig(Messages::TNodeSignal::TMessageId(id, realm), a##name, a##name2, a##name3) \
       
   107         {} \
       
   108     };
       
   109 
       
   110 #define DECLARE_MESSAGE_SIG_4( sig, type, name, type2, name2, type3, name3, type4, name4 ) \
       
   111 struct T##sig : public Messages::TSignatureBase \
       
   112     { \
       
   113 protected: \
       
   114 	inline T##sig() {} \
       
   115 	explicit T##sig( const Messages::TNodeSignal::TMessageId& aMessageId, type a##name, type2 a##name2, type3 a##name3, type4 a##name4 ) : \
       
   116 	   Messages::TSignatureBase(aMessageId), \
       
   117 	   i##name(a##name), \
       
   118 	   i##name2(a##name2), \
       
   119 	   i##name3(a##name3), \
       
   120 	   i##name4(a##name4) \
       
   121 	    {} \
       
   122 public: \
       
   123 	   DECLARE_MVIP_CTR( T##sig ) \
       
   124    	   EXPORT_DATA_VTABLE_AND_FN \
       
   125 	   type i##name; \
       
   126        type2 i##name2; \
       
   127        type3 i##name3; \
       
   128 	   type4 i##name4; \
       
   129     }; \
       
   130 template<TInt id, TInt32 realm> \
       
   131 struct TMessage##sig : public T##sig, public Messages::TSignatureBase::TTypeToMessageId<id, realm> \
       
   132     { \
       
   133 	explicit TMessage##sig(type a##name, type2 a##name2, type3 a##name3, type4 a##name4 ) : \
       
   134 	    T##sig(Messages::TNodeSignal::TMessageId(id, realm), a##name, a##name2, a##name3, a##name4) \
       
   135 	    {} \
       
   136     };
       
   137 
       
   138 namespace Messages
       
   139 {
       
   140 
       
   141 //-=========================================================
       
   142 //
       
   143 // TNodeSignal
       
   144 //
       
   145 //-=========================================================
       
   146 class TNodeSignal : public TSignalBase
       
   147 	{
       
   148 public:
       
   149     class TMessageId
       
   150         {
       
   151         friend class TNodeSignal;
       
   152     public:
       
   153 
       
   154 		typedef TUint TRealm;
       
   155 
       
   156         TBool operator==(const TMessageId& aMessageId) const
       
   157             {
       
   158             return aMessageId.iRealm == iRealm && aMessageId.iId == iId;
       
   159             }
       
   160 
       
   161         TBool operator!=(const TMessageId& aMessageId) const
       
   162             {
       
   163             return !((*this) == aMessageId);
       
   164             }
       
   165 
       
   166         TMessageId& operator=(const TMessageId& aMessageId)
       
   167             {
       
   168             iId = aMessageId.iId;
       
   169             iRealm = aMessageId.iRealm;
       
   170             return *this;
       
   171             }
       
   172 
       
   173         TUint MessageId() const
       
   174             {
       
   175             return iId;
       
   176             }
       
   177 
       
   178         TRealm Realm() const
       
   179             {
       
   180             return iRealm;
       
   181             }
       
   182 
       
   183         TBool IsNull() const
       
   184             {
       
   185             return MessageId() == KNullMessageId;
       
   186             }
       
   187 
       
   188         TMessageId(TUint aId, TRealm aRealm)
       
   189         :	iId(aId), iRealm(aRealm)
       
   190         	{ __ASSERT_DEBUG(!(aId & 0xFFFF0000), User::Panic(KSpecAssert_ElemNodeMessSigH, 1)); }
       
   191 
       
   192         TMessageId()
       
   193         :	iId(KNullMessageId), iRealm(0)
       
   194         	{}
       
   195 
       
   196     private:
       
   197         TUint16 iId;
       
   198         TRealm  iRealm;   //determines the realm for the iMessageId
       
   199                           //to avoid clashes with other realms.protected:
       
   200         };
       
   201 
       
   202     template<TInt id, TMessageId::TRealm realm>
       
   203     struct TTypeToMessageId
       
   204         {
       
   205         enum
       
   206             {
       
   207             EId    = id,
       
   208             ERealm = realm,
       
   209             };
       
   210 
       
   211         inline static TMessageId Id()
       
   212             {
       
   213             return TMessageId(id,realm);
       
   214             }
       
   215         };
       
   216 
       
   217 	typedef TTypeToMessageId<KNullMessageId, 0> TNullMessageId;
       
   218 
       
   219 	template<typename MSG>
       
   220 	TBool IsMessage()
       
   221 		{
       
   222 		return iMessageId.iId == MSG::EId && iMessageId.iRealm == MSG::ERealm;
       
   223 		}
       
   224 
       
   225 protected:
       
   226 	//We need to define the constructor or the PlacementNew (DECLARE_MVIP_CTR)
       
   227 	//will use a default one. (And initialise attributes to 0xCCCCCCCC etc).
       
   228 	TNodeSignal()
       
   229 	:	TSignalBase()
       
   230 		{
       
   231 		}
       
   232 
       
   233 	explicit TNodeSignal(const TMessageId& aMessageId)
       
   234 	:	TSignalBase(),
       
   235 	    iMessageId(aMessageId)
       
   236 		{
       
   237 		}
       
   238 
       
   239 public:
       
   240 	const TMessageId& MessageId() const
       
   241 	    {
       
   242 	    return iMessageId;
       
   243 	    }
       
   244 
       
   245 	void ClearMessageId()
       
   246 	    {
       
   247 	    iMessageId = TMessageId();
       
   248 	    }
       
   249 
       
   250 private:
       
   251 	mutable TMessageId iMessageId;
       
   252 
       
   253 public:
       
   254 	EXPORT_DATA_VTABLE_AND_FN
       
   255 	};
       
   256 
       
   257 //-=========================================================
       
   258 //
       
   259 // message_cast
       
   260 //
       
   261 //-=========================================================
       
   262 template <class MESSAGE>
       
   263 MESSAGE& message_cast(Messages::TNodeSignal& aMessage)
       
   264     {
       
   265     __ASSERT_DEBUG(aMessage.MessageId() == MESSAGE::Id() && aMessage.IsTypeOf(Meta::STypeId(MESSAGE::TypeId())), User::Panic(Messages::KMessagesPanic,Messages::EMessageCastPanic));
       
   266     return static_cast<MESSAGE&>(aMessage);
       
   267     }
       
   268 
       
   269 template <class MESSAGE>
       
   270 const MESSAGE& message_cast(const Messages::TNodeSignal& aMessage)
       
   271     {
       
   272     __ASSERT_DEBUG(aMessage.MessageId() == MESSAGE::Id() && aMessage.IsTypeOf(Meta::STypeId(MESSAGE::TypeId())), User::Panic(Messages::KMessagesPanic,Messages::EMessageCastPanic));
       
   273     return static_cast<const MESSAGE&>(aMessage);
       
   274     }
       
   275 
       
   276 template <class MESSAGE>
       
   277 MESSAGE* message_cast(Messages::TNodeSignal* aMessage)
       
   278     {
       
   279     __ASSERT_DEBUG(aMessage ,User::Panic(Messages::KMessagesPanic,Messages::EMessageCastPanic));
       
   280     return (aMessage->MessageId() == MESSAGE::Id() && aMessage->IsTypeOf(Meta::STypeId(MESSAGE::TypeId()))) ?
       
   281     	static_cast<MESSAGE*>(aMessage) :
       
   282     	NULL;
       
   283     }
       
   284 
       
   285 template <class MESSAGE>
       
   286 const MESSAGE* message_cast(const Messages::TNodeSignal* aMessage)
       
   287     {
       
   288     __ASSERT_DEBUG(aMessage,User::Panic(Messages::KMessagesPanic,Messages::EMessageCastPanic));
       
   289     return (aMessage->MessageId() == MESSAGE::Id() && aMessage->IsTypeOf(Meta::STypeId(MESSAGE::TypeId()))) ?
       
   290 	    static_cast<const MESSAGE*>(aMessage) :
       
   291 	    NULL;
       
   292     }
       
   293 
       
   294 //
       
   295 // TSignatureBase
       
   296 //
       
   297 class TSignatureBase : public TNodeSignal
       
   298 	{
       
   299 public:
       
   300 	IMPORT_C virtual void DispatchL(const TRuntimeCtxId& aSender, const TRuntimeCtxId& aRecipient);
       
   301 	IMPORT_C virtual void Error(const TRuntimeCtxId& aSender, const TRuntimeCtxId& aRecipient, TInt aError);
       
   302 
       
   303 protected:
       
   304 	//We need to define the constructor or the PlacementNew (DECLARE_MVIP_CTR)
       
   305 	//will use a default one. (And initialise attributes to 0xCCCCCCCC etc).
       
   306 	IMPORT_C explicit TSignatureBase();
       
   307 	IMPORT_C explicit TSignatureBase(const TNodeSignal::TMessageId& aMessageId);
       
   308 
       
   309 private:
       
   310 	//Forbidden ops.
       
   311 	TSignatureBase(const TSignatureBase&);
       
   312 	TSignatureBase& operator=(TSignatureBase);
       
   313 
       
   314 public:
       
   315 	DECLARE_MVIP_CTR(TSignatureBase)
       
   316 	EXPORT_DATA_VTABLE_AND_FN
       
   317 
       
   318 	// GCC enforces the C++ ISO standard rule that a class expose a public copy constructor
       
   319 	// if a temporary variable is passed as a parameter to a function by reference like this:
       
   320 	//
       
   321 	// Func( TMessage() ); // will not compile since the copy constructor is private
       
   322 	//
       
   323 	// As this class does not, we provide this CRef function so a temporary can still be
       
   324 	// passed like this:
       
   325 	//
       
   326 	// Func( TMessage().CRef() ); // use CRef() instead
       
   327 	const TSignatureBase& CRef() const
       
   328 		{
       
   329 		return *this;
       
   330 		}
       
   331 	};
       
   332 
       
   333 //
       
   334 // Signature classes
       
   335 //
       
   336 template<TInt id, TInt32 realm>
       
   337 struct TMessageSigVoid : public Messages::TSignatureBase, public Messages::TSignatureBase::TTypeToMessageId<id, realm>
       
   338     {
       
   339 	explicit TMessageSigVoid() :
       
   340 	    Messages::TSignatureBase(Messages::TNodeSignal::TMessageId(id, realm))
       
   341 	    { }
       
   342     };
       
   343 
       
   344 DECLARE_MESSAGE_SIG_1(SigNumber, TInt, Value)
       
   345 DECLARE_MESSAGE_SIG_1(SigUid, TUid, Uid)
       
   346 DECLARE_MESSAGE_SIG_1(SigAny, TAny*, Ptr)
       
   347 DECLARE_MESSAGE_SIG_1(SigNodeId, TNodeId, NodeId)
       
   348 DECLARE_MESSAGE_SIG_1(SigRMessage2, const RMessage2, Message)
       
   349 DECLARE_MESSAGE_SIG_1(SigMetaDataPtr, Meta::SMetaData*, Ptr)
       
   350 DECLARE_MESSAGE_SIG_1(SigClientType, Messages::TClientType, ClientType)
       
   351 DECLARE_MESSAGE_SIG_1(SigMessageId, TNodeSignal::TMessageId, MsgId)
       
   352 DECLARE_MESSAGE_SIG_1(SigTypeId, Meta::STypeId, TypeId)
       
   353 DECLARE_MESSAGE_SIG_2(SigNodeIdNumber, TNodeId, NodeId, TInt, Value)
       
   354 DECLARE_MESSAGE_SIG_2(SigNodeIdClientType, TNodeId, NodeId, TClientType, ClientType)
       
   355 DECLARE_MESSAGE_SIG_2(SigNumberNumber, TInt, Value1, TInt, Value2)
       
   356 DECLARE_MESSAGE_SIG_2(SigAnyNumber, TAny*, Ptr, TInt, Value)
       
   357 DECLARE_MESSAGE_SIG_2(SigUidNumber, TUid, Uid, TInt, Value)
       
   358 DECLARE_MESSAGE_SIG_2(SigNodeIdAny, TNodeId, NodeId, TAny*, Ptr)
       
   359 DECLARE_MESSAGE_SIG_2(SigNodeIdNodeId, TNodeId, NodeId1, TNodeId, NodeId2)
       
   360 DECLARE_MESSAGE_SIG_2(SigNumberRMessage2, TInt, Value, RMessage2, Message)
       
   361 DECLARE_MESSAGE_SIG_2(SigClientTypeUid, Messages::TClientType, ClientType, TUid, Uid)
       
   362 DECLARE_MESSAGE_SIG_2(SigMessageIdNumber, TNodeSignal::TMessageId, MsgId, TInt, Value)
       
   363 DECLARE_MESSAGE_SIG_3(SigNodeIdNumberNumber, TNodeId, NodeId, TInt, Value1, TInt, Value2)
       
   364 DECLARE_MESSAGE_SIG_3(SigNumberNumberNumber, TInt, Value1, TInt, Value2, TInt, Value3)
       
   365 DECLARE_MESSAGE_SIG_3(SigNodeIdNodeIdNumber, TNodeId, NodeId1, TNodeId, NodeId2, TInt, Value)
       
   366 DECLARE_MESSAGE_SIG_3(SigNumberUidNumber, TInt, Value1, TUid, Uid, TInt, Value2)
       
   367 DECLARE_MESSAGE_SIG_3(SigClientTypeUidClientType, Messages::TClientType, ClientType1, TUid, Uid, Messages::TClientType, ClientType2)
       
   368 DECLARE_MESSAGE_SIG_3(SigTypeIdAnyNumber, Meta::STypeId, TypeId, TAny*, Ptr, TInt, Value)
       
   369 DECLARE_MESSAGE_SIG_4(SigNumberNumberNumberNumber, TInt, Value1, TInt, Value2, TInt, Value3, TInt, Value4)
       
   370 DECLARE_MESSAGE_SIG_4(SigNodeIdNumberNumberNumber, TNodeId, NodeId, TInt, Value1, TInt, Value2, TInt, Value3)
       
   371 
       
   372 template<TInt id, TInt32 realm>
       
   373 class TMessageExtensionRMessage2 : public TSigNumberRMessage2, public TSignatureBase::TTypeToMessageId<id, realm>
       
   374     {
       
   375 public:
       
   376 	TMessageExtensionRMessage2(TInt aMsgId, const RMessage2& aMessage)
       
   377 	:	TSigNumberRMessage2(TNodeSignal::TMessageId(id, realm), aMsgId, aMessage) {}
       
   378 	inline TInt ExtensionMsgId() const
       
   379 		{
       
   380 		return iValue;
       
   381 		}
       
   382 
       
   383 protected:
       
   384 	TMessageExtensionRMessage2()
       
   385 	:	TSigNumberRMessage2()
       
   386 		{}
       
   387     };
       
   388 
       
   389 template<TInt id, TInt32 realm, TInt defValue = 0>
       
   390 class TMessageSigNumberDefault : public TSigNumber, public TSignatureBase::TTypeToMessageId<id, realm>
       
   391     {
       
   392 public:
       
   393     enum { EDefValue = defValue };
       
   394 	TMessageSigNumberDefault(TInt aValue = defValue)
       
   395 	:	TSigNumber(TNodeSignal::TMessageId(id, realm), aValue)
       
   396 		{}
       
   397     };
       
   398 
       
   399 template<TInt id, TInt32 realm, TInt defValue = 0>
       
   400 class TMessageSigNumberNumberDefault : public TSigNumberNumber, public TSignatureBase::TTypeToMessageId<id, realm>
       
   401     {
       
   402 public:
       
   403     enum { EDefValue = defValue };
       
   404 	TMessageSigNumberNumberDefault(TInt aValue1, TInt aValue2 = defValue)
       
   405 	:	TSigNumberNumber(TNodeSignal::TMessageId(id, realm), aValue1, aValue2)
       
   406 		{}
       
   407     };
       
   408 
       
   409 template<TInt id, TInt32 realm, TInt defValue1 = 0, TInt defValue2 = 0>
       
   410 class TMessageSigNumberDefaultNumberDefault : public TSigNumberNumber, public TSignatureBase::TTypeToMessageId<id, realm>
       
   411     {
       
   412 public:
       
   413     enum { EDefValue1 = defValue1, EDefValue2 = defValue2 };
       
   414 	TMessageSigNumberDefaultNumberDefault(TInt aValue1 = defValue1, TInt aValue2 = defValue2)
       
   415 	:	TSigNumberNumber(TNodeSignal::TMessageId(id, realm), aValue1, aValue2)
       
   416 		{}
       
   417     };
       
   418 
       
   419 template<TInt id, TInt32 realm, TInt defValue = 0>
       
   420 class TMessageSigAnyNumberDefault : public TSigAnyNumber, public TSignatureBase::TTypeToMessageId<id, realm>
       
   421     {
       
   422 public:
       
   423     enum { EDefValue = defValue };
       
   424 	TMessageSigAnyNumberDefault(TAny* aPtr, TInt aValue = defValue)
       
   425 	:	TSigAnyNumber(TNodeSignal::TMessageId(id, realm), aPtr, aValue)
       
   426 		{}
       
   427     };
       
   428 
       
   429 template<TInt id, TInt32 realm, TInt defValue1 = 0>
       
   430 class TMessageSigNodeIdNumberDefault : public TSigNodeIdNumber, public TSignatureBase::TTypeToMessageId<id, realm>
       
   431     {
       
   432 public:
       
   433     TMessageSigNodeIdNumberDefault(const TNodeId& aNodeId, TInt aValue = defValue1)
       
   434     :   TSigNodeIdNumber(TNodeSignal::TMessageId(id, realm), aNodeId, aValue)
       
   435         {}
       
   436     };
       
   437 
       
   438 template<TInt id, TInt32 realm, TInt defValue1 = 0, TInt defValue2 = 0>
       
   439 class TMessageSigNodeIdNumberDefaultNumberDefault : public TSigNodeIdNumberNumber, public TSignatureBase::TTypeToMessageId<id, realm>
       
   440     {
       
   441 public:
       
   442 	TMessageSigNodeIdNumberDefaultNumberDefault(const TNodeId& aNodeId, TInt aValue1 = defValue1, TInt aValue2 = defValue2)
       
   443 	:	TSigNodeIdNumberNumber(TNodeSignal::TMessageId(id, realm), aNodeId, aValue1, aValue2)
       
   444 		{}
       
   445     };
       
   446 
       
   447 template<TInt id, TInt32 realm>
       
   448 struct TMessageSigNum24Num8 : protected TSigNumber, public TSignatureBase::TTypeToMessageId<id, realm>
       
   449     {
       
   450 	explicit TMessageSigNum24Num8(TInt aValue24, TInt aValue8) :
       
   451 	    TSigNumber(TNodeSignal::TMessageId(id, realm), (aValue24<<8)|(aValue8&0xFF)){}
       
   452 
       
   453 	TUint Value24() const { return iValue>>8;}
       
   454 	TUint Value8() const { return iValue&0xFF;}
       
   455     };
       
   456 
       
   457 //
       
   458 // Signature classes - helper classes
       
   459 //
       
   460 class TVCFromGlobalsMessagePayloadCreationPolicy
       
   461 	{
       
   462 public:
       
   463 	IMPORT_C static Meta::SMetaData* New(TPtrC8& aSrc, TPtr8& aDst);
       
   464 	};
       
   465 
       
   466 class TSignatureWithPolymorphicPayloadMetaTypeBase : public Meta::MMetaType
       
   467 	{
       
   468 protected:
       
   469 	IMPORT_C TSignatureWithPolymorphicPayloadMetaTypeBase(TUint8* aData, Meta::SMetaData** aPayload, TInt aHostSize);
       
   470 	IMPORT_C TInt InternalLoad(TPtrC8& aBuffer, TDes8& aTempBuffer);
       
   471 	IMPORT_C virtual TInt Store(TDes8& aBuffer) const;
       
   472 	IMPORT_C virtual void Copy(const TAny* aData);
       
   473 	IMPORT_C virtual TInt Length() const;
       
   474 
       
   475 protected:
       
   476 	TUint8* iData;
       
   477 	Meta::SMetaData** iPayload;
       
   478 	TInt iHostSize;
       
   479 	};
       
   480 
       
   481 /**
       
   482 The class that determins how the payload will be loaded. A templated class that says the payload attribute offset and
       
   483 the payload atrribute creation class ( Policy class ). The loading of the payload will be determined by the attribute
       
   484 creation class.
       
   485 
       
   486 Template parameters:
       
   487 class TSIGNATURE - The signature class.
       
   488 TInt PAYLOADATTRIBOFFSET - The offset where the payload is persent in the signature class.
       
   489 class TATTRIBUTECREATIONPOLICY - This class determines how the payload should be constructued. The attribute policty class
       
   490 should implement the Meta::SMetaData* New(TPtrC8& aSrc, TPtr8& aDst) function.
       
   491 TInt PAYLOADBUFFERMAXLEN - The maximum payload length. Used internally during the load time.
       
   492 
       
   493 @internalTechnology
       
   494 */
       
   495 template <class TSIGNATURE, TInt PAYLOADATTRIBOFFSET, class TATTRIBUTECREATIONPOLICY, TInt PAYLOADBUFFERMAXLEN = TSignalBase::KMaxInlineMessageSize>
       
   496 class TSignatureWithPolymorphicPayloadMetaType : public TSignatureWithPolymorphicPayloadMetaTypeBase
       
   497 {
       
   498 public:
       
   499 	inline static MMetaType* NewL(const TAny* aMem, const TAny* aData)
       
   500 		{
       
   501 		// For some reason this assertion does not compile under x86gcc which complains
       
   502 		// that a default template argument has been specified for a templated member
       
   503 		// function.  There is no such function so this is probably a parser bug.
       
   504 		#if !defined(__GCCXML__) && !defined(__X86GCC__)
       
   505 			__ASSERT_COMPILE(PAYLOADATTRIBOFFSET == __Align8(PAYLOADATTRIBOFFSET)); //must be alligned!
       
   506 		#endif
       
   507 		return ::new ((TUint8*)aMem) TSignatureWithPolymorphicPayloadMetaType(aData);
       
   508 		}
       
   509 
       
   510 	inline virtual TInt Load(TPtrC8& aBuffer)
       
   511 		{
       
   512 		TBuf8<PAYLOADBUFFERMAXLEN> buffer;
       
   513 		TInt error = TSignatureWithPolymorphicPayloadMetaTypeBase::InternalLoad(aBuffer, buffer);
       
   514 		if (error == KErrNone && buffer.Length() > 0)
       
   515 			{
       
   516 			TPtrC8 src(buffer);
       
   517 			TPtr8 dst(iData + iHostSize, buffer.Length()); //always enough since the STypeId is bigger than the virtual table ptr etc
       
   518 			*iPayload = TATTRIBUTECREATIONPOLICY::New(src, dst);
       
   519 			}
       
   520 		return error;
       
   521 		}
       
   522 
       
   523 private:
       
   524 	TSignatureWithPolymorphicPayloadMetaType(const TAny* aData)
       
   525 	:	TSignatureWithPolymorphicPayloadMetaTypeBase(const_cast<TUint8*>(reinterpret_cast<const TUint8*>(aData) + sizeof(Meta::SMetaData*) - PAYLOADATTRIBOFFSET),
       
   526 	                                                 const_cast<Meta::SMetaData**>(reinterpret_cast<Meta::SMetaData* const*>(aData)),
       
   527 	                                                 sizeof(TSIGNATURE) - sizeof(TSignalBase))
       
   528 		{
       
   529 		}
       
   530 	};
       
   531 
       
   532 } // namespace Messages
       
   533 
       
   534 #endif // SYMBIAN_NM_SIGNATURE_H
       
   535