lafagnosticuifoundation/animation/src/AnimationTls.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2004-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "AnimationTls.h"
       
    17 
       
    18 #include <e32std.h>
       
    19 
       
    20 #include "AnimationTicker.h"
       
    21 
       
    22 /**
       
    23 Two-stage constructor.
       
    24 
       
    25 There is only ever one of these objects in existence.  The object is reference
       
    26 counted, and is destroyed only when every call to NewL has been matched by a
       
    27 call to Close.
       
    28 
       
    29 @return The new object
       
    30 */
       
    31 EXPORT_C CAnimationTls* CAnimationTls::NewL()
       
    32 	{
       
    33 	CAnimationTls* self = static_cast<CAnimationTls*>(Dll::Tls());
       
    34 	if (!self)
       
    35 		{
       
    36 		self = new (ELeave) CAnimationTls();
       
    37 		CleanupStack::PushL(self);
       
    38 		self->iTimer = CAnimationTicker::NewL();
       
    39 		CleanupStack::Pop(self);
       
    40 		Dll::SetTls(self);
       
    41 		}
       
    42 	++(self->iRefCount);
       
    43 	return self;
       
    44 	}
       
    45 
       
    46 /**
       
    47 Decrements the reference counter for this object, and destroys it if the
       
    48 reference count reaches 0.  This should be called once for every call to NewL.
       
    49 */
       
    50 EXPORT_C void CAnimationTls::Close()
       
    51 	{
       
    52 	--iRefCount;
       
    53 	if (iRefCount < 1)
       
    54 		{
       
    55 		Dll::FreeTls();
       
    56 		delete this;
       
    57 		}
       
    58 	}
       
    59 
       
    60 /**
       
    61 Returns the CAnimationTicker object for this thread.
       
    62 @return A pointer to the shared ticker object
       
    63 */
       
    64 EXPORT_C CAnimationTicker* CAnimationTls::Ticker()
       
    65 	{
       
    66 	return iTimer;
       
    67 	}
       
    68 
       
    69 CAnimationTls::CAnimationTls()
       
    70 	{
       
    71 	}
       
    72 
       
    73 CAnimationTls::~CAnimationTls()
       
    74 	{
       
    75 	delete iTimer;
       
    76 	}
       
    77 
       
    78 /** Reserved for future use */
       
    79 EXPORT_C void CAnimationTls::CAnimationTls_Reserved1() {}
       
    80 
       
    81 /** Reserved for future use */
       
    82 EXPORT_C void CAnimationTls::CAnimationTls_Reserved2() {}