|
1 // Copyright (c) 1997-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 // |
|
15 |
|
16 #include <coemop.h> |
|
17 |
|
18 /** Safety check to avoid loops in the Mop chain. |
|
19 */ |
|
20 MObjectProvider* MObjectProvider::FindParent(MObjectProvider* aMopToFind) |
|
21 { |
|
22 MObjectProvider* mop = this; |
|
23 while (mop && mop!= aMopToFind) |
|
24 { |
|
25 mop = mop->MopNext(); |
|
26 } |
|
27 return mop; |
|
28 } |
|
29 |
|
30 /** Gets the parent object provider. |
|
31 |
|
32 This is called by the private function MopGetById() when a call to |
|
33 MopGetObject() returns NULL. |
|
34 |
|
35 The default implementation returns NULL. Note that care must be taken |
|
36 to avoid infinite loops. For example, returning a pointer, either |
|
37 directly or indirectly, to this same object provider. |
|
38 |
|
39 @return A pointer to the parent object provider, or NULL if there is none. |
|
40 @publishedAll |
|
41 @released */ |
|
42 EXPORT_C MObjectProvider* MObjectProvider::MopNext() |
|
43 { |
|
44 return NULL; |
|
45 } |
|
46 |
|
47 |
|
48 /** Gets an object of a type identified by the specified TTypeUid object. |
|
49 |
|
50 Although private, the implementation tries to find a suitable object through |
|
51 a call to MopSupplyObject(). If this returns NULL, it calls MopNext() to find |
|
52 a parent object provider, and then recursively calls MopGetById(), until an object |
|
53 is found, or no further parents can be found. |
|
54 |
|
55 Note that we should preserve Binary Compatibility for this function because it |
|
56 is called by the publishedAll inline function MObjectProvider::MopGetObject(). |
|
57 |
|
58 @param aId A unique identifier which identifies the type of object required. |
|
59 @return The owned object of the given type ID. If no owned object of the given |
|
60 type ID exists, NULL is returned. |
|
61 @internalComponent */ |
|
62 EXPORT_C TAny* MObjectProvider::MopGetById(TTypeUid aId) |
|
63 { |
|
64 TAny* obj = MopSupplyObject(aId).Pointer(); |
|
65 |
|
66 if (obj) |
|
67 return obj; |
|
68 |
|
69 MObjectProvider* next = MopNext(); |
|
70 if (next) |
|
71 return next->MopGetById(aId); |
|
72 |
|
73 return NULL; |
|
74 } |
|
75 |
|
76 |
|
77 /** Gets an object of a type identified by the specified TTypeUid object. It does not |
|
78 recurse through the object provider chain to find the object required. If this object |
|
79 cannot provide it then it returns NULL. |
|
80 |
|
81 Although private, the implementation tries to find a suitable object through |
|
82 a call to MopSupplyObject(), and if this returns NULL, this function returns NULL. |
|
83 |
|
84 Note that we should preserve Binary Compatibility for this function because it |
|
85 is called by the publishedAll inline function MObjectProvider::MopGetObjectNoChaining(). |
|
86 |
|
87 @param aId A unique identifier which identifies the type of object required. |
|
88 @return The owned object of the given type ID. If no owned object of the given |
|
89 type ID exists, NULL is returned. |
|
90 @internalComponent */ |
|
91 EXPORT_C TAny* MObjectProvider::MopGetByIdNoChaining(TTypeUid aId) |
|
92 { |
|
93 TAny* obj = MopSupplyObject(aId).Pointer(); |
|
94 return obj; |
|
95 } |
|
96 |
|
97 |
|
98 EXPORT_C MObjectProvider::MObjectProvider() |
|
99 { |
|
100 } |
|
101 |
|
102 EXPORT_C void MObjectProvider::MObjectProvider_Reserved1() |
|
103 { |
|
104 } |
|
105 |
|
106 EXPORT_C void MObjectProvider::MObjectProvider_Reserved2() |
|
107 { |
|
108 } |
|
109 |