Open Lighting Architecture  Latest Git
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HttpServerActions.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * HttpServerActions.h
17  * The list of actions the Ola Server performs.
18  * Copyright (C) 2005 Simon Newton
19  */
20 
21 #ifndef OLAD_HTTPSERVERACTIONS_H_
22 #define OLAD_HTTPSERVERACTIONS_H_
23 
24 #include <stdint.h>
25 #include <string>
26 #include "ola/ActionQueue.h"
27 #include "ola/client/OlaClient.h"
28 #include "ola/base/Macro.h"
29 
30 namespace ola {
31 
32 /*
33  * The base action
34  */
35 class BaseHttpAction: public Action {
36  public:
37  explicit BaseHttpAction(client::OlaClient *client):
38  Action(),
39  m_client(client),
40  m_failed(false),
41  m_on_done(NULL) {
42  }
43  virtual ~BaseHttpAction() {}
44 
45  bool Failed() const { return m_failed; }
46  void Perform(SingleUseCallback0<void> *on_done);
47  void CallbackComplete(const client::Result &result);
48 
49  protected:
50  client::OlaClient *m_client;
51 
52  void RequestComplete(bool failure);
53  virtual void DoAction() = 0;
54 
55  private:
56  bool m_failed;
57  SingleUseCallback0<void> *m_on_done;
58 
59  DISALLOW_COPY_AND_ASSIGN(BaseHttpAction);
60 };
61 
62 
63 /*
64  * An action that sets the name of a universe
65  */
67  public:
69  unsigned int universe,
70  const std::string &name,
71  bool is_fatal):
72  BaseHttpAction(client),
73  m_universe(universe),
74  m_name(name),
75  m_is_fatal(is_fatal) {
76  }
77 
78  bool IsFatal() const { return m_is_fatal; }
79 
80  protected:
81  void DoAction();
82 
83  private:
84  unsigned int m_universe;
85  std::string m_name;
86  bool m_is_fatal;
87 
88  DISALLOW_COPY_AND_ASSIGN(SetNameAction);
89 };
90 
91 
92 /*
93  * An action that sets the merge mode of a universe
94  */
96  public:
98  unsigned int universe,
99  client::OlaUniverse::merge_mode mode):
100  BaseHttpAction(client),
101  m_universe(universe),
102  m_merge_mode(mode) {
103  }
104 
105  bool IsFatal() const { return false; }
106 
107  protected:
108  void DoAction();
109 
110  private:
111  unsigned int m_universe;
112  client::OlaUniverse::merge_mode m_merge_mode;
113 
114  DISALLOW_COPY_AND_ASSIGN(SetMergeModeAction);
115 };
116 
117 
118 /*
119  * An action that adds or removes a port from a universe.
120  */
122  public:
124  unsigned int device_alias,
125  unsigned int port,
126  client::PortDirection direction,
127  unsigned int universe,
128  client::PatchAction action):
129  BaseHttpAction(client),
130  m_device_alias(device_alias),
131  m_port(port),
132  m_direction(direction),
133  m_universe(universe),
134  m_action(action) {
135  }
136 
137  bool IsFatal() const { return false; }
138 
139  protected:
140  void DoAction();
141 
142  private:
143  unsigned int m_device_alias;
144  unsigned int m_port;
145  client::PortDirection m_direction;
146  unsigned int m_universe;
147  client::PatchAction m_action;
148 
149  DISALLOW_COPY_AND_ASSIGN(PatchPortAction);
150 };
151 
152 
153 /*
154  * An action that sets a port priority to inherit mode.
155  */
157  public:
159  unsigned int device_alias,
160  unsigned int port,
161  client::PortDirection direction):
162  BaseHttpAction(client),
163  m_device_alias(device_alias),
164  m_port(port),
165  m_direction(direction) {
166  }
167 
168  bool IsFatal() const { return false; }
169 
170  protected:
171  void DoAction();
172 
173  private:
174  unsigned int m_device_alias;
175  unsigned int m_port;
176  client::PortDirection m_direction;
177 
178  DISALLOW_COPY_AND_ASSIGN(PortPriorityInheritAction);
179 };
180 
181 
182 /*
183  * An action that sets a port priority to override mode.
184  */
186  public:
188  unsigned int device_alias,
189  unsigned int port,
190  client::PortDirection direction,
191  uint8_t override_value):
192  BaseHttpAction(client),
193  m_device_alias(device_alias),
194  m_port(port),
195  m_direction(direction),
196  m_override_value(override_value) {
197  }
198 
199  bool IsFatal() const { return false; }
200 
201  protected:
202  void DoAction();
203 
204  private:
205  unsigned int m_device_alias;
206  unsigned int m_port;
207  client::PortDirection m_direction;
208  uint8_t m_override_value;
209 
210  DISALLOW_COPY_AND_ASSIGN(PortPriorityStaticAction);
211 };
212 } // namespace ola
213 #endif // OLAD_HTTPSERVERACTIONS_H_
A 0 arg, single use callback that returns void.
Definition: Callback.h:157
PortDirection
The port direction.
Definition: ClientArgs.h:54
Definition: HttpServerActions.h:185
PatchAction
The patch action, used with OlaClient::Patch()
Definition: ClientArgs.h:38
The callback based C++ client for OLA.
Definition: OlaClient.h:45
Definition: HttpServerActions.h:156
Definition: HttpServerActions.h:35
Definition: HttpServerActions.h:95
Indicates the result of a OLA API call.
Definition: Result.h:52
Helper macros.
Definition: HttpServerActions.h:66
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: HttpServerActions.h:121
Definition: ActionQueue.h:36