commonappservices/alarmserver/Server/Source/ASSrvIteratorByState.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 1999-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 "ASSrvIteratorByState.h"
       
    17 
       
    18 // System includes
       
    19 
       
    20 // User includes
       
    21 
       
    22 // Type definitions
       
    23 
       
    24 // Constants
       
    25 
       
    26 // Enumerations
       
    27 
       
    28 // Classes referenced
       
    29 
       
    30 
       
    31 //
       
    32 // ----> RASSrvIteratorByState (source)
       
    33 //
       
    34 
       
    35 //*************************************************************************************
       
    36 RASSrvIteratorByState::RASSrvIteratorByState(CASSrvAlarmQueue& aQueue, TAlarmState aState, TStateMatchType aMatchType)
       
    37 :	RASSrvIteratorBase(aQueue), iMatchType(aMatchType)
       
    38 	{
       
    39 	SetState(aState);
       
    40 	}
       
    41 
       
    42 //*************************************************************************************
       
    43 RASSrvIteratorByState::	RASSrvIteratorByState(CASSrvAlarmQueue& aQueue, TAlarmState aEither, TAlarmState aOr)
       
    44 :	RASSrvIteratorBase(aQueue), iMatchType(EStateEitherOr)
       
    45 	{
       
    46 	SetStates(aEither, aOr);
       
    47 	}
       
    48 
       
    49 
       
    50 //
       
    51 //
       
    52 //
       
    53 
       
    54 
       
    55 //*************************************************************************************
       
    56 /**
       
    57  * Change the state for this iterator. Resets the iterator back to the start
       
    58  * of the queue
       
    59  */
       
    60 void RASSrvIteratorByState::SetState(TAlarmState aState, TStateMatchType aMatchType)
       
    61 	{
       
    62 	iState = aState;
       
    63 	iMatchType = aMatchType;
       
    64 	}
       
    65 
       
    66 
       
    67 //*************************************************************************************
       
    68 /**
       
    69  * Change the state for this iterator. Resets the iterator back to the start
       
    70  * of the queue
       
    71  */
       
    72 void RASSrvIteratorByState::SetStates(TAlarmState aEither, TAlarmState aOr)
       
    73 	{
       
    74 	iState = aEither;
       
    75 	iOtherState = aOr;
       
    76 	iMatchType = EStateEitherOr;
       
    77 	}
       
    78 
       
    79 
       
    80 //
       
    81 //
       
    82 //
       
    83 
       
    84 
       
    85 //*************************************************************************************
       
    86 TBool RASSrvIteratorByState::Matches(const TASSrvAlarm& aAlarm) const
       
    87 	{
       
    88 	// Check with other iterator - returns ETrue if there is no attached
       
    89 	// iterator to check with.
       
    90 	TBool matches = RASSrvIteratorBase::Matches(aAlarm);
       
    91 
       
    92 	// Now check this iterator
       
    93 	if	(matches)
       
    94 		{
       
    95 		switch(iMatchType)
       
    96 			{
       
    97 		default:
       
    98 		case EStateEitherOr:
       
    99 			return (aAlarm.State() == iState || aAlarm.State() == iOtherState);
       
   100 		case EStateMustMatch:
       
   101 			return aAlarm.State() == iState;
       
   102 		case EStateMustNotMatch:
       
   103 			return aAlarm.State() != iState;
       
   104 			}
       
   105 		}
       
   106 	//
       
   107 	return matches;
       
   108 	}