os/kernelhwsrv/kernel/eka/euser/us_que.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/us_que.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,852 @@
     1.4 +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\euser\us_que.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "us_std.h"
    1.22 +
    1.23 +EXPORT_C void TSglQueLink::Enque(TSglQueLink* aLink)
    1.24 +//
    1.25 +// Enque this after aLink.
    1.26 +//
    1.27 +	{
    1.28 +
    1.29 +	iNext=aLink->iNext;
    1.30 +	aLink->iNext=this;
    1.31 +	}
    1.32 +
    1.33 +
    1.34 +
    1.35 +
    1.36 +EXPORT_C void TDblQueLinkBase::Enque(TDblQueLinkBase* aLink)
    1.37 +/** 
    1.38 +Inserts this link object after the specified link object.
    1.39 +
    1.40 +The specified link object must already be in the doubly linked list.
    1.41 +
    1.42 +The function cannot be used to insert a list element into the beginning or 
    1.43 +end of a doubly linked list; this is handled by the TDblQue::AddFirst() 
    1.44 +and TDblQue::AddLast() functions.
    1.45 +
    1.46 +@param aLink A pointer to the link object embedded within the list element 
    1.47 +             to which this link object is to be connected. It must not be NULL.
    1.48 +              
    1.49 +@see TDblQue
    1.50 +*/
    1.51 +	{
    1.52 +
    1.53 +	iNext=aLink->iNext;
    1.54 +	iPrev=aLink;
    1.55 +	aLink->iNext->iPrev=this;
    1.56 +	aLink->iNext=this;
    1.57 +	}
    1.58 +
    1.59 +
    1.60 +
    1.61 +
    1.62 +EXPORT_C void TDblQueLinkBase::AddBefore(TDblQueLinkBase* aLink)
    1.63 +/**
    1.64 +Inserts this link object before the specified link object.
    1.65 +
    1.66 +The specified link object must already be in the doubly linked list.
    1.67 +
    1.68 +The function cannot be used to insert a list element into the beginning or 
    1.69 +end of a doubly linked list; this is handled by the TDblQue::AddFirst() 
    1.70 +and TDblQue::AddLast() functions.
    1.71 +
    1.72 +@param aLink A pointer to the link object embedded within the list element 
    1.73 +             to which this link object is to be connected. It must not be NULL.
    1.74 +              
    1.75 +@see TDblQue
    1.76 +*/
    1.77 +	{
    1.78 +
    1.79 +	iNext=aLink;
    1.80 +	iPrev=aLink->iPrev;
    1.81 +	aLink->iPrev->iNext=this;
    1.82 +	aLink->iPrev=this;
    1.83 +	}
    1.84 +
    1.85 +
    1.86 +
    1.87 +
    1.88 +EXPORT_C void TDblQueLink::Deque()
    1.89 +/**
    1.90 +Removes this link object from the doubly linked list.
    1.91 +
    1.92 +In effect, this removes the list element that acts as host to this link object
    1.93 +from the doubly linked list.
    1.94 +
    1.95 +The link object can be any in the doubly linked list.
    1.96 +
    1.97 +It is safe to use this method on an object which has already been removed from the list.
    1.98 +
    1.99 +@post iNext member is set to NULL
   1.100 +*/
   1.101 +	{
   1.102 +
   1.103 +	if (iNext)
   1.104 +		{
   1.105 +	    iPrev->iNext=iNext;
   1.106 +		iNext->iPrev=iPrev;
   1.107 +		iNext=NULL;
   1.108 +		}
   1.109 +	}
   1.110 +
   1.111 +
   1.112 +
   1.113 +
   1.114 +EXPORT_C TSglQueBase::TSglQueBase()
   1.115 +	: iHead(NULL),iLast((TSglQueLink*)&iHead),iOffset(0)
   1.116 +/**
   1.117 +Default constructor.
   1.118 +
   1.119 +It sets:
   1.120 +
   1.121 +1. iHead to Null.
   1.122 +
   1.123 +2. iLast to point to the head  of queue.
   1.124 +
   1.125 +3. iOffset to zero.
   1.126 +
   1.127 +@see iHead
   1.128 +@see iLast
   1.129 +@see iOffset
   1.130 +*/
   1.131 +	{}
   1.132 +
   1.133 +
   1.134 +
   1.135 +
   1.136 +EXPORT_C TSglQueBase::TSglQueBase(TInt aOffset)
   1.137 +	: iHead(NULL),iLast((TSglQueLink*)&iHead),iOffset(aOffset)
   1.138 +/**
   1.139 +Constructor with specified offset.
   1.140 +
   1.141 +It sets:
   1.142 +
   1.143 +1. iHead to Null
   1.144 +
   1.145 +2. iLast to point to the head of queue.
   1.146 +
   1.147 +3. iOffset to the specified value.
   1.148 +
   1.149 +@param aOffset The offset of a link object within an element.
   1.150 +
   1.151 +@panic USER 75, if aOffset is not divisible by four
   1.152 +
   1.153 +@see iHead
   1.154 +@see iLast
   1.155 +@see iOffset
   1.156 +*/
   1.157 +	{
   1.158 +
   1.159 +	__ASSERT_ALWAYS(iOffset%4==0,Panic(ESQueOffsetNotAligned));
   1.160 +	}
   1.161 +
   1.162 +
   1.163 +
   1.164 +
   1.165 +EXPORT_C TBool TSglQueBase::IsEmpty() const
   1.166 +/**
   1.167 +Tests whether the singly linked list is empty, i.e. has no list elements.
   1.168 +
   1.169 +@return True, if the singly linked list is empty; false, otherwise.
   1.170 +*/
   1.171 +	{
   1.172 +
   1.173 +	return(iHead==NULL);
   1.174 +	}
   1.175 +
   1.176 +
   1.177 +
   1.178 +
   1.179 +EXPORT_C void TSglQueBase::SetOffset(TInt aOffset)
   1.180 +/**
   1.181 +Sets the offset of the link object from the start of a singly linked
   1.182 +list element.
   1.183 +
   1.184 +@param aOffset The offset of the link object from the start of a singly linked 
   1.185 +               list element.
   1.186 +               
   1.187 +@panic USER 75, if aOffset is not divisible by four.              
   1.188 +
   1.189 +@see TSglQue
   1.190 +*/
   1.191 +	{
   1.192 +
   1.193 +	__ASSERT_ALWAYS(iOffset%4==0,Panic(ESQueOffsetNotAligned));
   1.194 +	iOffset=aOffset;
   1.195 +	}
   1.196 +
   1.197 +
   1.198 +
   1.199 +
   1.200 +
   1.201 +EXPORT_C void TSglQueBase::Reset()
   1.202 +/**
   1.203 +Empties the singly linked list.
   1.204 +
   1.205 +After a call to this function, there are no elements queued from the header; 
   1.206 +the elements are orphaned. Special care must be taken when list elements are 
   1.207 +CBase derived objects, i.e. are allocated on the heap.
   1.208 +*/
   1.209 +	{
   1.210 +	
   1.211 +	iHead=NULL;
   1.212 +	iLast=(TSglQueLink*)&iHead;
   1.213 +	}
   1.214 +
   1.215 +
   1.216 +
   1.217 +
   1.218 +
   1.219 +EXPORT_C void TSglQueBase::DoAddFirst(TAny* aPtr)
   1.220 +/**
   1.221 +Implements the insertion of a list element at the front of the singly linked 
   1.222 +list.
   1.223 +
   1.224 +This function is called by TSglQue::AddFirst().
   1.225 +
   1.226 +@param aPtr An untyped pointer to the element to be inserted.
   1.227 +
   1.228 +@see TSglQue::AddFirst
   1.229 +*/
   1.230 +	{
   1.231 +
   1.232 +	TSglQueLink* pL=PtrAdd((TSglQueLink*)aPtr,iOffset);
   1.233 +	pL->Enque((TSglQueLink*)&iHead);
   1.234 +	if (iLast==(TSglQueLink*)(&iHead))
   1.235 +		iLast=pL;
   1.236 +	}
   1.237 +
   1.238 +
   1.239 +
   1.240 +
   1.241 +EXPORT_C void TSglQueBase::DoAddLast(TAny* aPtr)
   1.242 +/**
   1.243 +Implements the insertion of a list element at the back of the singly linked 
   1.244 +list.
   1.245 +
   1.246 +This function is called by TSglQue::AddLast().
   1.247 +
   1.248 +@param aPtr An untyped pointer to the element to be inserted.
   1.249 +
   1.250 +@see TSglQue::AddLast
   1.251 +*/
   1.252 +	{
   1.253 +
   1.254 +	TSglQueLink* pL=PtrAdd((TSglQueLink*)aPtr,iOffset);
   1.255 +	pL->Enque(iLast);
   1.256 +	iLast=pL;
   1.257 +	}
   1.258 +
   1.259 +
   1.260 +
   1.261 +
   1.262 +EXPORT_C void TSglQueBase::DoRemove(TAny* aPtr)
   1.263 +/**
   1.264 +Implements the removal of a list element from the singly linked list.
   1.265 +
   1.266 +This function is called by TSglQue::Remove().
   1.267 +
   1.268 +@param aPtr An untyped pointer to the element to be removed.
   1.269 +
   1.270 +@see TSglQue::Remove
   1.271 +*/
   1.272 +	{
   1.273 +
   1.274 +	TSglQueLink* pP=(TSglQueLink*)(&iHead);
   1.275 +	TSglQueLink* pL=PtrAdd((TSglQueLink*)aPtr,iOffset);
   1.276 +	TSglQueLink* pN=pP->iNext;
   1.277 +	while (pN)
   1.278 +		{
   1.279 +		if (pN==pL)
   1.280 +			{
   1.281 +			pP->iNext=pN->iNext;
   1.282 +			if (iLast==pL)
   1.283 +				{
   1.284 +				iLast=pP;
   1.285 +				if (iLast==NULL)
   1.286 +					iLast=(TSglQueLink*)(&iHead);
   1.287 +				}
   1.288 +			return;
   1.289 +			}
   1.290 +		pP=pN;
   1.291 +		pN=pP->iNext;
   1.292 +		}
   1.293 +	Panic(ESQueLinkNotQueued);
   1.294 +	}
   1.295 +
   1.296 +
   1.297 +
   1.298 +
   1.299 +#pragma warning( disable : 4705 )	// statement has no effect
   1.300 +EXPORT_C TDblQueBase::TDblQueBase()
   1.301 +	: iOffset(0)
   1.302 +/**
   1.303 +Default constructor.
   1.304 +
   1.305 +It sets: 
   1.306 +
   1.307 +1. iHead to point to this object in both the forwards and backwards direction.
   1.308 +
   1.309 +2. iOffset to zero.
   1.310 +
   1.311 +@see iHead
   1.312 +@see iOffset
   1.313 +*/
   1.314 +	{
   1.315 +
   1.316 +	iHead.iNext=iHead.iPrev=(&iHead);
   1.317 +	}
   1.318 +
   1.319 +
   1.320 +
   1.321 +
   1.322 +EXPORT_C TDblQueBase::TDblQueBase(TInt aOffset)
   1.323 +	: iOffset(aOffset)
   1.324 +/**
   1.325 +Constructor with specified offset.
   1.326 +
   1.327 +It sets:
   1.328 +
   1.329 +1. iHead to point to this object in both the forwards and backwards direction.
   1.330 +
   1.331 +2. iOffset to the specified value.
   1.332 +
   1.333 +@param aOffset The offset of a link object within an element.
   1.334 +
   1.335 +@panic USER 78, if aOffset is not divisible by four
   1.336 +
   1.337 +@see iHead
   1.338 +@see iOffset
   1.339 +*/
   1.340 +	{
   1.341 +
   1.342 +	__ASSERT_ALWAYS(iOffset%4==0,Panic(ETQueOffsetNotAligned));
   1.343 +	iHead.iNext=iHead.iPrev=(&iHead);
   1.344 +	}
   1.345 +#pragma warning( default : 4705 )
   1.346 +
   1.347 +
   1.348 +
   1.349 +
   1.350 +EXPORT_C TBool TDblQueBase::IsEmpty() const
   1.351 +/**
   1.352 +Tests whether the doubly linked list is empty, i.e. has no list elements.
   1.353 +
   1.354 +@return True, if the doubly linked list is empty; false, otherwise.
   1.355 +*/
   1.356 +	{
   1.357 +
   1.358 +	return((const TDblQueLinkBase*)iHead.iNext==(&iHead));
   1.359 +	}
   1.360 +
   1.361 +
   1.362 +
   1.363 +
   1.364 +EXPORT_C void TDblQueBase::SetOffset(TInt aOffset)
   1.365 +/**
   1.366 +Sets the offset of the link object from the start of a doubly linked list element.
   1.367 +
   1.368 +@param aOffset The offset of the link object from the start of a doubly linked 
   1.369 +               list element.
   1.370 +               
   1.371 +@panic USER 78, if aOffset is not divisible by four.               
   1.372 +               
   1.373 +@see TDblQue
   1.374 +*/
   1.375 +	{
   1.376 +
   1.377 +	__ASSERT_ALWAYS(iOffset%4==0,Panic(ETQueOffsetNotAligned));
   1.378 +	iOffset=aOffset;
   1.379 +	}
   1.380 +
   1.381 +
   1.382 +
   1.383 +
   1.384 +EXPORT_C void TDblQueBase::Reset()
   1.385 +/**
   1.386 +Empties the doubly linked list.
   1.387 +
   1.388 +After a call to this function, there are no elements queued from the header; 
   1.389 +the elements are orphaned. Special care must be taken when list elements are 
   1.390 +CBase derived objects, i.e. are allocated on the heap.
   1.391 +*/
   1.392 +	{
   1.393 +	
   1.394 +	iHead.iNext=iHead.iPrev=(&iHead);
   1.395 +	}
   1.396 +
   1.397 +
   1.398 +
   1.399 +
   1.400 +EXPORT_C void TDblQueBase::DoAddFirst(TAny* aPtr)
   1.401 +/**
   1.402 +Implements the insertion of the specified list element at the front of the
   1.403 +doubly linked list.
   1.404 +
   1.405 +This function is called by TDblQue::AddFirst().
   1.406 +
   1.407 +@param aPtr An untyped pointer to the element to be inserted.
   1.408 +
   1.409 +@see TDblQue::AddFirst
   1.410 +*/
   1.411 +	{
   1.412 +
   1.413 +	PtrAdd((TDblQueLinkBase*)aPtr,iOffset)->Enque(&iHead);
   1.414 +	}
   1.415 +
   1.416 +
   1.417 +
   1.418 +
   1.419 +EXPORT_C void TDblQueBase::DoAddLast(TAny* aPtr)
   1.420 +/**
   1.421 +Implements the insertion of the specified list element at the back of the
   1.422 +doubly linked list.
   1.423 +
   1.424 +This function is called by TDblQue::AddLast().
   1.425 +
   1.426 +@param aPtr An untyped pointer to the element to be inserted.
   1.427 +
   1.428 +@see TDblQue::AddLast*/
   1.429 +	{
   1.430 +
   1.431 +	PtrAdd((TDblQueLinkBase*)aPtr,iOffset)->Enque(iHead.iPrev);
   1.432 +	}
   1.433 +
   1.434 +
   1.435 +
   1.436 +
   1.437 +EXPORT_C void TDblQueBase::DoAddPriority(TAny* aPtr)
   1.438 +/**
   1.439 +Implements the insertion of the specified list element in priority order.
   1.440 +
   1.441 +This function is called by TPriQue::Add().
   1.442 +
   1.443 +@param aPtr An untyped pointer to the element to be inserted.
   1.444 +
   1.445 +@see TPriQue::Add
   1.446 +*/
   1.447 +	{
   1.448 +
   1.449 +	TPriQueLink* pN=(TPriQueLink*)iHead.iNext;
   1.450 +	TPriQueLink* pI=PtrAdd((TPriQueLink*)aPtr,iOffset);
   1.451 +	TInt p=pI->iPriority;
   1.452 +	while (pN!=(TPriQueLink*)&iHead && p<=pN->iPriority)
   1.453 +		pN=(TPriQueLink*)pN->iNext;
   1.454 +	pI->Enque(pN->iPrev);
   1.455 +	}
   1.456 +
   1.457 +
   1.458 +
   1.459 +
   1.460 +EXPORT_C TDeltaQueBase::TDeltaQueBase()
   1.461 +	: iFirstDelta(NULL)
   1.462 +/**
   1.463 +Default constructor.
   1.464 +
   1.465 +It sets iFirstDelta to NULL.
   1.466 +
   1.467 +@see TDeltaQueBase::iFirstDelta
   1.468 +*/
   1.469 +	{
   1.470 +	}
   1.471 +
   1.472 +
   1.473 +
   1.474 +
   1.475 +EXPORT_C TDeltaQueBase::TDeltaQueBase(TInt aOffset)
   1.476 +	: TDblQueBase(aOffset),iFirstDelta(NULL)
   1.477 +/**
   1.478 +Constructor with specified offset.
   1.479 +
   1.480 +It sets:
   1.481 +
   1.482 +1. iFirstDelta to NULL
   1.483 +
   1.484 +2. TDblQueBase::iOffset to the specified value, through a call to the
   1.485 +   base class  constructor.
   1.486 +
   1.487 +@param aOffset The offset of a link object within an element.
   1.488 +
   1.489 +@see TDeltaQueBase::iFirstDelta
   1.490 +@see TDblQueBase::iOffset
   1.491 +*/
   1.492 +	{
   1.493 +	}
   1.494 +
   1.495 +
   1.496 +
   1.497 +
   1.498 +EXPORT_C void TDeltaQueBase::Reset()
   1.499 +/**
   1.500 +Empties the doubly linked list, and resets the first delta pointer.
   1.501 +*/
   1.502 +	{
   1.503 +	
   1.504 +	TDblQueBase::Reset();
   1.505 +	iFirstDelta=NULL;
   1.506 +	}
   1.507 +
   1.508 +
   1.509 +
   1.510 +
   1.511 +EXPORT_C TBool TDeltaQueBase::FirstDelta(TInt& aValue)
   1.512 +/**
   1.513 +Gets the delta value of the first list element.
   1.514 +
   1.515 +@param aValue On return, contsins the delta value of the first element.
   1.516 +              Note that this remains unchanged if there is no first element.
   1.517 +              
   1.518 +@return True, if there is a first element; false, otherwise.
   1.519 +*/
   1.520 +    {
   1.521 +    if (iFirstDelta)
   1.522 +        {
   1.523 +        aValue=*iFirstDelta;
   1.524 +        return(ETrue);
   1.525 +        }
   1.526 +    return(EFalse);
   1.527 +    }
   1.528 +
   1.529 +
   1.530 +
   1.531 +
   1.532 +EXPORT_C TBool TDeltaQueBase::CountDown()
   1.533 +/**
   1.534 +Decrements the delta value of the first element by one, and returns true if 
   1.535 +the result is negative or zero.
   1.536 +
   1.537 +@return True, if the resulting delta value is negative or zero; false, if 
   1.538 +        the value is positive, or there is no first element.
   1.539 +*/
   1.540 +	{
   1.541 +
   1.542 +    return(CountDown(1));
   1.543 +	}
   1.544 +
   1.545 +
   1.546 +
   1.547 +
   1.548 +EXPORT_C TBool TDeltaQueBase::CountDown(TInt aValue)
   1.549 +/**
   1.550 +Decrements the delta value of the first element by the specified value, and 
   1.551 +returns true if the result is negative or zero.
   1.552 +
   1.553 +@param aValue The amount by which the delta value is to be reduced.
   1.554 +
   1.555 +@return True, if the resulting delta value is negative or zero; false, if the 
   1.556 +        value is positive, or there is no first element.
   1.557 +*/
   1.558 +	{
   1.559 +
   1.560 +	if (iFirstDelta)
   1.561 +		{
   1.562 +		(*iFirstDelta)-=aValue;
   1.563 +		if (*iFirstDelta<=0)
   1.564 +			return(ETrue);
   1.565 +		}
   1.566 +	return(EFalse);
   1.567 +	}
   1.568 +
   1.569 +
   1.570 +
   1.571 +
   1.572 +EXPORT_C void TDeltaQueBase::DoAddDelta(TAny* aPtr,TInt aDelta)
   1.573 +/**
   1.574 +Implements the addition of the specified list element into the list.
   1.575 +
   1.576 +This function is called by TDeltaQue::Add().
   1.577 +
   1.578 +@param aPtr   Pointer to the list element to be inserted.
   1.579 +@param aDelta The 'distance' from the nominal zero point.
   1.580 +
   1.581 +@see TDeltaQue::Add
   1.582 +*/
   1.583 +	{
   1.584 +
   1.585 +	TDeltaQueLink* pD=(TDeltaQueLink*)iHead.iNext;
   1.586 +	TDeltaQueLink* pI=PtrAdd((TDeltaQueLink*)aPtr,iOffset);
   1.587 +	while (pD!=(TDeltaQueLink*)&iHead && aDelta>=pD->iDelta)
   1.588 +		{
   1.589 +		aDelta-=pD->iDelta;
   1.590 +		pD=(TDeltaQueLink*)pD->iNext;
   1.591 +		}
   1.592 +	pI->iDelta=aDelta;
   1.593 +	pI->Enque(pD->iPrev);
   1.594 +	if (pI->iNext!=&iHead)
   1.595 +		pD->iDelta-=aDelta;
   1.596 +	iFirstDelta=(&((TDeltaQueLink*)iHead.iNext)->iDelta);
   1.597 +	}
   1.598 +
   1.599 +
   1.600 +
   1.601 +
   1.602 +EXPORT_C void TDeltaQueBase::DoRemove(TAny* aPtr)
   1.603 +/**
   1.604 +Implements the removal of the specified list element from the list.
   1.605 +
   1.606 +This function is called by TDeltaQue::Remove().
   1.607 +
   1.608 +@param aPtr Pointer to the list element to be removed.
   1.609 +
   1.610 +@see TDeltaQue::Remove
   1.611 +*/
   1.612 +	{
   1.613 +
   1.614 +	TDeltaQueLink* pI=PtrAdd((TDeltaQueLink*)aPtr,iOffset);
   1.615 +	TDeltaQueLink* pN=(TDeltaQueLink*)pI->iNext;
   1.616 +	if (pN!=(TDeltaQueLink*)&iHead)
   1.617 +		pN->iDelta+=pI->iDelta;
   1.618 +	((TDblQueLink*)pI)->Deque();
   1.619 +	iFirstDelta=(iHead.iNext!=(&iHead) ? &((TDeltaQueLink*)iHead.iNext)->iDelta : NULL);
   1.620 +	}
   1.621 +
   1.622 +
   1.623 +
   1.624 +
   1.625 +EXPORT_C TAny* TDeltaQueBase::DoRemoveFirst()
   1.626 +/**
   1.627 +Implements the removal of the first list element from the linked list if its 
   1.628 +delta value is zero or negative.
   1.629 +
   1.630 +This function is called by TDeltaQue::RemoveFirst().
   1.631 +
   1.632 +@return A pointer to the element removed from the linked list. This is NULL, 
   1.633 +        if the first element has a positive delta value.
   1.634 +
   1.635 +@see TDeltaQue::RemoveFirst
   1.636 +*/
   1.637 +	{
   1.638 +
   1.639 +	TDeltaQueLink* pN=(TDeltaQueLink*)iHead.iNext;
   1.640 +	if (pN!=(TDeltaQueLink*)&iHead && pN->iDelta<=0)
   1.641 +		{
   1.642 +		pN=PtrSub(pN,iOffset);
   1.643 +		DoRemove(pN);
   1.644 +		return(pN);
   1.645 +		}
   1.646 +	return(NULL);
   1.647 +	}
   1.648 +
   1.649 +
   1.650 +
   1.651 +
   1.652 +EXPORT_C TSglQueIterBase::TSglQueIterBase(TSglQueBase& aQue)
   1.653 +//
   1.654 +// Cosntructor.
   1.655 +//
   1.656 +	: iOffset(aQue.iOffset),iHead((TSglQueLink*)&aQue.iHead),iNext(aQue.iHead)
   1.657 +	{}
   1.658 +
   1.659 +
   1.660 +
   1.661 +
   1.662 +EXPORT_C void TSglQueIterBase::SetToFirst()
   1.663 +/**
   1.664 +Sets the iterator to point to the first element in the singly linked list. 
   1.665 +
   1.666 +The function can be called to re-set the pointer at any time during the iterator's 
   1.667 +existence.
   1.668 +
   1.669 +The function can be called even if the list has no elements.
   1.670 +*/
   1.671 +	{
   1.672 +
   1.673 +	iNext=iHead->iNext;
   1.674 +	}
   1.675 +
   1.676 +
   1.677 +
   1.678 +
   1.679 +EXPORT_C void TSglQueIterBase::DoSet(TAny* aLink)
   1.680 +//
   1.681 +// Start the iterator at aLink.
   1.682 +//
   1.683 +	{
   1.684 +
   1.685 +	iNext=PtrAdd((TSglQueLink*)aLink,iOffset);
   1.686 +	}
   1.687 +
   1.688 +EXPORT_C TAny* TSglQueIterBase::DoPostInc()
   1.689 +//
   1.690 +// Return the current pointer and increment.
   1.691 +//
   1.692 +	{
   1.693 +
   1.694 +	TAny* pN=iNext;
   1.695 +	if (pN==NULL)
   1.696 +		return NULL;
   1.697 +	iNext=iNext->iNext;
   1.698 +	return(PtrSub(pN,iOffset));
   1.699 +	}
   1.700 +
   1.701 +EXPORT_C TAny* TSglQueIterBase::DoCurrent()
   1.702 +//
   1.703 +// Return the current pointer.
   1.704 +//
   1.705 +	{
   1.706 +
   1.707 +	return(iNext==NULL ? NULL : PtrSub((TAny*)iNext,iOffset));
   1.708 +	}
   1.709 +
   1.710 +
   1.711 +
   1.712 +
   1.713 +EXPORT_C TDblQueIterBase::TDblQueIterBase(TDblQueBase& aQue)
   1.714 +	: iOffset(aQue.iOffset),iHead(&aQue.iHead),iNext(aQue.iHead.iNext)
   1.715 +/**
   1.716 +Constructs the iterator for the specified doubly linked list.
   1.717 +
   1.718 +@param aQue A reference to a doubly linked list header.
   1.719 +*/
   1.720 +	{}
   1.721 +
   1.722 +
   1.723 +
   1.724 +
   1.725 +EXPORT_C void TDblQueIterBase::SetToFirst()
   1.726 +/**
   1.727 +Sets the iterator to point to the first element in the doubly linked list. 
   1.728 +
   1.729 +The function can be called to re-set the pointer at any time during the
   1.730 +iterator's  existence.
   1.731 +
   1.732 +The function can be called even if the list has no elements.
   1.733 +*/
   1.734 +	{
   1.735 +
   1.736 +	iNext=iHead->iNext;
   1.737 +	}
   1.738 +
   1.739 +
   1.740 +
   1.741 +
   1.742 +EXPORT_C void TDblQueIterBase::SetToLast()
   1.743 +/**
   1.744 +Sets the iterator to point to the last element in the doubly linked list. The 
   1.745 +function can be called to re-set the pointer at any time during the
   1.746 +iterator's existence.
   1.747 +
   1.748 +The function can be called even if the list has no elements.
   1.749 +*/
   1.750 +	{
   1.751 +
   1.752 +	iNext=iHead->iPrev;
   1.753 +	}
   1.754 +
   1.755 +
   1.756 +
   1.757 +
   1.758 +EXPORT_C void TDblQueIterBase::DoSet(TAny* aLink)
   1.759 +/**
   1.760 +Sets the iterator to point to a specific element in the list.
   1.761 +
   1.762 +The function is an implementation for TDblQueIter::Set().
   1.763 +
   1.764 +@param aLink A pointer to the current list element.
   1.765 +
   1.766 +@see TDblQueIter::Set
   1.767 +*/
   1.768 +	{
   1.769 +
   1.770 +	iNext=PtrAdd((TDblQueLinkBase*)aLink,iOffset);
   1.771 +	}
   1.772 +
   1.773 +
   1.774 +
   1.775 +
   1.776 +EXPORT_C TAny* TDblQueIterBase::DoPostInc()
   1.777 +/**
   1.778 +Gets the current item and then moves to the next item.
   1.779 +
   1.780 +The function is an implementation for TDblQueIter::operator++().
   1.781 +
   1.782 +@return A pointer to the current list element.
   1.783 +
   1.784 +@see TDblQueIter::operator++
   1.785 +*/
   1.786 +	{
   1.787 +
   1.788 +	if (iNext==iHead)
   1.789 +		return(NULL);
   1.790 +	__ASSERT_DEBUG((iNext->iNext!=NULL)&&(iNext->iPrev!=NULL),Panic(ETQueLinkHasBeenRemoved));
   1.791 +	TAny* p=PtrSub(iNext,iOffset);
   1.792 +	iNext=iNext->iNext;
   1.793 +	return(p);
   1.794 +	}
   1.795 +
   1.796 +
   1.797 +
   1.798 +
   1.799 +EXPORT_C TAny* TDblQueIterBase::DoPostDec()
   1.800 +/**
   1.801 +Gets the current item and then moves to the previous item.
   1.802 +
   1.803 +The function is an implementation for TDblQueIter::operator--().
   1.804 +
   1.805 +@return A pointer to the current list element.
   1.806 +
   1.807 +@see TDblQueIter::operator--
   1.808 +*/
   1.809 +	{
   1.810 +
   1.811 +	if (iNext==iHead)
   1.812 +		return(NULL);
   1.813 +	__ASSERT_DEBUG((iNext->iNext!=NULL)&&(iNext->iPrev!=NULL),Panic(ETQueLinkHasBeenRemoved));
   1.814 +	TAny* p=PtrSub(iNext,iOffset);
   1.815 +	iNext=iNext->iPrev;
   1.816 +	return(p);
   1.817 +	}
   1.818 +
   1.819 +
   1.820 +
   1.821 +
   1.822 +EXPORT_C TAny* TDblQueIterBase::DoCurrent()
   1.823 +/**
   1.824 +Gets the current item in the queue.
   1.825 +
   1.826 +The function is an implementation for TDblQueIter::operator T*().
   1.827 +
   1.828 +@return A pointer to the current list element.
   1.829 +
   1.830 +@see TDblQueIter::operator T*
   1.831 +*/
   1.832 +	{
   1.833 +
   1.834 +	if (iNext==iHead)
   1.835 +		return(NULL);
   1.836 +	__ASSERT_DEBUG((iNext->iNext!=NULL)&&(iNext->iPrev!=NULL),Panic(ETQueLinkHasBeenRemoved));
   1.837 +	return(PtrSub(iNext,iOffset));
   1.838 +	}
   1.839 +
   1.840 +
   1.841 +
   1.842 +
   1.843 +EXPORT_C void TDblQueBase::__DbgTestEmpty() const
   1.844 +/**
   1.845 +Tests whether the queue is empty.
   1.846 +
   1.847 +The function is implemented as an __ASSERT_DEBUG.
   1.848 +
   1.849 +@panic USER 79, if the assertion fails.
   1.850 +*/
   1.851 +	{
   1.852 +
   1.853 +	__ASSERT_DEBUG((((TDblQueLink*)iHead.iNext)!=&iHead)&&(((TDblQueLink*)iHead.iPrev)!=&iHead),Panic(ETQueQueueEmpty));
   1.854 +	}
   1.855 +