|
1 // Copyright (c) 2005-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 @internalTechnology |
|
19 */ |
|
20 |
|
21 #ifndef SYMBIAN_VC_H |
|
22 #define SYMBIAN_VC_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <e32std.h> |
|
26 #include <ecom/implementationproxy.h> // for TImplementationProxy |
|
27 |
|
28 //VIP == "virtual-ctor in place" |
|
29 |
|
30 #define DECLARE_MVIP_CTR(class_name) \ |
|
31 static class_name* PlacementNew(TDes8& aBuff); |
|
32 |
|
33 #define DEFINE_MVIP_CTR(class_name) \ |
|
34 class_name* class_name::PlacementNew(TDes8& aBuff) \ |
|
35 { \ |
|
36 return new(aBuff) class_name; \ |
|
37 } |
|
38 |
|
39 #define MVIP_CTR_ENTRY(aInterfaceUid, aMessageClass) {{aInterfaceUid},(TProxyNewLPtr)(aMessageClass::PlacementNew)} |
|
40 |
|
41 namespace Meta |
|
42 { |
|
43 struct STypeId; |
|
44 } |
|
45 |
|
46 namespace VC |
|
47 { |
|
48 |
|
49 class CVirtualCtorBase : public CBase |
|
50 { |
|
51 public: |
|
52 IMPORT_C CVirtualCtorBase(); |
|
53 IMPORT_C ~CVirtualCtorBase(); |
|
54 IMPORT_C void RegisterInterfaceL(TUid aInterfaceId, TInt aNumCtors, const TImplementationProxy* aCtorTable); |
|
55 IMPORT_C void DeregisterInterface(TUid aInterfaceId); |
|
56 IMPORT_C TBool IsInterfaceRegistered(TUid aInterfaceId) const; |
|
57 |
|
58 protected: |
|
59 IMPORT_C TProxyNewLPtr FindRawCtor(const Meta::STypeId& aType) const; |
|
60 |
|
61 private: |
|
62 class TCtorTable |
|
63 { |
|
64 public: |
|
65 TCtorTable(TUid aInterfaceId, TInt aNumCtors, const TImplementationProxy* aCtorTable) |
|
66 : iInterfaceId(aInterfaceId), |
|
67 iNumCtors(aNumCtors), |
|
68 iRegisteredCount(1), |
|
69 iCtorTable(aCtorTable) |
|
70 { |
|
71 } |
|
72 public: |
|
73 TUid iInterfaceId; |
|
74 TInt iNumCtors; |
|
75 mutable TInt iRegisteredCount; |
|
76 const TImplementationProxy* iCtorTable; |
|
77 }; |
|
78 typedef RArray<TCtorTable> TCtorTableList; |
|
79 TCtorTableList iCtorTableList; |
|
80 private: |
|
81 const TCtorTable* FindCtorTable(TUid aInterfaceId, TInt& aIndex) const; |
|
82 }; |
|
83 |
|
84 typedef TAny* (*TInPlaceNewPtr)(TDes8& aBuff); |
|
85 |
|
86 class CVirtualCtorInPlace : public CVirtualCtorBase |
|
87 { |
|
88 public: |
|
89 //Constructs only from the type |
|
90 IMPORT_C TAny* New(const Meta::STypeId& aType, TDes8& aBuff) const; |
|
91 |
|
92 inline const TInPlaceNewPtr FindCtor(const Meta::STypeId& aType) const |
|
93 { |
|
94 return reinterpret_cast<const TInPlaceNewPtr>(FindRawCtor(aType)); |
|
95 } |
|
96 }; |
|
97 |
|
98 |
|
99 } //namespace VC |
|
100 |
|
101 #endif |
|
102 //SYMBIAN_VC_H |
|
103 |