Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Using CBaseServerMtm

CBaseServerMtm implementations should define a factory function that is called by the Message Server to create a new instance of the Server-side MTM.

The definition varies between ER5 and later versions.


Factory function

<concrete-type>* <concrete-type>::<function-name>(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aInitialEntry);


Requirements

A concrete Server-side MTM must implement an exported factory function conforming to this signature. This function is not declared in the base class. It is typically named NewL(), to conform to the general pattern for EPOC two-phase construction functions. It is called by the Server-side MTM registry when a client requests this Server-side MTM.

The function should create a new instance of the CBaseServerMtm-derived class that provides the implementation, and perform any dynamic allocation required. The arguments received should be passed to the constructor.

The function is called by ordinal. The ordinal of the function must match that recorded in the MTM’s registry information. See CMtmDllInfo for details.

For pre-Unicode variants see the previous factory function definition.


Arguments

CRegisteredMtmDll& aRegisteredMtmDll

Registration data for the MTM DLL

CMsvServerEntry* aInitialEntry

Context on which to operate


Return value

A newly-created instance of the CBaseServerMtm-derived class for the Server-side MTM.


Leave considerations

The factory function should leave if it cannot create the object.


Example

For example, a Server-side MTM whose concrete class was CEgMtmServ could define a suitable factory function as:

EXPORT_C CEgMtmServ* CEgMtmServ::NewL(CRegisteredMtmDll& aRegisteredMtmDll,CMsvServerEntry* aInitialEntry)
 {
 CleanupStack::PushL(aInitialEntry);
 CEgMtmServ* egSvrMtm=new(ELeave) CEgMtmServ
  (aRegisteredMtmDll, aInitialEntry);
 CleanupStack::Pop();

 CleanupStack::PushL(egSvrMtm);
 egSvrMtm->ConstructL();
 CleanupStack::Pop();
 return egSvrMtm;
 }

[Top]


EPOC R5 factory function

<concrete-type>* <concrete-type>::<function-name>(CRegisteredMtmDll& aRegisteredMtmDll);


Requirements

A concrete Server-side MTM must implement an exported factory function conforming to this signature. This function is not declared in the base class. It is typically named NewL(), to conform to the general pattern for EPOC two-phase construction functions. It is called by the Server-side MTM registry when a client requests this Server-side MTM.

The function should create a new instance of the CBaseServerMtm-derived class that provides the implementation, and perform any dynamic allocation required. The argument received should be passed to the constructor.

The function is called by ordinal. The ordinal of the function must match that recorded in the MTM’s registry information. See CMtmDllInfo for details.


Arguments

CRegisteredMtmDll& aRegisteredMtmDll

Registration data for the MTM DLL


Return value

A newly-created instance of the CBaseServerMtm-derived class for the Server-side MTM.


Leave considerations

The factory function should leave if it cannot create the object.


Example

For example, a Server-side MTM whose concrete class was CEgMtmServ could define a suitable factory function as:

EXPORT_C CEgMtmServ* CEgMtmServ::NewL(CRegisteredMtmDll& aRegisteredMtmDll)
 {
 CEgMtmServ* egSvrMtm=new(ELeave) CEgMtmServ(aRegisteredMtmDll);
 CleanupStack::PushL(egSvrMtm);
 egSvrMtm->ConstructL();
 CleanupStack::Pop();
 return egSvrMtm;
 }