realtimenetprots/sipfw/SDP/src/SdpCodecStringPool.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2003-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 // Name          : SdpCodecStringPool.cpp
       
    15 // Part of       : SDP Codec
       
    16 // Version       : 1.0
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include <stringpool.h>
       
    22 #include "SdpCodecErr.h"
       
    23 #include "SdpCodecStringPool.h"
       
    24 #include "CSdpCodecStringPool.h"
       
    25 #include "sdpcodecstringconstants.h"
       
    26 #include "_sdpdefs.h"
       
    27 
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // SdpCodecStringPool::OpenL
       
    31 // Opens stringpool owner, leaves if one already exists in TLS
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 EXPORT_C void SdpCodecStringPool::OpenL()
       
    35 	{
       
    36 	__ASSERT_ALWAYS( Dll::Tls() == NULL, User::Leave ( KErrAlreadyExists ) );
       
    37 
       
    38 	CSdpCodecStringPool* codecStringPool = CSdpCodecStringPool::NewLC();
       
    39 	User::LeaveIfError( Dll::SetTls( codecStringPool ) );
       
    40 	CleanupStack::Pop();    //  codecStringPool
       
    41 	}
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // SdpCodecStringPool::Close
       
    45 // Closes & deletes string pool
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C void SdpCodecStringPool::Close()
       
    49 	{
       
    50 	if ( Dll::Tls() == NULL )
       
    51         {
       
    52         return;
       
    53         }
       
    54 
       
    55 	CSdpCodecStringPool* codecStringPool =
       
    56         static_cast<CSdpCodecStringPool*>( Dll::Tls() );
       
    57     delete codecStringPool;
       
    58 	Dll::SetTls( NULL );
       
    59 	}
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // SdpCodecStringPool::StringPoolL
       
    63 // Returns string pool
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 EXPORT_C RStringPool SdpCodecStringPool::StringPoolL()
       
    67     {
       
    68     CSdpCodecStringPool* codecStringPool =
       
    69         static_cast<CSdpCodecStringPool*>( Dll::Tls() );
       
    70     __ASSERT_ALWAYS( codecStringPool != NULL,
       
    71                      User::Leave( KErrSdpCodecStringPool ) );
       
    72 
       
    73 	return codecStringPool->StringPool();
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // SdpCodecStringPool::StringTableL
       
    78 // Returns string table
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 EXPORT_C const TStringTable& SdpCodecStringPool::StringTableL()
       
    82     {
       
    83      CSdpCodecStringPool* codecStringPool =
       
    84         static_cast<CSdpCodecStringPool*>( Dll::Tls() );
       
    85     __ASSERT_ALWAYS( codecStringPool != NULL,
       
    86                      User::Leave( KErrSdpCodecStringPool ) );
       
    87 
       
    88 	return codecStringPool->StringTable();
       
    89     }