BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/facilities/facilities/Scheduler.h
Go to the documentation of this file.
1// $Id: Scheduler.h,v 1.1.1.1 2005/10/17 06:11:40 maqm Exp $
2
3#ifndef SCHEDULER_H
4#define SCHEDULER_H
5
6#ifdef _MSC_VER
7#pragma warning(disable:4786)
8#endif
9
10#include <map>
11#include <iostream>
12class ScheduledEvent;
13
14
15class GPStime {
16 // Represent absolute time. Units seconds.
17public:
18 GPStime(double t=0):m_t(t){}
19 /* */ operator double()const{return m_t;}
20private:
21 double m_t;
22
23 friend GPStime& operator += (GPStime&, const double& );
24};
25
26inline GPStime& operator += (GPStime& t, const double& dt)
27{
28 t.m_t += dt;
29 return t;
30}
31
32
33class Scheduler : private std::multimap<double, ScheduledEvent*>
34{
35 //create a sequence of call backs to a list of ScheduledEvent
36 // instances, in time order. Delete each after running
37
38public:
40 // ctor
41
43 // dtor, removes all entries still in list
44
45 void schedule(double deltaT, ScheduledEvent* event);
46 // add a scheduled event, to occur deltaT after the present
47 // the instance will be deleted after being run
48
49 void start();
50 // start the scheduler
51
52 void stop();
53 // stop the scheduler
54
55 bool running(){return m_running;}
56 // status
57
58 void clear();
59 // purge pending events
60
61 GPStime elapsed_time()const{return m_time;}
62 // access to the current time
63
64 void setLog(std::ostream& out);
65 // define the log file, start logging to it
66
67 void endLogging();
68 // end logging.
69
70 void printOn(std::ostream& out)const;
71 // make table of pending entries
72
74private:
75 static Scheduler* s_instance;
76 GPStime m_time; // current time
77 bool m_running;
78 std::ostream* m_log;
79};
80#endif
GPStime & operator+=(GPStime &t, const double &dt)
TGraph2DErrors * dt
Definition: McCor.cxx:45
friend GPStime & operator+=(GPStime &, const double &)
void endLogging()
void printOn(std::ostream &out) const
void clear()
void start()
void stop()
static Scheduler * instance()
void setLog(std::ostream &out)
void schedule(double deltaT, ScheduledEvent *event)
int t()
Definition: t.c:1