libzypp
12.16.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
libzypp
Welcome to libzypp
Code Pitfalls - Frequently made mistakes
Code Snippets
Environment Variables
Testing for provided features.
Notes on revisions
Extending ZYpp: Plugins and Hooks
Services
Solver - Vendor protection
Writing and tunning testcases
Libzypp and threads
User data as transaction id
Todo List
Deprecated List
Modules
Namespaces
Classes
Files
File List
zypp
base
media
misc
parser
pool
repo
sat
solver
target
thread
ui
url
ws
zypp_detail
APIConfig.h
Arch.cc
Arch.h
AutoDispose.h
Bit.h
ByteCount.cc
ByteCount.h
Callback.h
Capabilities.cc
Capabilities.h
Capability.cc
Capability.h
CapMatch.cc
CapMatch.h
Changelog.cc
Changelog.h
CheckSum.cc
CheckSum.h
CountryCode.cc
CountryCode.h
Date.cc
Date.h
Dep.cc
Dep.h
Digest.cc
Digest.h
DiskUsage.cc
DiskUsage.h
DiskUsageCounter.cc
DiskUsageCounter.h
DownloadMode.cc
DownloadMode.h
Edition.cc
Edition.h
ExternalProgram.cc
ExternalProgram.h
Fetcher.cc
Fetcher.h
FileChecker.cc
FileChecker.h
Filter.h
Glob.cc
Glob.h
HistoryLog.cc
HistoryLog.h
HistoryLogData.cc
HistoryLogData.h
IdString.cc
IdString.h
IdStringType.h
InstanceId.cc
InstanceId.h
KeyContext.h
KeyRing.cc
KeyRing.h
KVMap.h
LanguageCode.cc
LanguageCode.h
Locale.cc
Locale.h
Locks.cc
Locks.h
ManagedFile.h
MediaProducts.cc
MediaProducts.h
MediaSetAccess.cc
MediaSetAccess.h
Misc.h
OnMediaLocation.cc
OnMediaLocation.h
Package.cc
Package.h
PackageKeyword.h
Patch.cc
Patch.h
PathInfo.cc
PathInfo.h
Pathname.cc
Pathname.h
Pattern.cc
Pattern.h
PluginFrame.cc
PluginFrame.h
PluginFrameException.cc
PluginFrameException.h
PluginScript.cc
PluginScript.h
PluginScriptException.cc
PluginScriptException.h
PoolItem.cc
PoolItem.h
PoolItemBest.cc
PoolItemBest.h
PoolQuery.cc
PoolQuery.h
PoolQueryResult.cc
PoolQueryResult.h
PoolQueryUtil.tcc
ProblemSolution.cc
ProblemSolution.h
ProblemTypes.h
Product.cc
Product.h
ProgressData.cc
ProgressData.h
ProvideFilePolicy.cc
ProvideFilePolicy.h
PublicKey.cc
PublicKey.h
Range.cc
Range.h
Rel.cc
Rel.h
RelCompare.h
RepoInfo.cc
RepoInfo.h
RepoManager.cc
RepoManager.h
Repository.cc
Repository.h
RepoStatus.cc
RepoStatus.h
ResFilters.h
ResKind.cc
ResKind.h
ResObject.cc
ResObject.h
ResObjects.h
Resolvable.cc
Resolvable.h
Resolver.cc
Resolver.h
ResolverProblem.cc
ResolverProblem.h
ResPool.cc
ResPool.h
ResPoolProxy.cc
ResPoolProxy.h
ResStatus.cc
ResStatus.h
ResTraits.h
ServiceInfo.cc
ServiceInfo.h
Signature.cc
Signature.h
SrcPackage.cc
SrcPackage.h
SysContent.cc
SysContent.h
Target.cc
Target.h
TmpPath.cc
TmpPath.h
TriBool.h
Url.cc
Url.h
Vendor.h
VendorAttr.cc
VendorAttr.h
VendorSupportOptions.cc
VendorSupportOptions.h
ZConfig.cc
ZConfig.h
ZYpp.cc
ZYpp.h
ZYppCallbacks.h
ZYppCommit.h
ZYppCommitPolicy.cc
ZYppCommitPolicy.h
ZYppCommitResult.cc
ZYppCommitResult.h
ZYppFactory.cc
ZYppFactory.h
File Members
ProgressData.h
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
12
#ifndef ZYPP_PROGRESSDATA_H
13
#define ZYPP_PROGRESSDATA_H
14
15
#include <iosfwd>
16
#include <string>
17
18
#include "
zypp/base/PtrTypes.h
"
19
#include "
zypp/base/Function.h
"
20
#include "
zypp/base/ProvideNumericId.h
"
21
22
#include "
zypp/Date.h
"
23
25
namespace
zypp
26
{
27
29
//
30
// CLASS NAME : ProgressData
31
//
135
class
ProgressData
:
public
base::ProvideNumericId
<ProgressData,unsigned>
136
{
137
public
:
138
typedef
long
long
value_type
;
144
typedef
function<bool( const ProgressData & )>
ReceiverFnc
;
145
146
private
:
147
enum
State
{
INIT
,
RUN
,
END
};
148
149
class
Data
150
{
151
public
:
152
Data
(
value_type
min_r,
value_type
max_r,
value_type
val_r )
153
:
_state
(
INIT
),
_min
( min_r ),
_max
( max_r ),
_val
( val_r )
154
,
_last_val
( 0 ),
_last_send
( 0 )
155
{}
156
157
public
:
158
State
_state
;
159
std::string
_name
;
160
value_type
_min
;
161
value_type
_max
;
162
value_type
_val
;
163
164
ReceiverFnc
_receiver
;
165
value_type
_last_val
;
166
Date
_last_send
;
167
168
private
:
170
friend
Data
* rwcowClone<Data>(
const
Data
* rhs );
171
Data
*
clone
()
const
{
return
new
Data
( *
this
); }
172
};
173
174
public
:
176
ProgressData
()
177
:
_d
( new
Data
( 0, 0, 0 ) )
178
{}
179
181
ProgressData
(
value_type
max_r )
182
:
_d
( new
Data
( 0, max_r, 0 ) )
183
{}
184
186
ProgressData
(
value_type
min_r,
value_type
max_r )
187
:
_d
( new
Data
( min_r, max_r, min_r ) )
188
{}
189
191
ProgressData
(
value_type
min_r,
value_type
max_r,
value_type
val_r )
192
:
_d
( new
Data
( min_r, max_r, val_r ) )
193
{}
194
195
~ProgressData
()
196
{
197
if
(
_d
->
_state
==
RUN
)
198
{
199
_d
->
_state
=
END
;
200
report
();
201
}
202
}
203
204
public
:
206
void
min
(
value_type
min_r )
207
{
_d
->
_min
= min_r; }
208
210
void
max
(
value_type
max_r )
211
{
_d
->
_max
= max_r; }
212
214
void
noRange
()
215
{
range
( 0, 0 ); }
216
218
void
range
(
value_type
max_r )
219
{
range
( 0, max_r ); }
220
222
void
range
(
value_type
min_r,
value_type
max_r )
223
{
min
( min_r );
max
( max_r ); }
224
225
public
:
227
void
name
(
const
std::string & name_r )
228
{
_d
->
_name
= name_r; }
229
231
void
sendTo
(
const
ReceiverFnc
& fnc_r )
232
{
_d
->
_receiver
= fnc_r; }
233
235
void
noSend
()
236
{
_d
->
_receiver
=
ReceiverFnc
(); }
237
238
public
:
249
251
bool
set
(
value_type
val_r )
252
{
253
_d
->
_val
= val_r;
254
return
report
();
255
}
256
258
bool
incr
(
value_type
val_r = 1 )
259
{
return
set
(
val
() + val_r ); }
260
262
bool
decr
(
value_type
val_r = 1 )
263
{
return
set
(
val
() - val_r ); }
264
266
bool
toMin
()
267
{
return
set
(
min
() ); }
268
270
bool
toMax
()
271
{
return
set
(
hasRange
() ?
max
() :
val
() ); }
272
274
bool
tick
()
275
{
return
set
(
val
() ); }
276
278
279
public
:
284
value_type
min
()
const
285
{
return
_d
->
_min
; }
286
288
value_type
max
()
const
289
{
return
_d
->
_max
; }
290
292
value_type
val
()
const
293
{
return
_d
->
_val
; }
294
296
bool
hasRange
()
const
297
{
return
min
() !=
max
(); }
298
303
bool
reportPercent
()
const
304
{
return
hasRange
(); }
305
310
bool
reportAlive
()
const
311
{
return
!
hasRange
(); }
312
316
value_type
reportValue
()
const
317
{
return
hasRange
() ?
val
() * 100 / (
max
() -
min
() ) : -1; }
318
320
const
std::string &
name
()
const
321
{
return
_d
->
_name
; }
322
324
const
ReceiverFnc
&
receiver
()
const
325
{
return
_d
->
_receiver
; }
326
330
bool
finalReport
()
const
331
{
return
(
_d
->
_state
==
END
); }
332
334
335
private
:
337
bool
report
();
338
340
RWCOW_pointer<Data>
_d
;
341
};
343
345
std::ostream &
operator<<
( std::ostream & str,
const
ProgressData
& obj );
346
348
349
class
InputStream
;
351
ProgressData
makeProgressData
(
const
InputStream
& input_r );
352
354
387
class
CombinedProgressData
388
{
389
public
:
404
CombinedProgressData
(
ProgressData
&pd,
405
ProgressData::value_type
weight = 0 );
406
411
bool
operator()
(
const
ProgressData
&progress );
412
413
private
:
414
ProgressData::value_type
_weight
;
415
ProgressData::value_type
_last_value
;
416
ProgressData
&
_pd
;
417
};
418
420
}
// namespace zypp
422
#endif // ZYPP_PROGRESSDATA_H
zypp
ProgressData.h
Generated by
1.8.2