0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CUSBPNPACKET_H
|
|
20 |
#define CUSBPNPACKET_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <e32base.h> // For CBase
|
|
24 |
|
|
25 |
// CONSTANTS
|
|
26 |
// MACROS
|
|
27 |
// DATA TYPES
|
|
28 |
// FUNCTION PROTOTYPES
|
|
29 |
// FORWARD DECLARATIONS
|
|
30 |
|
|
31 |
|
|
32 |
/**
|
|
33 |
* CUsbPnPacket
|
|
34 |
* Implements circular data packet buffer functionality.
|
|
35 |
*/
|
|
36 |
class CUsbPnPacket : public CBase
|
|
37 |
{
|
|
38 |
public:
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Two-phased constructor.
|
|
42 |
*/
|
|
43 |
static CUsbPnPacket* NewL( CUsbPnPacket* aPacket, TInt aNum );
|
|
44 |
|
|
45 |
/**
|
|
46 |
* Destructor
|
|
47 |
*/
|
|
48 |
~CUsbPnPacket();
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Returns the next packet.
|
|
52 |
* @return CUsbPnPacket* The next packet.
|
|
53 |
*/
|
|
54 |
CUsbPnPacket& NextPacket() const;
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Returns the buffer.
|
|
58 |
* @return TDes8* Buffer
|
|
59 |
*/
|
|
60 |
HBufC8& Buffer() const;
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Returns true if packet contains data already.
|
|
64 |
* @return TBool Sync flag.
|
|
65 |
*/
|
|
66 |
TBool PacketInUse() const;
|
|
67 |
|
|
68 |
/**
|
|
69 |
*
|
|
70 |
*/
|
|
71 |
TInt PacketNumber() const;
|
|
72 |
|
|
73 |
/**
|
|
74 |
*Release packet's buffer after usage.
|
|
75 |
*Realloc to standard size if bigger than usual.
|
|
76 |
*/
|
|
77 |
void ReleaseL();
|
|
78 |
|
|
79 |
/**
|
|
80 |
*Realloc packet's buffer if bigger needed.
|
|
81 |
*/
|
|
82 |
void ReallocBufferL( const TInt aNeededLength );
|
|
83 |
|
|
84 |
private:
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Constructor. Allocates memory.
|
|
88 |
* @param CUsbPnPacket* aUsbPacket A packet which is linked as next packet to this packet.
|
|
89 |
* @param TInt aNum Serial number of the created packet for easing debugging.
|
|
90 |
*/
|
|
91 |
CUsbPnPacket( CUsbPnPacket* aPacket, TInt aNum );
|
|
92 |
|
|
93 |
/**
|
|
94 |
* By default Symbian 2nd phase constructor is private.
|
|
95 |
*/
|
|
96 |
void ConstructL();
|
|
97 |
|
|
98 |
/* defined for preventing misuse */
|
|
99 |
explicit CUsbPnPacket(const CUsbPnPacket&);
|
|
100 |
CUsbPnPacket& operator=(const CUsbPnPacket&);
|
|
101 |
|
|
102 |
|
|
103 |
// Pointer to next packet in circular buffer.
|
|
104 |
CUsbPnPacket* iNextPacket;
|
|
105 |
|
|
106 |
// Ownership. Pointer to buffer
|
|
107 |
HBufC8* iBuffer;
|
|
108 |
|
|
109 |
// Order number
|
|
110 |
TInt iNumber;
|
|
111 |
};
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
#endif // #ifndef CUSBPNPACKET_H
|