telutils/phoneparser/src/CPhoneGsmHandlerContainer.cpp
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Implementation of handler container.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CPhoneGsmHandlerContainer.h"
       
    21 #include    "PhoneGsmParser.h"
       
    22 
       
    23 // CONSTANTS
       
    24 const TInt KPhoneHandlerArrayGranularity = 10;
       
    25 const TInt KPhoneHandlerArrayReserve = 10;
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CPhoneGsmHandlerContainer::CPhoneGsmHandlerContainer
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CPhoneGsmHandlerContainer::CPhoneGsmHandlerContainer()
       
    34     {
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CPhoneGsmHandlerContainer::ConstructL
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 void CPhoneGsmHandlerContainer::ConstructL()
       
    42     {
       
    43     iHandlers = 
       
    44         new ( ELeave ) CHandlerArray( KPhoneHandlerArrayGranularity );
       
    45     iHandlers->SetReserveL( KPhoneHandlerArrayReserve );
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CPhoneGsmHandlerContainer::NewL
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C CPhoneGsmHandlerContainer* CPhoneGsmHandlerContainer::NewL()
       
    53     {
       
    54     CPhoneGsmHandlerContainer* self = 
       
    55         new (ELeave) CPhoneGsmHandlerContainer;
       
    56     
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop( self );
       
    60 
       
    61     return self;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CPhoneGsmHandlerContainer::~CPhoneGsmHandlerContainer
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 EXPORT_C CPhoneGsmHandlerContainer::~CPhoneGsmHandlerContainer()
       
    69     {
       
    70     if ( iHandlers )
       
    71         {
       
    72         iHandlers->ResetAndDestroy();
       
    73         }
       
    74     delete iHandlers;
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CPhoneGsmHandlerContainer::AddHandlerL
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 EXPORT_C void CPhoneGsmHandlerContainer::AddHandlerL( 
       
    82         CPhoneGsmHandlerBase& aHandler )
       
    83     {
       
    84     TInt index;
       
    85     TInt count = iHandlers->Count();
       
    86 
       
    87     for ( index = 0; index < count; index++ )
       
    88         {
       
    89         CPhoneGsmHandlerBase* handler = iHandlers->At( index );
       
    90 
       
    91         if ( handler == &aHandler )
       
    92             {
       
    93             PhoneGsmParser::Panic( PhoneGsmParser::EIncorrectUse );
       
    94             }
       
    95         }
       
    96 
       
    97     iHandlers->AppendL( &aHandler );
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CPhoneGsmHandlerContainer::ProcessL
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 void CPhoneGsmHandlerContainer::ProcessL( 
       
   105         CPhoneGsmParserResult& aResult )
       
   106     {
       
   107     TInt index;
       
   108     TInt count = iHandlers->Count();
       
   109 
       
   110     for ( index = 0; index < count; index++ )
       
   111         {
       
   112         iHandlers->At( index )->ProcessL( aResult );
       
   113         }
       
   114     }
       
   115 
       
   116 //  End of File