MObjectProvider Class Reference

class MObjectProvider

An interface that allows an object to be part of a network of object providers.

The object provider mechanism can be used to find and access objects of a given type, where the type is defined by a TTypeUid object. Object providers may be arranged in a hierarchy, i.e. an object provider may have a parent-child relationship with another object provider.

An object provider must provide an implementation for the MopSupplyObject() function and can choose to provide an implementation for the MopNext() function. Typically, it will also have functionality to define who its parent is.

CCoeControl is an example of a class that implements this interface. Top level controls must have the view or app UI set as their object provider. This is done by calling CCoeControl::SetMopParent() on the view or the app UI. The view or app UI does this by calling the top level control's CCoeControl::SetMopParent() function.

Public Member Functions
MObjectProvider *FindParent(MObjectProvider *)
T *MopGetObject(T *&)
T *MopGetObjectNoChaining(T *&)
Protected Member Functions
MObjectProvider()
Private Member Functions
IMPORT_C voidMObjectProvider_Reserved1()
IMPORT_C voidMObjectProvider_Reserved2()
IMPORT_C TAny *MopGetById(TTypeUid)
IMPORT_C TAny *MopGetByIdNoChaining(TTypeUid)
IMPORT_C MObjectProvider *MopNext()
TTypeUid::Ptr MopSupplyObject(TTypeUid)
Private Attributes
TInt iMObjectProvider_Reserved1

Constructor & Destructor Documentation

MObjectProvider()

IMPORT_CMObjectProvider()[protected]

Member Functions Documentation

FindParent(MObjectProvider *)

MObjectProvider *FindParent(MObjectProvider *aMopToFind)

Safety check to avoid loops in the Mop chain.

Parameters

MObjectProvider * aMopToFind

MObjectProvider_Reserved1()

IMPORT_C voidMObjectProvider_Reserved1()[private, virtual]

MObjectProvider_Reserved2()

IMPORT_C voidMObjectProvider_Reserved2()[private, virtual]

MopGetById(TTypeUid)

IMPORT_C TAny *MopGetById(TTypeUidaId)[private]

Gets an object of a type identified by the specified TTypeUid object.

Although private, the implementation tries to find a suitable object through a call to MopSupplyObject(). If this returns NULL, it calls MopNext() to find a parent object provider, and then recursively calls MopGetById(), until an object is found, or no further parents can be found.

Note that we should preserve Binary Compatibility for this function because it is called by the publishedAll inline function MObjectProvider::MopGetObject().

Parameters

TTypeUid aIdA unique identifier which identifies the type of object required.

MopGetByIdNoChaining(TTypeUid)

IMPORT_C TAny *MopGetByIdNoChaining(TTypeUidaId)[private]

Gets an object of a type identified by the specified TTypeUid object. It does not recurse through the object provider chain to find the object required. If this object cannot provide it then it returns NULL.

Although private, the implementation tries to find a suitable object through a call to MopSupplyObject(), and if this returns NULL, this function returns NULL.

Note that we should preserve Binary Compatibility for this function because it is called by the publishedAll inline function MObjectProvider::MopGetObjectNoChaining().

Parameters

TTypeUid aIdA unique identifier which identifies the type of object required.

MopGetObject(T *&)

T *MopGetObject(T *&aPtr)[inline]

Gets an object of the type defined by the template parameter.

The object may be supplied directly by this object provider, or by other object providers higher up the hierarchy.

Parameters

T *& aPtrA reference to a pointer to an object of a type that is to be retrieved.

MopGetObjectNoChaining(T *&)

T *MopGetObjectNoChaining(T *&aPtr)[inline]

Gets an object of the type defined by the template parameter.

The object will be supplied directly by this object provider, or NULL will be returned, this function does not recurse through the object chain.

Parameters

T *& aPtrA reference to a pointer to an object of a type that is to be retrieved.

MopNext()

IMPORT_C MObjectProvider *MopNext()[private, virtual]

Gets the parent object provider.

This is called by the private function MopGetById() when a call to MopGetObject() returns NULL.

The default implementation returns NULL. Note that care must be taken to avoid infinite loops. For example, returning a pointer, either directly or indirectly, to this same object provider.

MopSupplyObject(TTypeUid)

TTypeUid::Ptr MopSupplyObject(TTypeUidaId)[private, pure virtual]

Gets an object whose type is encapsulated by the specified TTypeUid object.

Parameters

TTypeUid aIdEncapsulates the Uid that identifies the type of object required.

Member Data Documentation

TInt iMObjectProvider_Reserved1

TInt iMObjectProvider_Reserved1[private]