sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\include\drivers\usbcque.h sl@0: // Simple singly linked list + its iterator for the USB Device driver. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file usbcque.h sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __USBCQUE_H__ sl@0: #define __USBCQUE_H__ sl@0: sl@0: #include sl@0: sl@0: sl@0: // sl@0: // --- Class definitions --- sl@0: // sl@0: sl@0: class TSglQueLink sl@0: { sl@0: private: sl@0: void Enque(TSglQueLink* aLink); sl@0: public: sl@0: TSglQueLink* iNext; sl@0: friend class TSglQueBase; sl@0: }; sl@0: sl@0: sl@0: class TSglQueBase sl@0: { sl@0: protected: sl@0: TSglQueBase(TInt aOffset); sl@0: void DoAddLast(TAny* aPtr); sl@0: void DoRemove(TAny* aPtr); sl@0: protected: sl@0: TSglQueLink* iHead; sl@0: TSglQueLink* iLast; sl@0: TInt iOffset; sl@0: TInt iElements; sl@0: private: sl@0: friend class TSglQueIterBase; sl@0: }; sl@0: sl@0: sl@0: template sl@0: class TSglQue : public TSglQueBase sl@0: { sl@0: public: sl@0: inline TSglQue(TInt aOffset); sl@0: inline void AddLast(T& aRef); sl@0: inline void Remove(T& aRef); sl@0: inline TInt Elements() const; sl@0: }; sl@0: sl@0: sl@0: class TSglQueIterBase sl@0: { sl@0: public: sl@0: void SetToFirst(); sl@0: protected: sl@0: TSglQueIterBase(TSglQueBase& aQue); sl@0: TAny* DoPostInc(); sl@0: TAny* DoCurrent(); sl@0: protected: sl@0: TInt iOffset; sl@0: TSglQueLink*& iHead; sl@0: TSglQueLink* iNext; sl@0: }; sl@0: sl@0: sl@0: template sl@0: class TSglQueIter : public TSglQueIterBase sl@0: { sl@0: public: sl@0: inline TSglQueIter(TSglQueBase& aQue); sl@0: inline operator T*(); sl@0: inline T* operator++(TInt); sl@0: }; sl@0: sl@0: // sl@0: // --- Inline implementations --- sl@0: // sl@0: sl@0: // Class TSglQue sl@0: template sl@0: inline TSglQue::TSglQue(TInt aOffset) sl@0: : TSglQueBase(aOffset) sl@0: {} sl@0: sl@0: sl@0: template sl@0: inline void TSglQue::AddLast(T& aRef) sl@0: { sl@0: DoAddLast(&aRef); sl@0: } sl@0: sl@0: sl@0: template sl@0: inline void TSglQue::Remove(T& aRef) sl@0: { sl@0: DoRemove(&aRef); sl@0: } sl@0: sl@0: sl@0: template sl@0: inline TInt TSglQue::Elements() const sl@0: { sl@0: return iElements; sl@0: } sl@0: sl@0: sl@0: // Class TSglQueIter sl@0: template sl@0: inline TSglQueIter::TSglQueIter(TSglQueBase& aQue) sl@0: : TSglQueIterBase(aQue) sl@0: {} sl@0: sl@0: sl@0: template sl@0: inline TSglQueIter::operator T*() sl@0: { sl@0: return ((T*)DoCurrent()); sl@0: } sl@0: sl@0: template sl@0: inline T* TSglQueIter::operator++(TInt) sl@0: { sl@0: return ((T*)DoPostInc()); sl@0: } sl@0: sl@0: sl@0: #endif // __USBCQUE_H__