secureswitools/swisistools/source/sisxlibrary/actualcounterbase.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2004-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 * Note: This file may contain code to generate corrupt files for test purposes.
       
    16 * Such code is excluded from production builds by use of compiler defines;
       
    17 * it is recommended that such code should be removed if this code is ever published publicly.
       
    18 * used for smart pointers. See CElement.
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 /**
       
    24  @file 
       
    25  @internalComponent
       
    26  @released
       
    27 */
       
    28 
       
    29 #ifndef __ACTUALCOUNTERBASE_H__
       
    30 #define __ACTUALCOUNTERBASE_H__
       
    31 
       
    32 
       
    33 #include <memory>
       
    34 
       
    35 #include "counterbase.h"
       
    36 
       
    37 
       
    38 
       
    39 
       
    40 template <class P> class CActualCounterBase: public CCounterBase
       
    41 	{
       
    42 private:
       
    43     P iPtr; // copy constructor must not throw
       
    44 
       
    45     CActualCounterBase (CActualCounterBase const&);
       
    46     CActualCounterBase & operator= (CActualCounterBase const&);
       
    47     typedef CActualCounterBase<P> this_type;
       
    48 
       
    49 public:
       
    50     CActualCounterBase (P p);
       
    51     virtual void Dispose ();
       
    52     void* operator new (size_t);
       
    53     void operator delete (void* ap);
       
    54 	};
       
    55 
       
    56 
       
    57 
       
    58 
       
    59 template <class P> inline
       
    60 		CActualCounterBase <P>::CActualCounterBase (P p) :
       
    61 			iPtr (p)		
       
    62 	{
       
    63 	}
       
    64 
       
    65 template <class P> void CActualCounterBase <P>::Dispose ()					
       
    66 	{ 
       
    67 	delete iPtr; 
       
    68 	}
       
    69 
       
    70 template <class P> void* CActualCounterBase <P>::operator new (size_t)
       
    71 	{
       
    72 	return std::allocator<this_type> ().allocate (1, static_cast <this_type*> (0));
       
    73 	}
       
    74 
       
    75 template <class P> void CActualCounterBase <P>::operator delete (void* ap)
       
    76 	{
       
    77 	std::allocator<this_type> ().deallocate (static_cast <this_type*> (ap), 1);
       
    78 	}
       
    79 
       
    80 #endif // __ACTUALCOUNTERBASE_H__