Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2011-11-17 16:49:55 +0400
committerKenneth Heafield <github@kheafield.com>2011-11-17 16:49:55 +0400
commit72a4c8a0d34529086b91c016ce32f0b03f9778a1 (patch)
tree1520b39aa01e77dda85b57f42749e992b42a886d /util/ersatz_progress.hh
parent07a8558c02fe46b08734c8479b58ad0f9e3a1a3c (diff)
Move kenlm up one level, simplify compilation
Diffstat (limited to 'util/ersatz_progress.hh')
-rw-r--r--util/ersatz_progress.hh54
1 files changed, 54 insertions, 0 deletions
diff --git a/util/ersatz_progress.hh b/util/ersatz_progress.hh
new file mode 100644
index 000000000..92c345fee
--- /dev/null
+++ b/util/ersatz_progress.hh
@@ -0,0 +1,54 @@
+#ifndef UTIL_ERSATZ_PROGRESS__
+#define UTIL_ERSATZ_PROGRESS__
+
+#include <iosfwd>
+#include <string>
+
+// Ersatz version of boost::progress so core language model doesn't depend on
+// boost. Also adds option to print nothing.
+
+namespace util {
+class ErsatzProgress {
+ public:
+ // No output.
+ ErsatzProgress();
+
+ // Null means no output. The null value is useful for passing along the ostream pointer from another caller.
+ ErsatzProgress(std::ostream *to, const std::string &message, std::size_t complete);
+
+ ~ErsatzProgress();
+
+ ErsatzProgress &operator++() {
+ if (++current_ >= next_) Milestone();
+ return *this;
+ }
+
+ ErsatzProgress &operator+=(std::size_t amount) {
+ if ((current_ += amount) >= next_) Milestone();
+ return *this;
+ }
+
+ void Set(std::size_t to) {
+ if ((current_ = to) >= next_) Milestone();
+ Milestone();
+ }
+
+ void Finished() {
+ Set(complete_);
+ }
+
+ private:
+ void Milestone();
+
+ std::size_t current_, next_, complete_;
+ unsigned char stones_written_;
+ std::ostream *out_;
+
+ // noncopyable
+ ErsatzProgress(const ErsatzProgress &other);
+ ErsatzProgress &operator=(const ErsatzProgress &other);
+};
+
+} // namespace util
+
+#endif // UTIL_ERSATZ_PROGRESS__