libmoost
/home/mhx/git/github/libmoost/include/moost/progress/policy/skeleton.hpp
Go to the documentation of this file.
00001 /* vim:set ts=3 sw=3 sts=3 et: */
00028 #ifndef MOOST_UTILS_PROGRESS_POLICY_SKELETON_HPP__
00029 #define MOOST_UTILS_PROGRESS_POLICY_SKELETON_HPP__
00030 
00031 #include <ostream>
00032 
00035 
00036 namespace moost { namespace progress { namespace policy {
00037 
00041 
00044    template<typename CounterType = size_t>
00045    class skeleton // this is an example policy -- it does absolutely nothing of any use :)
00046    {
00047    public:
00049       typedef CounterType counter_type;
00050 
00052       skeleton(std::ostream & out = std::cout)
00053          : counter_(0), out_(out)
00054       {
00055       }
00056 
00057       counter_type  operator+=(counter_type const incr)
00058       {
00059          animate();
00060          return counter_ += incr;
00061       }
00062 
00066       counter_type operator ++ ()
00067       {
00068          return *this += 1;
00069       }
00070 
00071       counter_type operator ++ (int)
00072       {
00073          counter_type const tmp = counter_;
00074          ++*this; // call += to ensure any thing it does (such as animate) is applied
00075          return tmp;
00076       }
00077 
00079       counter_type count() const
00080       {
00081          return counter_;
00082       }
00083 
00087       counter_type expected_count() const
00088       {
00089          return counter_;
00090       }
00091 
00092    private:
00093       void animate()
00094       {
00095          // TODO: Your progess display animation goes here, which should take into account that incr
00096          //        could be > 1 so you need to ensure you display an appropriate number of 'frames'.
00097 
00098       }
00099 
00100    private:
00101       counter_type counter_;
00102       std::ostream & out_;
00103    };
00104 
00105 }}}
00106 
00107 #endif // MOOST_UTILS_PROGRESS_POLICY_SKELETON_HPP__