uiacceltk/hitchcock/Client/src/alfstatic.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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 "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:   Static class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "alf/alfstatic.h"
       
    21 
       
    22 /**
       
    23  * Thread local storage space. Writable static data is not supported in
       
    24  * Symbian, so static data is stored in this struct.
       
    25  */
       
    26 
       
    27 struct TTlsData
       
    28     {
       
    29     /** Primary environment. */
       
    30     CAlfEnv* iPrimaryEnv;
       
    31     };
       
    32 
       
    33 EXPORT_C CAlfStatic* CAlfStatic::NewLC(CAlfEnv* aPrimaryEnv)
       
    34     {
       
    35     CAlfStatic* self = new (ELeave) CAlfStatic();
       
    36     CleanupStack::PushL(self);
       
    37     self->ConstructL(aPrimaryEnv);
       
    38     return self;        
       
    39     }
       
    40 
       
    41 EXPORT_C CAlfStatic* CAlfStatic::NewL(CAlfEnv* aPrimaryEnv)
       
    42     {
       
    43     CAlfStatic* self = NewLC(aPrimaryEnv);
       
    44     CleanupStack::Pop(self);
       
    45     return self;        
       
    46     }
       
    47 
       
    48 CAlfStatic::~CAlfStatic()
       
    49     {
       
    50     Dll::FreeTls();
       
    51     delete iData;        
       
    52     }
       
    53 
       
    54 EXPORT_C CAlfEnv& CAlfStatic::Env()
       
    55     {
       
    56     return *Data()->iPrimaryEnv;
       
    57     }
       
    58 
       
    59 
       
    60 CAlfStatic::CAlfStatic()
       
    61     {
       
    62     
       
    63     }
       
    64 
       
    65 void CAlfStatic::ConstructL(CAlfEnv* aPrimaryEnv)
       
    66     {
       
    67     iData = new (ELeave) TTlsData();
       
    68     Mem::FillZ(iData, sizeof(TTlsData));    
       
    69     
       
    70     iData->iPrimaryEnv = aPrimaryEnv;
       
    71     
       
    72     Dll::SetTls(iData);    
       
    73     }
       
    74 
       
    75 EXPORT_C struct TTlsData* CAlfStatic::Data()
       
    76     {
       
    77     return static_cast<TTlsData*>(Dll::Tls());        
       
    78     }
       
    79