HG-MD  1
Public Member Functions | Private Attributes
Time2Finish Class Reference

estimates the time in seconds when tmax should be reached More...

#include <Time.h>

List of all members.

Public Member Functions

void set (Mdouble t, Mdouble tmax)
Mdouble getTime2Finish (Mdouble t)
string getFinishTime (Mdouble t)

Private Attributes

clock_t start
Mdouble t_
Mdouble tmax_

Detailed Description

estimates the time in seconds when tmax should be reached


Member Function Documentation

string Time2Finish::getFinishTime ( Mdouble  t) [inline]
                                        {       
                Mdouble time2Finish = getTime2Finish(t);
                time_t finish = time(NULL) + time2Finish;
                stringstream ss;
                //write estimated end time
                ss << ctime(&finish);
                //decrement put pointer by one to avoid line break
                ss.seekp((long)ss.tellp()-1);
                //write time to finish
                ss << " (" << time2Finish/3600 << "h)";
                return ss.str();
        }
                                          {
                clock_t finish = clock();
                Mdouble elapsedTime = (Mdouble(finish)-Mdouble(start))/CLOCKS_PER_SEC;
                Mdouble time2Finish = elapsedTime*(tmax_-t_)/(t-t_);
                start = finish;
                t_ = t;
                return time2Finish;     
        }
void Time2Finish::set ( Mdouble  t,
Mdouble  tmax 
) [inline]
{start = clock(); t_=t; tmax_=tmax;}

Member Data Documentation

clock_t Time2Finish::start [private]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines