Ticker.h
Go to the documentation of this file.
1 ///
2 /// \file Ticker.h
3 /// \brief Notify subscribers when certain time/event intervals have elapsed
4 /// \version $Id: Ticker.h,v 1.6 2012-11-12 20:48:10 mbaird42 Exp $
5 /// \author messier@indiana.edu
6 ///
7 #ifndef OM_TICKER_H
8 #define OM_TICKER_H
9 #include <climits>
10 #include <ctime>
11 #include <list>
12 namespace om { class TickerSubscriber; }
13 
14 namespace om {
15  class Ticker {
16  public:
17  static Ticker& Instance();
18  void Update(unsigned int run, unsigned int subrun);
19  void Subscribe(TickerSubscriber* s, unsigned int which);
20 
21  private:
22  void PublishRun();
23  void PublishSubrun();
24  void Publish30Sec();
25  void Publish1Min();
26  void Publish5Min();
27  void Publish10Min();
28  void Publish30Min();
29  void PublishHour();
30  void Publish24Hr();
31 
32  private:
33  /// Ticker is a singleton - constructor is private.
34  Ticker();
35 
36  /// Define what an uninitialized run/subrun number looks like
37  static const unsigned int kUninitRun = UINT_MAX;
38 
39  /// Define what an uninitialized time looks like
40  static const int kUninitTime = -1;
41 
42  private:
43  unsigned int fLastRun; ///< Run number of last update
44  unsigned int fLastSubrun; ///< Subrun number of last update
45  int fLast30Sec; ///< Time of last 30 second update
46  int fLast1Min; ///< Time of last 1 minute update
47  int fLast5Min; ///< Time of last 5 minute update
48  int fLast10Min; ///< Time of last 10 minute update
49  int fLast30Min; ///< Time of last 30 minute update
50  int fLastHour; ///< Time of last hour update
51  int fLast24Hr; ///< Time of last 24 hour update
52  std::list<TickerSubscriber*> f30SecSubscribers;
53  std::list<TickerSubscriber*> f1MinSubscribers;
54  std::list<TickerSubscriber*> f5MinSubscribers;
55  std::list<TickerSubscriber*> f10MinSubscribers;
56  std::list<TickerSubscriber*> f30MinSubscribers;
57  std::list<TickerSubscriber*> fHourSubscribers;
58  std::list<TickerSubscriber*> f24HrSubscribers;
59  std::list<TickerSubscriber*> fRunSubscribers;
60  std::list<TickerSubscriber*> fSubrunSubscribers;
61  };
62 }
63 #endif
64 ////////////////////////////////////////////////////////////////////////
static const unsigned int kUninitRun
Define what an uninitialized run/subrun number looks like.
Definition: Ticker.h:37
std::list< TickerSubscriber * > fSubrunSubscribers
Definition: Ticker.h:60
std::list< TickerSubscriber * > fHourSubscribers
Definition: Ticker.h:57
void Publish10Min()
Definition: Ticker.cxx:147
std::list< TickerSubscriber * > f10MinSubscribers
Definition: Ticker.h:55
unsigned int fLastRun
Run number of last update.
Definition: Ticker.h:43
void Publish5Min()
Definition: Ticker.cxx:138
void Update(unsigned int run, unsigned int subrun)
Definition: Ticker.cxx:34
std::list< TickerSubscriber * > f30MinSubscribers
Definition: Ticker.h:56
std::list< TickerSubscriber * > f30SecSubscribers
Definition: Ticker.h:52
static const int kUninitTime
Define what an uninitialized time looks like.
Definition: Ticker.h:40
int fLast30Sec
Time of last 30 second update.
Definition: Ticker.h:45
const XML_Char * s
Definition: expat.h:262
std::list< TickerSubscriber * > fRunSubscribers
Definition: Ticker.h:59
void PublishRun()
Definition: Ticker.cxx:102
void Subscribe(TickerSubscriber *s, unsigned int which)
Definition: Ticker.cxx:183
void Publish1Min()
Definition: Ticker.cxx:129
int fLast1Min
Time of last 1 minute update.
Definition: Ticker.h:46
Ticker()
Ticker is a singleton - constructor is private.
Definition: Ticker.cxx:12
std::list< TickerSubscriber * > f1MinSubscribers
Definition: Ticker.h:53
std::list< TickerSubscriber * > f5MinSubscribers
Definition: Ticker.h:54
Definition: run.py:1
static Ticker & Instance()
Definition: Ticker.cxx:26
int fLast30Min
Time of last 30 minute update.
Definition: Ticker.h:49
void Publish30Min()
Definition: Ticker.cxx:156
unsigned int fLastSubrun
Subrun number of last update.
Definition: Ticker.h:44
void Publish24Hr()
Definition: Ticker.cxx:174
void Publish30Sec()
Definition: Ticker.cxx:120
int fLast5Min
Time of last 5 minute update.
Definition: Ticker.h:47
int fLast10Min
Time of last 10 minute update.
Definition: Ticker.h:48
int fLast24Hr
Time of last 24 hour update.
Definition: Ticker.h:51
void PublishSubrun()
Definition: Ticker.cxx:111
std::list< TickerSubscriber * > f24HrSubscribers
Definition: Ticker.h:58
int fLastHour
Time of last hour update.
Definition: Ticker.h:50
Online Monitoring package header.
void PublishHour()
Definition: Ticker.cxx:165