1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/usbcque.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,147 @@
1.4 +// Copyright (c) 2002-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\include\drivers\usbcque.h
1.18 +// Simple singly linked list + its iterator for the USB Device driver.
1.19 +//
1.20 +//
1.21 +
1.22 +/**
1.23 + @file usbcque.h
1.24 + @internalTechnology
1.25 +*/
1.26 +
1.27 +#ifndef __USBCQUE_H__
1.28 +#define __USBCQUE_H__
1.29 +
1.30 +#include <kernel/kernel.h>
1.31 +
1.32 +
1.33 +//
1.34 +// --- Class definitions ---
1.35 +//
1.36 +
1.37 +class TSglQueLink
1.38 + {
1.39 +private:
1.40 + void Enque(TSglQueLink* aLink);
1.41 +public:
1.42 + TSglQueLink* iNext;
1.43 + friend class TSglQueBase;
1.44 + };
1.45 +
1.46 +
1.47 +class TSglQueBase
1.48 + {
1.49 +protected:
1.50 + TSglQueBase(TInt aOffset);
1.51 + void DoAddLast(TAny* aPtr);
1.52 + void DoRemove(TAny* aPtr);
1.53 +protected:
1.54 + TSglQueLink* iHead;
1.55 + TSglQueLink* iLast;
1.56 + TInt iOffset;
1.57 + TInt iElements;
1.58 +private:
1.59 + friend class TSglQueIterBase;
1.60 + };
1.61 +
1.62 +
1.63 +template<class T>
1.64 +class TSglQue : public TSglQueBase
1.65 + {
1.66 +public:
1.67 + inline TSglQue(TInt aOffset);
1.68 + inline void AddLast(T& aRef);
1.69 + inline void Remove(T& aRef);
1.70 + inline TInt Elements() const;
1.71 + };
1.72 +
1.73 +
1.74 +class TSglQueIterBase
1.75 + {
1.76 +public:
1.77 + void SetToFirst();
1.78 +protected:
1.79 + TSglQueIterBase(TSglQueBase& aQue);
1.80 + TAny* DoPostInc();
1.81 + TAny* DoCurrent();
1.82 +protected:
1.83 + TInt iOffset;
1.84 + TSglQueLink*& iHead;
1.85 + TSglQueLink* iNext;
1.86 + };
1.87 +
1.88 +
1.89 +template<class T>
1.90 +class TSglQueIter : public TSglQueIterBase
1.91 + {
1.92 +public:
1.93 + inline TSglQueIter(TSglQueBase& aQue);
1.94 + inline operator T*();
1.95 + inline T* operator++(TInt);
1.96 + };
1.97 +
1.98 +//
1.99 +// --- Inline implementations ---
1.100 +//
1.101 +
1.102 +// Class TSglQue
1.103 +template<class T>
1.104 +inline TSglQue<T>::TSglQue(TInt aOffset)
1.105 + : TSglQueBase(aOffset)
1.106 + {}
1.107 +
1.108 +
1.109 +template<class T>
1.110 +inline void TSglQue<T>::AddLast(T& aRef)
1.111 + {
1.112 + DoAddLast(&aRef);
1.113 + }
1.114 +
1.115 +
1.116 +template<class T>
1.117 +inline void TSglQue<T>::Remove(T& aRef)
1.118 + {
1.119 + DoRemove(&aRef);
1.120 + }
1.121 +
1.122 +
1.123 +template<class T>
1.124 +inline TInt TSglQue<T>::Elements() const
1.125 + {
1.126 + return iElements;
1.127 + }
1.128 +
1.129 +
1.130 +// Class TSglQueIter
1.131 +template<class T>
1.132 +inline TSglQueIter<T>::TSglQueIter(TSglQueBase& aQue)
1.133 + : TSglQueIterBase(aQue)
1.134 + {}
1.135 +
1.136 +
1.137 +template<class T>
1.138 +inline TSglQueIter<T>::operator T*()
1.139 + {
1.140 + return ((T*)DoCurrent());
1.141 + }
1.142 +
1.143 +template<class T>
1.144 +inline T* TSglQueIter<T>::operator++(TInt)
1.145 + {
1.146 + return ((T*)DoPostInc());
1.147 + }
1.148 +
1.149 +
1.150 +#endif // __USBCQUE_H__