telutils/phoneparser/src/CPhoneGsmHandlerContainer.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 13 Oct 2010 15:10:43 +0300
branchRCL_3
changeset 56 2735883dd3f6
parent 44 987c9837762f
permissions -rw-r--r--
Revision: 201038 Kit: 201041

/*
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Implementation of handler container.
*
*/


// INCLUDE FILES
#include    "CPhoneGsmHandlerContainer.h"
#include    "PhoneGsmParser.h"

// CONSTANTS
const TInt KPhoneHandlerArrayGranularity = 10;
const TInt KPhoneHandlerArrayReserve = 10;

// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CPhoneGsmHandlerContainer::CPhoneGsmHandlerContainer
// -----------------------------------------------------------------------------
//
CPhoneGsmHandlerContainer::CPhoneGsmHandlerContainer()
    {
    }

// -----------------------------------------------------------------------------
// CPhoneGsmHandlerContainer::ConstructL
// -----------------------------------------------------------------------------
//
void CPhoneGsmHandlerContainer::ConstructL()
    {
    iHandlers = 
        new ( ELeave ) CHandlerArray( KPhoneHandlerArrayGranularity );
    iHandlers->SetReserveL( KPhoneHandlerArrayReserve );
    }

// -----------------------------------------------------------------------------
// CPhoneGsmHandlerContainer::NewL
// -----------------------------------------------------------------------------
//
EXPORT_C CPhoneGsmHandlerContainer* CPhoneGsmHandlerContainer::NewL()
    {
    CPhoneGsmHandlerContainer* self = 
        new (ELeave) CPhoneGsmHandlerContainer;
    
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop( self );

    return self;
    }

// -----------------------------------------------------------------------------
// CPhoneGsmHandlerContainer::~CPhoneGsmHandlerContainer
// -----------------------------------------------------------------------------
//
EXPORT_C CPhoneGsmHandlerContainer::~CPhoneGsmHandlerContainer()
    {
    if ( iHandlers )
        {
        iHandlers->ResetAndDestroy();
        }
    delete iHandlers;
    }

// -----------------------------------------------------------------------------
// CPhoneGsmHandlerContainer::AddHandlerL
// -----------------------------------------------------------------------------
//
EXPORT_C void CPhoneGsmHandlerContainer::AddHandlerL( 
        CPhoneGsmHandlerBase& aHandler )
    {
    TInt index;
    TInt count = iHandlers->Count();

    for ( index = 0; index < count; index++ )
        {
        CPhoneGsmHandlerBase* handler = iHandlers->At( index );

        if ( handler == &aHandler )
            {
            PhoneGsmParser::Panic( PhoneGsmParser::EIncorrectUse );
            }
        }

    iHandlers->AppendL( &aHandler );
    }

// -----------------------------------------------------------------------------
// CPhoneGsmHandlerContainer::ProcessL
// -----------------------------------------------------------------------------
//
void CPhoneGsmHandlerContainer::ProcessL( 
        CPhoneGsmParserResult& aResult )
    {
    TInt index;
    TInt count = iHandlers->Count();

    for ( index = 0; index < count; index++ )
        {
        iHandlers->At( index )->ProcessL( aResult );
        }
    }

//  End of File