diff options
author | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-10-18 23:24:01 +0000 |
---|---|---|
committer | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-10-18 23:24:01 +0000 |
commit | e0ef743090038ee02d656cee11debd2246624ba0 (patch) | |
tree | e5e1d32402c8dcb490c574e24c087c56d4cc172e /klm/util/ersatz_progress.hh | |
parent | 0c2514868f58bbfe422aa275e2905182cf2f57eb (diff) |
kenneth's LM preliminary integration
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@681 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'klm/util/ersatz_progress.hh')
-rw-r--r-- | klm/util/ersatz_progress.hh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/klm/util/ersatz_progress.hh b/klm/util/ersatz_progress.hh new file mode 100644 index 00000000..ea6c3bb9 --- /dev/null +++ b/klm/util/ersatz_progress.hh @@ -0,0 +1,50 @@ +#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(); + } + + 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__ |