diff -r 43e37759235e -r 51a74ef9ed63 Symbian3/SDK/Source/GUID-F94CEC6D-C602-550F-9B12-856493F3C509.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-F94CEC6D-C602-550F-9B12-856493F3C509.dita Wed Mar 31 11:11:55 2010 +0100 @@ -0,0 +1,60 @@ + + + + + +Implementing an Interface An interface implementation is a single unit of functionality that is instantiated through the interface definition. An implementation is created by deriving a class from the interface definition, and implementing its functions. An interface implementation actually provides the services defined by the interface. Derive a class from the interface definition. Implement the object creation functions like NewL() or ConstructL() for the derived class. Call the appropiate REComSession::CreateImplementationL() function to instantiate an interface implementation that satisfies the specified interface. Implement the pure virtual functions defined by the interface definition, to provide required services to clients. Creating an interface implementation example

The following code depicts an example segment of the interface definition class derived from CActive.

class CExampleInterfaceDefinition : public CActive + { +public: + // Wraps ECom object instantiation + static CExampleInterfaceDefinition* NewL(); + // Wraps ECom object destruction + virtual ~CExampleInterfaceDefinition(); + // Interface service + virtual void DoMethodL() = 0; +... +private: + // Instance identifier key or UID. + TUid iDtor_ID_Key; + };

The following code depicts a class derived from the interface definition CExampleInterfaceDefinition.

class CExampleIntImplementation : public CExampleInterfaceDefinition + { +public: + // Two-phase constructor + static CExampleIntImplementation* NewL(); + // Destructor + ~CExampleIntImplementation(); + // Implement the required methods from CExampleInterfaceDefinition + void DoMethodL(); + +private: + void ConstructL(); + };

The following code depicts the implementation of the object creation functions and virtual functions in CExampleInterfaceDefinition.

CExampleIntImplementation* CExampleIntImplementation::NewL() +{ + CExampleIntImplementaion self = new (ELeave) CExampleIntImplmentation(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; +} + +void CExampleIntImplementation::ConstructL() +{ +// specific implementation +} +CExampleIntImplementation::~CExampleIntImplementation() +{ +} + ~CExampleIntImplementation(); + +void CExampleIntImplementation::DoMethodL() +{ + // specific implementation of the DoMetholdL() +} + +
\ No newline at end of file