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.
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() }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.