os/ossrv/genericopenlibs/openenvcore/backend/inc/base.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/backend/inc/base.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,118 @@
     1.4 +/*
     1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:  Base class for all objects created by backend
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef BASE_H
    1.23 +#define BASE_H
    1.24 +
    1.25 +#include "sysif.h"
    1.26 +
    1.27 +class BBase : public CBase
    1.28 +	{
    1.29 +public:
    1.30 +	/*
    1.31 +	Default constructor
    1.32 +	*/
    1.33 +	inline BBase()	{}
    1.34 +	virtual ~BBase() { }
    1.35 +	
    1.36 +	/* *****************************************************************
    1.37 +	Overloading new and delete operators so that they will
    1.38 +	allocate and deallocare memory from/to the private heap of backend
    1.39 +	********************************************************************/
    1.40 +	inline TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW
    1.41 +		{
    1.42 +		Mem::FillZ(aBase, aSize); return aBase;
    1.43 +		}
    1.44 +		
    1.45 +	inline TAny* operator new(TUint aSize) __NO_THROW
    1.46 +		{
    1.47 +		return Backend()->Alloc(aSize);
    1.48 +		}
    1.49 +		
    1.50 +	inline TAny* operator new(TUint aSize, TLeave)
    1.51 +		{
    1.52 +		TAny* ptr = Backend()->Alloc(aSize);
    1.53 +		if (ptr == NULL)
    1.54 +			{
    1.55 +			User::Leave(KErrNoMemory);
    1.56 +			}
    1.57 +		return ptr;
    1.58 +		}
    1.59 +		
    1.60 +	inline TAny* operator new(TUint aSize, TUint aExtraSize) __NO_THROW
    1.61 +		{
    1.62 +		return Backend()->Alloc(aSize + aExtraSize);
    1.63 +		}
    1.64 +		
    1.65 +	inline TAny* operator new(TUint aSize, TLeave, TUint aExtraSize)
    1.66 +		{
    1.67 +		TAny* ptr = Backend()->Alloc(aSize + aExtraSize);
    1.68 +		if (ptr == NULL)
    1.69 +			{
    1.70 +			User::Leave(KErrNoMemory);
    1.71 +			}
    1.72 +		return ptr;
    1.73 +		}
    1.74 +		
    1.75 +/*corresponding overloaded delete operators	*/
    1.76 +
    1.77 +	inline void operator delete(TAny *aPtr, TAny*) __NO_THROW
    1.78 +		{
    1.79 +		Backend()->Free( aPtr );
    1.80 +		}
    1.81 +		
    1.82 +	inline void operator delete(TAny *aPtr) __NO_THROW
    1.83 +		{
    1.84 +		Backend()->Free( aPtr );
    1.85 +		}
    1.86 +		
    1.87 +	inline void operator delete(TAny *aPtr, TLeave) 
    1.88 +		{
    1.89 +		Backend()->Free( aPtr );
    1.90 +		}
    1.91 +		
    1.92 +	inline void operator delete(TAny *aPtr, TUint) __NO_THROW
    1.93 +		{
    1.94 +		Backend()->Free( aPtr );
    1.95 +		}
    1.96 +		
    1.97 +	inline void operator delete(TAny *aPtr, TLeave, TUint) 
    1.98 +		{
    1.99 +		Backend()->Free( aPtr );
   1.100 +		}
   1.101 +		
   1.102 +	static void Delete(BBase* aPtr)
   1.103 +		{
   1.104 +		delete aPtr;
   1.105 +		}
   1.106 +		
   1.107 +/*
   1.108 +protected:
   1.109 +	virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
   1.110 +		{
   1.111 +		a0 = NULL;
   1.112 +		return KErrExtensionNotSupported;
   1.113 +		}*/
   1.114 +		
   1.115 +private:
   1.116 +	BBase(const BBase&);
   1.117 +	BBase& operator=(const CBase&);
   1.118 +	};
   1.119 +
   1.120 +
   1.121 +#endif //BASE_H