williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@2
|
5 |
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description: CPosLandmarkEncoder class
|
williamr@2
|
15 |
*
|
williamr@2
|
16 |
*/
|
williamr@2
|
17 |
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#ifndef CPOSLANDMARKENCODER_H
|
williamr@2
|
20 |
#define CPOSLANDMARKENCODER_H
|
williamr@2
|
21 |
|
williamr@2
|
22 |
#include <e32base.h>
|
williamr@2
|
23 |
#include "EPos_Landmarks.h"
|
williamr@2
|
24 |
#include "EPos_CPosLandmark.h"
|
williamr@2
|
25 |
#include "EPos_CPosLandmarkCategory.h"
|
williamr@2
|
26 |
#include "EPos_CPosLmOperation.h"
|
williamr@2
|
27 |
|
williamr@2
|
28 |
class CPosLandmarkEncoderExtension;
|
williamr@2
|
29 |
|
williamr@2
|
30 |
/**
|
williamr@2
|
31 |
* Class used for encoding landmark content.
|
williamr@2
|
32 |
*
|
williamr@2
|
33 |
* When creating an instance of this class, the type (e.g. the mime type) of
|
williamr@2
|
34 |
* the landmark content must be specified. The client will then receive an
|
williamr@2
|
35 |
* encoder implementation which understands the requested landmark content.
|
williamr@2
|
36 |
*
|
williamr@2
|
37 |
* Output is written either to a buffer or to a file.
|
williamr@2
|
38 |
*
|
williamr@2
|
39 |
* The basic protocol for encoding is to
|
williamr@2
|
40 |
* -# define where to write the output to by calling @ref SetUseOutputBufferL or
|
williamr@2
|
41 |
* @ref SetOutputFileL,
|
williamr@2
|
42 |
* -# optionally add collection data using @ref AddCollectionDataL,
|
williamr@2
|
43 |
* -# add landmark data to encode by using functions in @ref CPosLandmarkEncoder
|
williamr@2
|
44 |
* and/or @ref CPosLandmarkDatabase::ExportLandmarksL
|
williamr@2
|
45 |
* -# finalize the encoding by calling @ref FinalizeEncodingL.
|
williamr@2
|
46 |
*
|
williamr@2
|
47 |
* If this protocol is not followed
|
williamr@2
|
48 |
* the client is panicked with error code @p EPosLmProtocolBreak. Encoding can
|
williamr@2
|
49 |
* be performed multiple times using the same encoder object.
|
williamr@2
|
50 |
*
|
williamr@2
|
51 |
* If @ref CPosLandmarkEncoder is used, the client must call the global
|
williamr@2
|
52 |
* function @ref ReleaseLandmarkResources before terminating, in order to
|
williamr@2
|
53 |
* release all used landmark resources, otherwise the client may receive
|
williamr@2
|
54 |
* an ALLOC panic.
|
williamr@2
|
55 |
*
|
williamr@2
|
56 |
* @lib eposlandmarks.lib
|
williamr@2
|
57 |
* @since S60 3.0
|
williamr@2
|
58 |
*/
|
williamr@2
|
59 |
class CPosLandmarkEncoder : public CBase
|
williamr@2
|
60 |
{
|
williamr@2
|
61 |
public:
|
williamr@2
|
62 |
|
williamr@2
|
63 |
/**
|
williamr@2
|
64 |
* Two-phased constructor.
|
williamr@2
|
65 |
*
|
williamr@2
|
66 |
* The client must specify the type (e.g. the MIME type) of the content
|
williamr@2
|
67 |
* format which should be used for encoding.
|
williamr@2
|
68 |
*
|
williamr@2
|
69 |
* @param[in] The MIME type of the encode format.
|
williamr@2
|
70 |
* @return A new instance of this class.
|
williamr@2
|
71 |
*
|
williamr@2
|
72 |
* @leave KErrNotSupported Content format is not supported.
|
williamr@2
|
73 |
*/
|
williamr@2
|
74 |
IMPORT_C static CPosLandmarkEncoder* NewL( const TDesC8& aContentMimeType );
|
williamr@2
|
75 |
|
williamr@2
|
76 |
/**
|
williamr@2
|
77 |
* Destructor.
|
williamr@2
|
78 |
*/
|
williamr@2
|
79 |
IMPORT_C virtual ~CPosLandmarkEncoder();
|
williamr@2
|
80 |
|
williamr@2
|
81 |
public:
|
williamr@2
|
82 |
|
williamr@2
|
83 |
/**
|
williamr@2
|
84 |
* Encode to a buffer.
|
williamr@2
|
85 |
*
|
williamr@2
|
86 |
* This function returns a dynamic buffer which will be filled with
|
williamr@2
|
87 |
* encoded landmark content. The client takes ownership of the buffer.
|
williamr@2
|
88 |
*
|
williamr@2
|
89 |
* The client must not delete the buffer until encoding is finalized.
|
williamr@2
|
90 |
*
|
williamr@2
|
91 |
* @return The output buffer.
|
williamr@2
|
92 |
*/
|
williamr@2
|
93 |
virtual CBufBase* SetUseOutputBufferL() = 0;
|
williamr@2
|
94 |
|
williamr@2
|
95 |
/**
|
williamr@2
|
96 |
* Encode to a file.
|
williamr@2
|
97 |
*
|
williamr@2
|
98 |
* The client specifies an output file for the encoder. The encoder
|
williamr@2
|
99 |
* will then write all encoded data to this file.
|
williamr@2
|
100 |
*
|
williamr@2
|
101 |
* The file will be opened in exclusive mode which means that the file
|
williamr@2
|
102 |
* cannot be accessed until the file is closed. The file is closed when
|
williamr@2
|
103 |
* @ref FinalizeEncodingL has been executed. The file is also closed
|
williamr@2
|
104 |
* if a new encoding is initialized by a call to
|
williamr@2
|
105 |
* @ref SetUseOutputBufferL or @ref SetOutputFileL. After this, further
|
williamr@2
|
106 |
* encoding to the old file is not possible.
|
williamr@2
|
107 |
*
|
williamr@2
|
108 |
* @param[in] aOutputFile The file name to write the encoded data to.
|
williamr@2
|
109 |
*
|
williamr@2
|
110 |
* @leave KErrAlreadyExists Specified file already exists.
|
williamr@2
|
111 |
*/
|
williamr@2
|
112 |
virtual void SetOutputFileL( const TDesC& aOutputFile ) = 0;
|
williamr@2
|
113 |
|
williamr@2
|
114 |
/**
|
williamr@2
|
115 |
* Add landmark collection data to be encoded.
|
williamr@2
|
116 |
*
|
williamr@2
|
117 |
* @pre Output buffer or file is specified.
|
williamr@2
|
118 |
*
|
williamr@2
|
119 |
* Landmark collection data is generic information about the landmark
|
williamr@2
|
120 |
* collection. It can for instance contain a name for the landmark
|
williamr@2
|
121 |
* collection. Predefined collection attributes are defined by
|
williamr@2
|
122 |
* @ref TPosLmCollectionDataId enumeration but also format specific
|
williamr@2
|
123 |
* collection meta data can be defined.
|
williamr@2
|
124 |
*
|
williamr@2
|
125 |
* Collection data must be added before any landmarks are added.
|
williamr@2
|
126 |
* Each collection ID can only be specified once.
|
williamr@2
|
127 |
*
|
williamr@2
|
128 |
* If the collection data is not a part of the chosen landmark encoding
|
williamr@2
|
129 |
* format, it will be silently ignored.
|
williamr@2
|
130 |
*
|
williamr@2
|
131 |
* @param[in] aDataId Identifies which collection data to add.
|
williamr@2
|
132 |
* @param[in] aCollectionData The collection data which should be added.
|
williamr@2
|
133 |
*
|
williamr@2
|
134 |
* @leave KErrAlreadyExists Collection data ID is specified twice.
|
williamr@2
|
135 |
*
|
williamr@2
|
136 |
* @panic "Landmarks Client"-EPosLmProtocolBreak
|
williamr@2
|
137 |
* -# Output buffer or file not specified.
|
williamr@2
|
138 |
* -# Collection data is added after some landmarks are added.
|
williamr@2
|
139 |
* @panic "Landmarks Client"-EPosLmInvalidArgument @p EPosLmCollDataNone is
|
williamr@2
|
140 |
* specified as collection data ID.
|
williamr@2
|
141 |
*/
|
williamr@2
|
142 |
virtual void AddCollectionDataL(
|
williamr@2
|
143 |
TPosLmCollectionDataId aDataId,
|
williamr@2
|
144 |
const TDesC& aCollectionData
|
williamr@2
|
145 |
) = 0;
|
williamr@2
|
146 |
|
williamr@2
|
147 |
/**
|
williamr@2
|
148 |
* Add a landmark to be encoded.
|
williamr@2
|
149 |
*
|
williamr@2
|
150 |
* @pre Output buffer or file is specified.
|
williamr@2
|
151 |
*
|
williamr@2
|
152 |
* If the landmark contains any categories, those categories may be
|
williamr@2
|
153 |
* added by calling @ref AddCategoryForLatestLandmarkL.
|
williamr@2
|
154 |
*
|
williamr@2
|
155 |
* The client can either call this function directly or pass this encoder
|
williamr@2
|
156 |
* object to @ref CPosLandmarkDatabase::ExportLandmarksL.
|
williamr@2
|
157 |
*
|
williamr@2
|
158 |
* @param[in] aLandmark The landmark to add.
|
williamr@2
|
159 |
*
|
williamr@2
|
160 |
* @panic "Landmarks Client"-EPosLmProtocolBreak Output buffer or file not specified.
|
williamr@2
|
161 |
*/
|
williamr@2
|
162 |
virtual void AddLandmarkL( const CPosLandmark& aLandmark ) = 0;
|
williamr@2
|
163 |
|
williamr@2
|
164 |
/**
|
williamr@2
|
165 |
* Add a landmark category for the most recently added landmark.
|
williamr@2
|
166 |
*
|
williamr@2
|
167 |
* @pre Output buffer or file is specified.
|
williamr@2
|
168 |
*
|
williamr@2
|
169 |
* The landmark category is added to the landmark which was most
|
williamr@2
|
170 |
* recently added using @ref AddLandmarkL.
|
williamr@2
|
171 |
*
|
williamr@2
|
172 |
* The client can either call this function directly or pass this
|
williamr@2
|
173 |
* encoder object to @ref CPosLandmarkDatabase::ExportLandmarksL.
|
williamr@2
|
174 |
*
|
williamr@2
|
175 |
* @param[in] aCategory The landmark category to add.
|
williamr@2
|
176 |
*
|
williamr@2
|
177 |
* @panic "Landmarks Client"-EPosLmProtocolBreak
|
williamr@2
|
178 |
* -# Output buffer or file not specified.
|
williamr@2
|
179 |
* -# No landmarks have been added yet.
|
williamr@2
|
180 |
*/
|
williamr@2
|
181 |
virtual void AddCategoryForLatestLandmarkL(
|
williamr@2
|
182 |
const CPosLandmarkCategory& aCategory
|
williamr@2
|
183 |
) = 0;
|
williamr@2
|
184 |
|
williamr@2
|
185 |
/**
|
williamr@2
|
186 |
* Finalize the encode process.
|
williamr@2
|
187 |
*
|
williamr@2
|
188 |
* Writes any buffered data to the output buffer/file. If an output
|
williamr@2
|
189 |
* buffer is used it is compressed so that unused memory is freed. If an
|
williamr@2
|
190 |
* output file is used, it is closed.
|
williamr@2
|
191 |
*
|
williamr@2
|
192 |
* After finalizing, further encoding to the specified output is not
|
williamr@2
|
193 |
* possible. To start a new encoding, @ref SetUseOutputBufferL or
|
williamr@2
|
194 |
* @ref SetOutputFileL must be called.
|
williamr@2
|
195 |
*
|
williamr@2
|
196 |
* The function returns an operation object which can be run in
|
williamr@2
|
197 |
* incremental mode. If it is run incrementally the client can supervise
|
williamr@2
|
198 |
* the progress of the operation.
|
williamr@2
|
199 |
*
|
williamr@2
|
200 |
* The client takes ownership of the returned operation object.
|
williamr@2
|
201 |
*
|
williamr@2
|
202 |
* If the @ref CPosLmOperation object is deleted before the operation
|
williamr@2
|
203 |
* is complete, finalize is cancelled. Further encoding will not be
|
williamr@2
|
204 |
* possible.
|
williamr@2
|
205 |
*
|
williamr@2
|
206 |
* @return A handle to the operation.
|
williamr@2
|
207 |
*/
|
williamr@2
|
208 |
virtual CPosLmOperation* FinalizeEncodingL() = 0;
|
williamr@2
|
209 |
|
williamr@2
|
210 |
protected:
|
williamr@2
|
211 |
|
williamr@2
|
212 |
// C++ constructor.
|
williamr@2
|
213 |
IMPORT_C CPosLandmarkEncoder();
|
williamr@2
|
214 |
|
williamr@2
|
215 |
private:
|
williamr@2
|
216 |
|
williamr@2
|
217 |
// Prohibit copy constructor
|
williamr@2
|
218 |
CPosLandmarkEncoder( const CPosLandmarkEncoder& );
|
williamr@2
|
219 |
// Prohibit assigment operator
|
williamr@2
|
220 |
CPosLandmarkEncoder& operator= ( const CPosLandmarkEncoder& );
|
williamr@2
|
221 |
|
williamr@2
|
222 |
private:
|
williamr@2
|
223 |
CPosLandmarkEncoderExtension* iExtension;
|
williamr@2
|
224 |
|
williamr@2
|
225 |
// Implementation Uid
|
williamr@2
|
226 |
TUid iDtorIdKey;
|
williamr@2
|
227 |
};
|
williamr@2
|
228 |
|
williamr@2
|
229 |
#endif // CPOSLANDMARKENCODER_H
|
williamr@2
|
230 |
|
williamr@2
|
231 |
|