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