0
|
1 |
// Copyright (c) 2002-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 the License "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 |
// e32\include\drivers\usbcque.h
|
|
15 |
// Simple singly linked list + its iterator for the USB Device driver.
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file usbcque.h
|
|
21 |
@internalTechnology
|
|
22 |
*/
|
|
23 |
|
|
24 |
#ifndef __USBCQUE_H__
|
|
25 |
#define __USBCQUE_H__
|
|
26 |
|
|
27 |
#include <kernel/kernel.h>
|
|
28 |
|
|
29 |
|
|
30 |
//
|
|
31 |
// --- Class definitions ---
|
|
32 |
//
|
|
33 |
|
|
34 |
class TSglQueLink
|
|
35 |
{
|
|
36 |
private:
|
|
37 |
void Enque(TSglQueLink* aLink);
|
|
38 |
public:
|
|
39 |
TSglQueLink* iNext;
|
|
40 |
friend class TSglQueBase;
|
|
41 |
};
|
|
42 |
|
|
43 |
|
|
44 |
class TSglQueBase
|
|
45 |
{
|
|
46 |
protected:
|
|
47 |
TSglQueBase(TInt aOffset);
|
|
48 |
void DoAddLast(TAny* aPtr);
|
|
49 |
void DoRemove(TAny* aPtr);
|
|
50 |
protected:
|
|
51 |
TSglQueLink* iHead;
|
|
52 |
TSglQueLink* iLast;
|
|
53 |
TInt iOffset;
|
|
54 |
TInt iElements;
|
|
55 |
private:
|
|
56 |
friend class TSglQueIterBase;
|
|
57 |
};
|
|
58 |
|
|
59 |
|
|
60 |
template<class T>
|
|
61 |
class TSglQue : public TSglQueBase
|
|
62 |
{
|
|
63 |
public:
|
|
64 |
inline TSglQue(TInt aOffset);
|
|
65 |
inline void AddLast(T& aRef);
|
|
66 |
inline void Remove(T& aRef);
|
|
67 |
inline TInt Elements() const;
|
|
68 |
};
|
|
69 |
|
|
70 |
|
|
71 |
class TSglQueIterBase
|
|
72 |
{
|
|
73 |
public:
|
|
74 |
void SetToFirst();
|
|
75 |
protected:
|
|
76 |
TSglQueIterBase(TSglQueBase& aQue);
|
|
77 |
TAny* DoPostInc();
|
|
78 |
TAny* DoCurrent();
|
|
79 |
protected:
|
|
80 |
TInt iOffset;
|
|
81 |
TSglQueLink*& iHead;
|
|
82 |
TSglQueLink* iNext;
|
|
83 |
};
|
|
84 |
|
|
85 |
|
|
86 |
template<class T>
|
|
87 |
class TSglQueIter : public TSglQueIterBase
|
|
88 |
{
|
|
89 |
public:
|
|
90 |
inline TSglQueIter(TSglQueBase& aQue);
|
|
91 |
inline operator T*();
|
|
92 |
inline T* operator++(TInt);
|
|
93 |
};
|
|
94 |
|
|
95 |
//
|
|
96 |
// --- Inline implementations ---
|
|
97 |
//
|
|
98 |
|
|
99 |
// Class TSglQue
|
|
100 |
template<class T>
|
|
101 |
inline TSglQue<T>::TSglQue(TInt aOffset)
|
|
102 |
: TSglQueBase(aOffset)
|
|
103 |
{}
|
|
104 |
|
|
105 |
|
|
106 |
template<class T>
|
|
107 |
inline void TSglQue<T>::AddLast(T& aRef)
|
|
108 |
{
|
|
109 |
DoAddLast(&aRef);
|
|
110 |
}
|
|
111 |
|
|
112 |
|
|
113 |
template<class T>
|
|
114 |
inline void TSglQue<T>::Remove(T& aRef)
|
|
115 |
{
|
|
116 |
DoRemove(&aRef);
|
|
117 |
}
|
|
118 |
|
|
119 |
|
|
120 |
template<class T>
|
|
121 |
inline TInt TSglQue<T>::Elements() const
|
|
122 |
{
|
|
123 |
return iElements;
|
|
124 |
}
|
|
125 |
|
|
126 |
|
|
127 |
// Class TSglQueIter
|
|
128 |
template<class T>
|
|
129 |
inline TSglQueIter<T>::TSglQueIter(TSglQueBase& aQue)
|
|
130 |
: TSglQueIterBase(aQue)
|
|
131 |
{}
|
|
132 |
|
|
133 |
|
|
134 |
template<class T>
|
|
135 |
inline TSglQueIter<T>::operator T*()
|
|
136 |
{
|
|
137 |
return ((T*)DoCurrent());
|
|
138 |
}
|
|
139 |
|
|
140 |
template<class T>
|
|
141 |
inline T* TSglQueIter<T>::operator++(TInt)
|
|
142 |
{
|
|
143 |
return ((T*)DoPostInc());
|
|
144 |
}
|
|
145 |
|
|
146 |
|
|
147 |
#endif // __USBCQUE_H__
|