sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Implements a custom resolver CClientRequestPerfTestResolver for use during resolver performance tests.
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@internalComponent
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <ecom/ecom.h>
|
sl@0
|
23 |
#include "ImplementationProxy.h"
|
sl@0
|
24 |
#include "EComClientRequestPerfTestResolver.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
CClientRequestPerfTestResolver* CClientRequestPerfTestResolver::NewL(MPublicRegistry& aRegistry)
|
sl@0
|
27 |
{
|
sl@0
|
28 |
return new(ELeave) CClientRequestPerfTestResolver(aRegistry);
|
sl@0
|
29 |
}
|
sl@0
|
30 |
|
sl@0
|
31 |
CClientRequestPerfTestResolver::~CClientRequestPerfTestResolver()
|
sl@0
|
32 |
{
|
sl@0
|
33 |
if(iImplementationInfoArray)
|
sl@0
|
34 |
{
|
sl@0
|
35 |
iImplementationInfoArray->Reset();
|
sl@0
|
36 |
delete iImplementationInfoArray;
|
sl@0
|
37 |
}
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
CClientRequestPerfTestResolver::CClientRequestPerfTestResolver(MPublicRegistry& aRegistry)
|
sl@0
|
41 |
: CResolver(aRegistry)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
// Do nothing here
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
TUid CClientRequestPerfTestResolver::IdentifyImplementationL(TUid aInterfaceUid,
|
sl@0
|
47 |
const TEComResolverParams& aAdditionalParameters) const
|
sl@0
|
48 |
{
|
sl@0
|
49 |
RImplInfoArray& implementationsInfo = iRegistry.ListImplementationsL(aInterfaceUid);
|
sl@0
|
50 |
TUid found = KNullUid;
|
sl@0
|
51 |
if(implementationsInfo.Count())
|
sl@0
|
52 |
{
|
sl@0
|
53 |
found = Resolve(implementationsInfo, aAdditionalParameters);
|
sl@0
|
54 |
}
|
sl@0
|
55 |
return found;
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
TUid CClientRequestPerfTestResolver::Resolve(const RImplInfoArray& aImplementationsInfo,
|
sl@0
|
59 |
const TEComResolverParams& aAdditionalParameters) const
|
sl@0
|
60 |
{
|
sl@0
|
61 |
// Loop through the implementations matching on type
|
sl@0
|
62 |
const TInt count = aImplementationsInfo.Count();
|
sl@0
|
63 |
for(TInt index = 0; index < count; ++index)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
const CImplementationInformation& impData = *aImplementationsInfo[index];
|
sl@0
|
66 |
// As soon as we get a match on the datatype then return uid of the
|
sl@0
|
67 |
// implementation found.
|
sl@0
|
68 |
if (Match(impData.DataType(), // The Datatype of this implementation
|
sl@0
|
69 |
aAdditionalParameters.DataType(), // The type we are trying to find
|
sl@0
|
70 |
aAdditionalParameters.IsGenericMatch())) // If wildcards should be used
|
sl@0
|
71 |
return impData.ImplementationUid();
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
return KNullUid;
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
RImplInfoArray* CClientRequestPerfTestResolver::ListAllL(TUid aInterfaceUid,
|
sl@0
|
78 |
const TEComResolverParams& aAdditionalParameters) const
|
sl@0
|
79 |
{
|
sl@0
|
80 |
// Use the member var to create the array so that we get proper cleanup behaviour
|
sl@0
|
81 |
iImplementationInfoArray = new(ELeave) RImplInfoArray;
|
sl@0
|
82 |
RImplInfoArray* retList = iImplementationInfoArray;
|
sl@0
|
83 |
|
sl@0
|
84 |
RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);
|
sl@0
|
85 |
|
sl@0
|
86 |
const TBool useWildcards = aAdditionalParameters.IsGenericMatch();
|
sl@0
|
87 |
const TDesC8& matchType = aAdditionalParameters.DataType();
|
sl@0
|
88 |
const TInt numImps = fullList.Count();
|
sl@0
|
89 |
for(TInt index = 0; index < numImps; ++index)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
if(Match(fullList[index]->DataType(), matchType, useWildcards))
|
sl@0
|
92 |
{
|
sl@0
|
93 |
User::LeaveIfError(retList->Append(fullList[index]));
|
sl@0
|
94 |
}
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
// Reset the member variable because we are passing ownership back
|
sl@0
|
98 |
iImplementationInfoArray = NULL;
|
sl@0
|
99 |
return retList;
|
sl@0
|
100 |
}
|
sl@0
|
101 |
|
sl@0
|
102 |
TBool CClientRequestPerfTestResolver::Match(const TDesC8& aImplementationType,
|
sl@0
|
103 |
const TDesC8& aMatchType,
|
sl@0
|
104 |
TBool aUseWildcards) const
|
sl@0
|
105 |
{
|
sl@0
|
106 |
TInt matchPos = KErrNotFound;
|
sl@0
|
107 |
|
sl@0
|
108 |
_LIT8(dataSeparator, "||");
|
sl@0
|
109 |
const TInt separatorLength = dataSeparator().Length();
|
sl@0
|
110 |
|
sl@0
|
111 |
// Look for the section separator marker '||'
|
sl@0
|
112 |
TInt separatorPos = aImplementationType.Find(dataSeparator);
|
sl@0
|
113 |
if(separatorPos == KErrNotFound)
|
sl@0
|
114 |
{
|
sl@0
|
115 |
// Match against the whole string
|
sl@0
|
116 |
if(aUseWildcards)
|
sl@0
|
117 |
matchPos = aMatchType.Match(aImplementationType);
|
sl@0
|
118 |
else
|
sl@0
|
119 |
matchPos = aMatchType.Compare(aImplementationType);
|
sl@0
|
120 |
}
|
sl@0
|
121 |
else
|
sl@0
|
122 |
{
|
sl@0
|
123 |
// Find the first section, up to the separator
|
sl@0
|
124 |
TPtrC8 dataSection = aImplementationType.Left(separatorPos);
|
sl@0
|
125 |
TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength);
|
sl@0
|
126 |
// Match against each section in turn
|
sl@0
|
127 |
while(separatorPos != KErrNotFound)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
// Search this section
|
sl@0
|
130 |
if(aUseWildcards)
|
sl@0
|
131 |
matchPos = aMatchType.Match(dataSection);
|
sl@0
|
132 |
else
|
sl@0
|
133 |
matchPos = aMatchType.Compare(dataSection);
|
sl@0
|
134 |
|
sl@0
|
135 |
// If we found it then no need to continue, so return
|
sl@0
|
136 |
if(matchPos != KErrNotFound)
|
sl@0
|
137 |
return ETrue;
|
sl@0
|
138 |
|
sl@0
|
139 |
// Move on to the next section
|
sl@0
|
140 |
separatorPos = remainingData.Find(dataSeparator);
|
sl@0
|
141 |
if(separatorPos != KErrNotFound)
|
sl@0
|
142 |
{
|
sl@0
|
143 |
dataSection.Set(remainingData.Left(separatorPos));
|
sl@0
|
144 |
remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
|
sl@0
|
145 |
}
|
sl@0
|
146 |
else
|
sl@0
|
147 |
dataSection.Set(remainingData);
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
// Check the final part
|
sl@0
|
151 |
if(aUseWildcards)
|
sl@0
|
152 |
matchPos = aMatchType.Match(dataSection);
|
sl@0
|
153 |
else
|
sl@0
|
154 |
matchPos = aMatchType.Compare(dataSection);
|
sl@0
|
155 |
|
sl@0
|
156 |
}
|
sl@0
|
157 |
return matchPos != KErrNotFound;
|
sl@0
|
158 |
}
|
sl@0
|
159 |
|
sl@0
|
160 |
// __________________________________________________________________________
|
sl@0
|
161 |
// Exported proxy for instantiation method resolution
|
sl@0
|
162 |
// Define the interface UIDs
|
sl@0
|
163 |
const TImplementationProxy ImplementationTable[] =
|
sl@0
|
164 |
{
|
sl@0
|
165 |
IMPLEMENTATION_PROXY_ENTRY(0x10009DF8, CClientRequestPerfTestResolver::NewL)
|
sl@0
|
166 |
};
|
sl@0
|
167 |
|
sl@0
|
168 |
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
|
sl@0
|
169 |
{
|
sl@0
|
170 |
aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
|
sl@0
|
171 |
return ImplementationTable;
|
sl@0
|
172 |
}
|
sl@0
|
173 |
|