os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/EComClientRequestPerfTestResolver.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/EComClientRequestPerfTestResolver.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,173 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Implements a custom resolver CClientRequestPerfTestResolver for use during resolver performance tests.
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @internalComponent
1.23 +*/
1.24 +
1.25 +#include <ecom/ecom.h>
1.26 +#include "ImplementationProxy.h"
1.27 +#include "EComClientRequestPerfTestResolver.h"
1.28 +
1.29 +CClientRequestPerfTestResolver* CClientRequestPerfTestResolver::NewL(MPublicRegistry& aRegistry)
1.30 + {
1.31 + return new(ELeave) CClientRequestPerfTestResolver(aRegistry);
1.32 + }
1.33 +
1.34 +CClientRequestPerfTestResolver::~CClientRequestPerfTestResolver()
1.35 + {
1.36 + if(iImplementationInfoArray)
1.37 + {
1.38 + iImplementationInfoArray->Reset();
1.39 + delete iImplementationInfoArray;
1.40 + }
1.41 + }
1.42 +
1.43 +CClientRequestPerfTestResolver::CClientRequestPerfTestResolver(MPublicRegistry& aRegistry)
1.44 +: CResolver(aRegistry)
1.45 + {
1.46 + // Do nothing here
1.47 + }
1.48 +
1.49 +TUid CClientRequestPerfTestResolver::IdentifyImplementationL(TUid aInterfaceUid,
1.50 + const TEComResolverParams& aAdditionalParameters) const
1.51 + {
1.52 + RImplInfoArray& implementationsInfo = iRegistry.ListImplementationsL(aInterfaceUid);
1.53 + TUid found = KNullUid;
1.54 + if(implementationsInfo.Count())
1.55 + {
1.56 + found = Resolve(implementationsInfo, aAdditionalParameters);
1.57 + }
1.58 + return found;
1.59 + }
1.60 +
1.61 +TUid CClientRequestPerfTestResolver::Resolve(const RImplInfoArray& aImplementationsInfo,
1.62 + const TEComResolverParams& aAdditionalParameters) const
1.63 + {
1.64 + // Loop through the implementations matching on type
1.65 + const TInt count = aImplementationsInfo.Count();
1.66 + for(TInt index = 0; index < count; ++index)
1.67 + {
1.68 + const CImplementationInformation& impData = *aImplementationsInfo[index];
1.69 + // As soon as we get a match on the datatype then return uid of the
1.70 + // implementation found.
1.71 + if (Match(impData.DataType(), // The Datatype of this implementation
1.72 + aAdditionalParameters.DataType(), // The type we are trying to find
1.73 + aAdditionalParameters.IsGenericMatch())) // If wildcards should be used
1.74 + return impData.ImplementationUid();
1.75 + }
1.76 +
1.77 + return KNullUid;
1.78 + }
1.79 +
1.80 +RImplInfoArray* CClientRequestPerfTestResolver::ListAllL(TUid aInterfaceUid,
1.81 + const TEComResolverParams& aAdditionalParameters) const
1.82 + {
1.83 + // Use the member var to create the array so that we get proper cleanup behaviour
1.84 + iImplementationInfoArray = new(ELeave) RImplInfoArray;
1.85 + RImplInfoArray* retList = iImplementationInfoArray;
1.86 +
1.87 + RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);
1.88 +
1.89 + const TBool useWildcards = aAdditionalParameters.IsGenericMatch();
1.90 + const TDesC8& matchType = aAdditionalParameters.DataType();
1.91 + const TInt numImps = fullList.Count();
1.92 + for(TInt index = 0; index < numImps; ++index)
1.93 + {
1.94 + if(Match(fullList[index]->DataType(), matchType, useWildcards))
1.95 + {
1.96 + User::LeaveIfError(retList->Append(fullList[index]));
1.97 + }
1.98 + }
1.99 +
1.100 + // Reset the member variable because we are passing ownership back
1.101 + iImplementationInfoArray = NULL;
1.102 + return retList;
1.103 + }
1.104 +
1.105 +TBool CClientRequestPerfTestResolver::Match(const TDesC8& aImplementationType,
1.106 + const TDesC8& aMatchType,
1.107 + TBool aUseWildcards) const
1.108 + {
1.109 + TInt matchPos = KErrNotFound;
1.110 +
1.111 + _LIT8(dataSeparator, "||");
1.112 + const TInt separatorLength = dataSeparator().Length();
1.113 +
1.114 + // Look for the section separator marker '||'
1.115 + TInt separatorPos = aImplementationType.Find(dataSeparator);
1.116 + if(separatorPos == KErrNotFound)
1.117 + {
1.118 + // Match against the whole string
1.119 + if(aUseWildcards)
1.120 + matchPos = aMatchType.Match(aImplementationType);
1.121 + else
1.122 + matchPos = aMatchType.Compare(aImplementationType);
1.123 + }
1.124 + else
1.125 + {
1.126 + // Find the first section, up to the separator
1.127 + TPtrC8 dataSection = aImplementationType.Left(separatorPos);
1.128 + TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength);
1.129 + // Match against each section in turn
1.130 + while(separatorPos != KErrNotFound)
1.131 + {
1.132 + // Search this section
1.133 + if(aUseWildcards)
1.134 + matchPos = aMatchType.Match(dataSection);
1.135 + else
1.136 + matchPos = aMatchType.Compare(dataSection);
1.137 +
1.138 + // If we found it then no need to continue, so return
1.139 + if(matchPos != KErrNotFound)
1.140 + return ETrue;
1.141 +
1.142 + // Move on to the next section
1.143 + separatorPos = remainingData.Find(dataSeparator);
1.144 + if(separatorPos != KErrNotFound)
1.145 + {
1.146 + dataSection.Set(remainingData.Left(separatorPos));
1.147 + remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
1.148 + }
1.149 + else
1.150 + dataSection.Set(remainingData);
1.151 + }
1.152 +
1.153 + // Check the final part
1.154 + if(aUseWildcards)
1.155 + matchPos = aMatchType.Match(dataSection);
1.156 + else
1.157 + matchPos = aMatchType.Compare(dataSection);
1.158 +
1.159 + }
1.160 + return matchPos != KErrNotFound;
1.161 + }
1.162 +
1.163 +// __________________________________________________________________________
1.164 +// Exported proxy for instantiation method resolution
1.165 +// Define the interface UIDs
1.166 +const TImplementationProxy ImplementationTable[] =
1.167 + {
1.168 + IMPLEMENTATION_PROXY_ENTRY(0x10009DF8, CClientRequestPerfTestResolver::NewL)
1.169 + };
1.170 +
1.171 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
1.172 + {
1.173 + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
1.174 + return ImplementationTable;
1.175 + }
1.176 +