|
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 /** |
|
17 @file |
|
18 @internalAll |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef SYMBIAN_FACTORY_H |
|
23 #define SYMBIAN_FACTORY_H |
|
24 |
|
25 #include <elements/nm_node.h> |
|
26 #include <elements/factoryobject.h> |
|
27 |
|
28 namespace Factories |
|
29 { |
|
30 class CFactoryBase; |
|
31 class CFactoryContainer; |
|
32 typedef CFactoryBase* (*TFACTORYCONSTRUCTOR)(const TDesC8&, CFactoryContainer&); |
|
33 class IFactoryNotify; |
|
34 |
|
35 |
|
36 class CFactoryContainer : public CBase |
|
37 /** Factory Factory Container class is used to store factory objects of a |
|
38 specific type. It provides basic functionality to find, add and remove factories. |
|
39 |
|
40 @internalAll |
|
41 */ |
|
42 { |
|
43 friend class CFactoryBase; |
|
44 |
|
45 public: |
|
46 IMPORT_C CFactoryBase* FindFactory(TUid aFactoryUid) const; |
|
47 IMPORT_C ~CFactoryContainer(); |
|
48 IMPORT_C void RegisterNotifierL(TUid aFactoryUid, const IFactoryNotify& aFactoryNotify); |
|
49 IMPORT_C virtual NetInterfaces::TInterfaceControl* FetchNodeInterfaceControlL(TInt aInterfaceId); |
|
50 |
|
51 protected: |
|
52 IMPORT_C explicit CFactoryContainer(); |
|
53 IMPORT_C void AddL(CFactoryBase& aFactory); |
|
54 IMPORT_C CFactoryBase* Factory(TInt aIndex) const; //checks if the aIndex is within the range |
|
55 IMPORT_C AFactoryObject* FindObject(MFactoryQuery& aQuery) const; |
|
56 |
|
57 private: |
|
58 RPointerArray<CFactoryBase> iFactories; |
|
59 }; |
|
60 |
|
61 |
|
62 class CFactoryContainerNode : public CFactoryContainer, |
|
63 public Messages::ASimpleNodeIdBase |
|
64 /** Factory Factory Container class is used to store factory objects of a |
|
65 specific type. It provides basic functionality to find, add and remove factories. |
|
66 |
|
67 @internalAll |
|
68 */ |
|
69 { |
|
70 public: |
|
71 IMPORT_C ~CFactoryContainerNode(); |
|
72 |
|
73 protected: |
|
74 IMPORT_C explicit CFactoryContainerNode(); |
|
75 }; |
|
76 |
|
77 |
|
78 class CFactoryBase : public CBase, |
|
79 public NetInterfaces::AApiExtBase |
|
80 /** Factory Base class provides basic object managment |
|
81 functionlity and the ability for a factory to be load from another |
|
82 Dynamic Linked Library via the ECOM framework. |
|
83 |
|
84 It also provides asynchronous destruction for it's managed objects (if |
|
85 required) but also copes with synchronous destruction, should a managed |
|
86 object get deleted by another entity. |
|
87 |
|
88 @internalAll |
|
89 */ |
|
90 { |
|
91 friend class AFactoryObject; |
|
92 friend class CFactoryContainer; |
|
93 friend class RPointerArray<CFactoryBase>; |
|
94 |
|
95 public: |
|
96 IMPORT_C static CFactoryBase* NewL(const TDesC8& aName, const TUid& aInterfaceUid, CFactoryContainer& aParentContainer); |
|
97 IMPORT_C static CFactoryBase* NewL(const TUid& aImplementationUid, CFactoryContainer& aParentContainer); |
|
98 IMPORT_C TUid Uid() const; |
|
99 CFactoryContainer& ParentContainer() {return iParentContainer;} |
|
100 |
|
101 IMPORT_C void RegisterNotifierL(const IFactoryNotify& aFactoryNotify); |
|
102 IMPORT_C void DeRegisterNotifier(const IFactoryNotify& aFactoryNotify); |
|
103 |
|
104 protected: |
|
105 IMPORT_C explicit CFactoryBase(TUid aFactoryUid, CFactoryContainer& aParentContainer); |
|
106 IMPORT_C ~CFactoryBase(); |
|
107 IMPORT_C void ConstructL(const TUid& aDestroyUid); |
|
108 IMPORT_C void ConstructL(); |
|
109 |
|
110 //Removes aObject from the factory (doesn't delete the object). |
|
111 IMPORT_C void RemoveManagedObject(AFactoryObject& aObject); |
|
112 //Marks aObject for deletion. The object will not be served by 'this' from now on. |
|
113 IMPORT_C void ManagedObjectBeingDeleted(AFactoryObject& aObject); |
|
114 IMPORT_C TFactoryObjectEntry& AddManagedObjectL(AFactoryObject& aObject); |
|
115 IMPORT_C AFactoryObject* FindObject(MFactoryQuery& aQuery) const; |
|
116 |
|
117 private: |
|
118 IMPORT_C void SignalDeletion(AFactoryObject& aObject); |
|
119 IMPORT_C TInt SignalCreation(AFactoryObject& aObject); |
|
120 void RemoveManagedObject(TInt aIndex); |
|
121 |
|
122 private: |
|
123 CFactoryContainer& iParentContainer; |
|
124 TUid iFactoryUid; |
|
125 RArray<TFactoryObjectEntry> iObjects; |
|
126 TUid iDestroyUid; |
|
127 protected: |
|
128 RArray<IFactoryNotify> iFactoryNotify; // accessed by shimcpr for InterfaceStateChange |
|
129 }; |
|
130 |
|
131 template <class FACTORY_OBJECT_TYPE> |
|
132 FACTORY_OBJECT_TYPE* factoryobject_cast(AFactoryObject* aFactoryObject) |
|
133 { |
|
134 return aFactoryObject && TUid::Uid(FACTORY_OBJECT_TYPE::FactoryType::iUid) == aFactoryObject->Factory().Uid() ? |
|
135 static_cast<FACTORY_OBJECT_TYPE*>(aFactoryObject) : NULL; |
|
136 }; |
|
137 |
|
138 template <class FACTORY_OBJECT_TYPE> |
|
139 FACTORY_OBJECT_TYPE* factoryobject_cast(const AFactoryObject* aFactoryObject) |
|
140 { |
|
141 return aFactoryObject && TUid::Uid(FACTORY_OBJECT_TYPE::FactoryType::iUid) == aFactoryObject->Factory().Uid() ? |
|
142 static_cast<FACTORY_OBJECT_TYPE*>(aFactoryObject) : NULL; |
|
143 } |
|
144 |
|
145 } //namespace Factories |
|
146 |
|
147 #endif |
|
148 //SYMBIAN_FACTORY_H |
|
149 |