xref: /haiku/src/apps/installer/ProgressReporter.h (revision e81a954787e50e56a7f06f72705b7859b6ab06d1)
1 /*
2  * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
3  *  All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef PROGRESS_REPORTER_H
6 #define PROGRESS_REPORTER_H
7 
8 
9 #include <Messenger.h>
10 
11 
12 class ProgressReporter {
13 public:
14 								ProgressReporter(const BMessenger& messenger,
15 									BMessage* message);
16 	virtual						~ProgressReporter();
17 
18 			void				Reset();
19 
20 			void				AddItems(uint64 count, off_t bytes);
21 
22 			void				StartTimer();
23 
24 			void				ItemsWritten(uint64 items, off_t bytes,
25 									const char* itemName,
26 									const char* targetFolder);
27 
28 			// TODO: Perhaps move cancelling here as well...
29 
30 private:
31 			void				_UpdateProgress(const char* itemName,
32 									const char* targetFolder);
33 
34 private:
35 			bigtime_t			fStartTime;
36 
37 			off_t				fBytesToWrite;
38 			off_t				fBytesWritten;
39 
40 			uint64				fItemsToWrite;
41 			uint64				fItemsWritten;
42 
43 			BMessenger			fMessenger;
44 			BMessage*			fMessage;
45 };
46 
47 
48 #endif // PROGRESS_REPORTER_H
49