|
1 // Copyright (c) 2007-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 #ifndef __WSPLUGINMANAGER_H__ |
|
17 #define __WSPLUGINMANAGER_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include "Graphics/WSPLUGIN.H" |
|
21 #include <Graphics/WSGRAPHICDRAWERINTERFACE.H> |
|
22 |
|
23 /** |
|
24 The window server has a single plugin manager object, which maintains the set |
|
25 of loaded plugins. |
|
26 */ |
|
27 class CWsPluginManager : public CBase, public MWsPluginManager |
|
28 { |
|
29 private: |
|
30 class CPluginInfo : public CBase |
|
31 { |
|
32 public: |
|
33 CPluginInfo(); |
|
34 ~CPluginInfo(); |
|
35 CWsPlugin * iPlugin; |
|
36 }; |
|
37 public: |
|
38 static CWsPluginManager* NewL(); |
|
39 ~CWsPluginManager(); |
|
40 |
|
41 void InitializePluginsL(MWsGraphicDrawerEnvironment& aEnvironment); |
|
42 |
|
43 template <class T> T * FindImplementation(TInt & aStart); |
|
44 template <class T> T * FindNamedImplementation(const TDesC& aName); |
|
45 |
|
46 public: // from MWsObjectProvider: |
|
47 TAny * ResolveObjectInterface(TUint aId); |
|
48 |
|
49 public: // from MWsPluginManager |
|
50 TAny * ResolvePluginInterface(TUint aId); |
|
51 |
|
52 private: |
|
53 CWsPluginManager(); |
|
54 void ConstructL(); |
|
55 CWsPlugin * LoadPluginL(const TDesC& aSection); |
|
56 |
|
57 private: |
|
58 RPointerArray<CPluginInfo> iPlugins; |
|
59 REComSession& iSession; |
|
60 }; |
|
61 |
|
62 /** |
|
63 This searches for any plugin which implements a specified interface. |
|
64 Calling this function modifies the value of aStart, and passing it back in |
|
65 allows the next implementation to be found. |
|
66 */ |
|
67 template <class T> T * CWsPluginManager::FindImplementation(TInt & aStart) |
|
68 { |
|
69 while (aStart < iPlugins.Count()) |
|
70 { |
|
71 T * impl = iPlugins[aStart]->iPlugin->ObjectInterface<T>(); |
|
72 ++aStart; |
|
73 if (impl) |
|
74 { |
|
75 return impl; |
|
76 } |
|
77 } |
|
78 return NULL; |
|
79 } |
|
80 |
|
81 /** |
|
82 This searches for any plugin which implements a specified interface and |
|
83 has the specified name returned from PluginName. |
|
84 |
|
85 Maybe plugin name should be a function on an MWsNamed class instead of CWsPlugin? |
|
86 */ |
|
87 template <class T> T * CWsPluginManager::FindNamedImplementation(const TDesC& aName) |
|
88 { |
|
89 TInt pos = 0; |
|
90 while (pos < iPlugins.Count()) |
|
91 { |
|
92 T * impl = iPlugins[pos]->iPlugin->ObjectInterface<T>(); |
|
93 if (impl && iPlugins[pos]->iPlugin->PluginName() == aName) |
|
94 { |
|
95 return impl; |
|
96 } |
|
97 ++pos; |
|
98 } |
|
99 return NULL; |
|
100 } |
|
101 |
|
102 #endif // __WSPLUGINMANAGER_H__ |