os/security/cryptomgmtlibs/securitycommonutils/test/inc_private/scstestcommon.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * Defines inline functions which provide constant data to both the
    16 * client and server implementations.
    17 *
    18 */
    19 
    20 
    21 /**
    22  @internalComponent
    23  @test
    24  @file
    25 */
    26 
    27 
    28 #ifndef SCSTESTCOMMON_INL
    29 #define SCSTESTCOMMON_INL
    30 
    31 #include <e32uid.h>
    32 
    33 #include "scstestcommon.h"
    34 
    35 
    36 namespace ScsTestImpl
    37 	{
    38 	inline TVersion Version()
    39 	/**
    40 		This function is defined because there is no literal constructor for TVersion.
    41 
    42 		@return					Defines a version number which the client	
    43 								can use to open the server.  If the client
    44 								was built with a higher version number, then
    45 								it cannot open the server.  This ensures that
    46 								a client only talks to a server whose version
    47 								is at least as high as its own.
    48 	 */
    49 		{
    50 		TVersion v(KScsTestVerMajor, KScsTestVerMinor, KScsTestVerBuild);
    51 		return v;
    52 		}
    53 
    54 	inline TUidType ServerImageFullUid()
    55 	/**
    56 		This function is defined because there is no literal constructor
    57 		for TUidType.  It returns the server executable's UID, which is used
    58 		to ensure the client launches the correct server process, as opposed
    59 		to another application which uses the same executable name.
    60 
    61 		@return TUidType		The server executable's full UID.
    62 	 */
    63 		{
    64 		TUidType uidType(KExecutableImageUid, KNullUid, KScsTestServerUid);
    65 		return uidType;
    66 		}
    67 	}
    68 
    69 template <class T>
    70 inline T TAnyPtrToFuncPtr(TAny* aPtr)
    71 /**
    72 	ISO C++ doesn't allow converting directly between object and
    73 	function pointers, so this function goes via an integer.
    74 
    75 	@param	aPtr			Object pointer to convert to a (static) function pointer.
    76 	@return					Function pointer, where the exact type of the function is	
    77 							described by the T template parameter.
    78  */
    79 	{
    80 	TUint32 funcAsInt = reinterpret_cast<TUint32>(aPtr);
    81 	return reinterpret_cast<T>(funcAsInt);
    82 	}
    83 
    84 #endif	// #ifndef SCSTESTCOMMON_INL
    85 
    86