/** * * @file SleepChronogram.cpp * * @author M. Laporte, D. Mathieu * * @date 05/01/2007 * * @version 2.0 * * @brief SleepChronogr() affiche periodiquement un caractere **/ #include #include // sleep() #include "SleepChronogram.h" using namespace std; using namespace boost; using namespace boost::posix_time; char * nsUtil::clrscr = "\033[2J"; // Clear screen #define GOTOXY nsUtil::gotoxy GOTOXY::gotoxy (int x, int y) : m_x (x), m_y (y) {} ostream & nsUtil::operator << (ostream & os, const gotoxy & m) { return os << "\033[" << m.m_y << ';' << m.m_x << 'H'; } #undef GOTOXY void nsUtil::SleepChronogram (unsigned Num, unsigned & Col, char Status, unsigned Duree, boost::mutex & ioMutex, unsigned Decal /* = 10u */, unsigned Periode /* = 1u */) throw (std::ios_base::failure) { for (unsigned i = Duree; i--; ) { { lock_guard Lock (ioMutex); cout << gotoxy (Col++, Num + Decal) << Status << flush; } this_thread::sleep (seconds (Periode)); } } // SleepChronogr()