os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/EComClientRequestPerfTestResolver.cpp
Update contrib.
1 // Copyright (c) 2006-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Implements a custom resolver CClientRequestPerfTestResolver for use during resolver performance tests.
22 #include <ecom/ecom.h>
23 #include "ImplementationProxy.h"
24 #include "EComClientRequestPerfTestResolver.h"
26 CClientRequestPerfTestResolver* CClientRequestPerfTestResolver::NewL(MPublicRegistry& aRegistry)
28 return new(ELeave) CClientRequestPerfTestResolver(aRegistry);
31 CClientRequestPerfTestResolver::~CClientRequestPerfTestResolver()
33 if(iImplementationInfoArray)
35 iImplementationInfoArray->Reset();
36 delete iImplementationInfoArray;
40 CClientRequestPerfTestResolver::CClientRequestPerfTestResolver(MPublicRegistry& aRegistry)
41 : CResolver(aRegistry)
46 TUid CClientRequestPerfTestResolver::IdentifyImplementationL(TUid aInterfaceUid,
47 const TEComResolverParams& aAdditionalParameters) const
49 RImplInfoArray& implementationsInfo = iRegistry.ListImplementationsL(aInterfaceUid);
50 TUid found = KNullUid;
51 if(implementationsInfo.Count())
53 found = Resolve(implementationsInfo, aAdditionalParameters);
58 TUid CClientRequestPerfTestResolver::Resolve(const RImplInfoArray& aImplementationsInfo,
59 const TEComResolverParams& aAdditionalParameters) const
61 // Loop through the implementations matching on type
62 const TInt count = aImplementationsInfo.Count();
63 for(TInt index = 0; index < count; ++index)
65 const CImplementationInformation& impData = *aImplementationsInfo[index];
66 // As soon as we get a match on the datatype then return uid of the
67 // implementation found.
68 if (Match(impData.DataType(), // The Datatype of this implementation
69 aAdditionalParameters.DataType(), // The type we are trying to find
70 aAdditionalParameters.IsGenericMatch())) // If wildcards should be used
71 return impData.ImplementationUid();
77 RImplInfoArray* CClientRequestPerfTestResolver::ListAllL(TUid aInterfaceUid,
78 const TEComResolverParams& aAdditionalParameters) const
80 // Use the member var to create the array so that we get proper cleanup behaviour
81 iImplementationInfoArray = new(ELeave) RImplInfoArray;
82 RImplInfoArray* retList = iImplementationInfoArray;
84 RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);
86 const TBool useWildcards = aAdditionalParameters.IsGenericMatch();
87 const TDesC8& matchType = aAdditionalParameters.DataType();
88 const TInt numImps = fullList.Count();
89 for(TInt index = 0; index < numImps; ++index)
91 if(Match(fullList[index]->DataType(), matchType, useWildcards))
93 User::LeaveIfError(retList->Append(fullList[index]));
97 // Reset the member variable because we are passing ownership back
98 iImplementationInfoArray = NULL;
102 TBool CClientRequestPerfTestResolver::Match(const TDesC8& aImplementationType,
103 const TDesC8& aMatchType,
104 TBool aUseWildcards) const
106 TInt matchPos = KErrNotFound;
108 _LIT8(dataSeparator, "||");
109 const TInt separatorLength = dataSeparator().Length();
111 // Look for the section separator marker '||'
112 TInt separatorPos = aImplementationType.Find(dataSeparator);
113 if(separatorPos == KErrNotFound)
115 // Match against the whole string
117 matchPos = aMatchType.Match(aImplementationType);
119 matchPos = aMatchType.Compare(aImplementationType);
123 // Find the first section, up to the separator
124 TPtrC8 dataSection = aImplementationType.Left(separatorPos);
125 TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength);
126 // Match against each section in turn
127 while(separatorPos != KErrNotFound)
129 // Search this section
131 matchPos = aMatchType.Match(dataSection);
133 matchPos = aMatchType.Compare(dataSection);
135 // If we found it then no need to continue, so return
136 if(matchPos != KErrNotFound)
139 // Move on to the next section
140 separatorPos = remainingData.Find(dataSeparator);
141 if(separatorPos != KErrNotFound)
143 dataSection.Set(remainingData.Left(separatorPos));
144 remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
147 dataSection.Set(remainingData);
150 // Check the final part
152 matchPos = aMatchType.Match(dataSection);
154 matchPos = aMatchType.Compare(dataSection);
157 return matchPos != KErrNotFound;
160 // __________________________________________________________________________
161 // Exported proxy for instantiation method resolution
162 // Define the interface UIDs
163 const TImplementationProxy ImplementationTable[] =
165 IMPLEMENTATION_PROXY_ENTRY(0x10009DF8, CClientRequestPerfTestResolver::NewL)
168 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
170 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
171 return ImplementationTable;