BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
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:
39 Scheduler();
40 // ctor
41
42 ~Scheduler();
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
73 static Scheduler* instance();
74private:
75 static Scheduler* s_instance;
76 GPStime m_time; // current time
77 bool m_running;
78 std::ostream* m_log;
79};
80#endif
TGraph2DErrors * dt
Definition McCor.cxx:45
GPStime & operator+=(GPStime &t, const double &dt)
Definition Scheduler.h:26
TTree * t
Definition binning.cxx:23
friend GPStime & operator+=(GPStime &, const double &)
Definition Scheduler.h:26
GPStime(double t=0)
Definition Scheduler.h:18
void endLogging()
Definition Scheduler.cxx:86
void printOn(std::ostream &out) const
Definition Scheduler.cxx:66
void clear()
Definition Scheduler.cxx:24
void start()
Definition Scheduler.cxx:40
bool running()
Definition Scheduler.h:55
void stop()
Definition Scheduler.cxx:62
static Scheduler * instance()
Definition Scheduler.cxx:9
GPStime elapsed_time() const
Definition Scheduler.h:61
void setLog(std::ostream &out)
Definition Scheduler.cxx:78
void schedule(double deltaT, ScheduledEvent *event)
Definition Scheduler.cxx:35