phaser-server  0.0.3
notify.h
Go to the documentation of this file.
1 #ifndef NOTIFY_H
2 #define NOTIFY_H
8 #include <JSON.h>
9 class PhaseJob;
10 
19 { public:
21  JsonNotice(const char *value) : m_notifyValue(value) {}
22  std::string operator()(void);
23 
24  protected:
25  virtual void Create(JSONObject &) = 0;
26 
27  private:
28  const char *m_notifyValue;
29 };
30 
31 
36 class StatusNotice : public JsonNotice
37 { public:
39  StatusNotice(const std::string &message, bool alert) : JsonNotice("status"),
40  m_msg(message), m_alert(alert) {}
41 
42  protected:
43  virtual void Create(JSONObject &) override;
44 
45  private:
46  const std::string &m_msg;
47  const bool m_alert;
48 };
49 
50 
53 class JobNotice : public JsonNotice
54 { protected:
56  JobNotice(const char *value, const PhaseJob *job) : JsonNotice(value),
57  m_job(job) {}
58  void AddDate(JSONObject &, const char *, time_t);
59 
60  protected:
61  const PhaseJob *m_job;
62 };
63 
64 
69 class PauseNotice : public JobNotice
70 { public:
73  PauseNotice(const PhaseJob *job) : JobNotice("paused", job) {}
74 
75  protected:
76  virtual void Create(JSONObject &) override;
77 };
78 
79 
84 class LoopNotice : public JobNotice
85 { public:
87  LoopNotice(const PhaseJob *job) : JobNotice("loop", job) {}
88 
89  protected:
90  virtual void Create(JSONObject &) override;
91 };
92 
93 
98 class CavityNotice : public JobNotice
99 { public:
102  CavityNotice(const PhaseJob *job) : JobNotice("cavity", job) {}
103 
104  protected:
105  virtual void Create(JSONObject &) override;
106 };
107 
108 
113 class ProgressNotice : public JobNotice
114 { public:
117  ProgressNotice(const PhaseJob *job) : JobNotice("progress", job) {}
118 
119  protected:
120  virtual void Create(JSONObject &) override;
121 };
122 
123 
128 class JobStateNotice : public JobNotice
129 { public:
132  JobStateNotice(const PhaseJob *job) : JobNotice("job", job) {}
133 
134  protected:
135  virtual void Create(JSONObject &) override;
136 };
137 
138 #endif
Job 'current cavity' notice.
Definition: notify.h:99
virtual void Create(JSONObject &) override
Add job 'current cavity' information as "name" and "start".
Definition: notify.cpp:79
CavityNotice(const PhaseJob *job)
Definition: notify.h:102
Abstract RF phasing job related notice.
Definition: notify.h:54
void AddDate(JSONObject &, const char *, time_t)
Add date information to the passed JSON object.
Definition: notify.cpp:46
JobNotice(const char *value, const PhaseJob *job)
Initialize value of 'notification' tag and the RF phasing job.
Definition: notify.h:56
const PhaseJob * m_job
Job whose status is to be reported.
Definition: notify.h:61
Notify the state of the RF phasing job.
Definition: notify.h:129
virtual void Create(JSONObject &) override
Add job state information.
Definition: notify.cpp:112
JobStateNotice(const PhaseJob *job)
Definition: notify.h:132
Abstract base for all notifications.
Definition: notify.h:19
std::string operator()(void)
Get the JSON encoded response string.
Definition: notify.cpp:14
JsonNotice(const char *value)
Initialize the value of the 'notification' tag.
Definition: notify.h:21
Job iteration notice.
Definition: notify.h:85
virtual void Create(JSONObject &) override
Add job iteration as "count".
Definition: notify.cpp:68
LoopNotice(const PhaseJob *job)
Construct a 'loop' notification.
Definition: notify.h:87
Job pause/resume notice.
Definition: notify.h:70
PauseNotice(const PhaseJob *job)
Definition: notify.h:73
virtual void Create(JSONObject &) override
Add job pause state information as "paused".
Definition: notify.cpp:57
A job for processing RF cavities.
Definition: phaseJob.h:17
Job cavity progress notice.
Definition: notify.h:114
ProgressNotice(const PhaseJob *job)
Definition: notify.h:117
virtual void Create(JSONObject &) override
Add job cavity progress as "value".
Definition: notify.cpp:96
RF phasing Job status message.
Definition: notify.h:37
StatusNotice(const std::string &message, bool alert)
Construct a status notification with a message (can be null).
Definition: notify.h:39
virtual void Create(JSONObject &) override
Add the associated message (or null) as 'message'.
Definition: notify.cpp:34