|
1 /* |
|
2 * Copyright (c) 2008 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 "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: Declares main application class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __HIDDESCRIPTOR_H__ |
|
20 #define __HIDDESCRIPTOR_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <s32strm.h> |
|
24 |
|
25 /*! |
|
26 This class represents an individual BT HID Descriptor |
|
27 */ |
|
28 class CHidDescriptor : public CBase |
|
29 { |
|
30 public: |
|
31 /*! The type of this HID descriptor */ |
|
32 enum TDescType |
|
33 { |
|
34 EReportDescriptor = 0x22, /*!< Report Descriptor */ |
|
35 EPhysicalDescriptor = 0x23, |
|
36 /*!< Physical Descriptor */ |
|
37 }; |
|
38 public: |
|
39 |
|
40 /*! |
|
41 Create a CHidDescriptor object |
|
42 @result a pointer to the created instance of CHidDescriptor |
|
43 */ |
|
44 static CHidDescriptor* NewL(); |
|
45 |
|
46 /*! |
|
47 Create a CHidDescriptor object |
|
48 (object is left on the cleanup stack) |
|
49 @result a pointer to the created instance of CHidDescriptor |
|
50 */ |
|
51 static CHidDescriptor* NewLC(); |
|
52 |
|
53 /*! |
|
54 Create a CHidDescriptor object from a stream. |
|
55 @param aStream a stream to create the object from |
|
56 @result a pointer to the created instance of CHidDescriptor |
|
57 */ |
|
58 static CHidDescriptor* NewL(RReadStream& aStream); |
|
59 |
|
60 /*! |
|
61 Create a CHidDescriptor object from a stream. |
|
62 (object is left on the cleanup stack) |
|
63 @param aStream a stream to create the object from |
|
64 @result a pointer to the created instance of CHidDescriptor |
|
65 */ |
|
66 static CHidDescriptor* NewLC(RReadStream& aStream); |
|
67 |
|
68 /*! |
|
69 Destroy the object and release all memory objects |
|
70 */ |
|
71 ~CHidDescriptor(); |
|
72 |
|
73 /*! |
|
74 Sets the type of this HID descriptor |
|
75 @param aType The type of this descriptor. |
|
76 */ |
|
77 inline void SetDescriptorType(TDescType aType); |
|
78 |
|
79 /*! |
|
80 Sets the contents of the member buffer |
|
81 @param aBuf new buffer to copy. |
|
82 */ |
|
83 inline void SetRawDataL(const TDesC8& aBuf); |
|
84 |
|
85 /*! |
|
86 Gets the type of this HID descriptor |
|
87 @return The type of this descriptor. |
|
88 */ |
|
89 inline TDescType DescriptorType() const; |
|
90 |
|
91 /*! |
|
92 Gets the contents of the member buffer |
|
93 @return A TDesC8 reference to the member data buffer |
|
94 */ |
|
95 inline const TDesC8& RawData() const; |
|
96 |
|
97 /*! |
|
98 Determine the number of bytes this object will take up when |
|
99 externalised to disk |
|
100 @return The size required to externalise. |
|
101 */ |
|
102 TInt DiskSize() const; |
|
103 |
|
104 /*! |
|
105 Externalize data to a stream |
|
106 @param aStream stream object |
|
107 */ |
|
108 void ExternalizeL(RWriteStream& aStream) const; |
|
109 |
|
110 private: |
|
111 |
|
112 /*! |
|
113 Constructs this object |
|
114 */ |
|
115 CHidDescriptor(); |
|
116 |
|
117 /*! |
|
118 Performs second phase construction of this object |
|
119 */ |
|
120 void ConstructL(); |
|
121 |
|
122 /*! |
|
123 Performs second phase construction of this object from a filestore |
|
124 @param aStream a stream to create the object from |
|
125 */ |
|
126 void ConstructL(RReadStream& aStream); |
|
127 |
|
128 private: |
|
129 // Member variables |
|
130 /*! The type of this descriptor */ |
|
131 TDescType iType; |
|
132 |
|
133 /*! The raw descriptor */ |
|
134 HBufC8* iRawData; |
|
135 }; |
|
136 |
|
137 inline void CHidDescriptor::SetDescriptorType(TDescType aType) |
|
138 { |
|
139 iType = aType; |
|
140 } |
|
141 |
|
142 inline void CHidDescriptor::SetRawDataL(const TDesC8& aText) |
|
143 { |
|
144 // Copy the buffer |
|
145 delete iRawData; |
|
146 iRawData = 0; |
|
147 iRawData = aText.AllocL(); |
|
148 } |
|
149 |
|
150 inline CHidDescriptor::TDescType CHidDescriptor::DescriptorType() const |
|
151 { |
|
152 return iType; |
|
153 } |
|
154 |
|
155 inline const TDesC8& CHidDescriptor::RawData() const |
|
156 { |
|
157 if (!iRawData) |
|
158 { |
|
159 return KNullDesC8; |
|
160 } |
|
161 else |
|
162 { |
|
163 return *iRawData; |
|
164 } |
|
165 } |
|
166 |
|
167 #endif // __HIDDESCRIPTOR_H__ |