Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
#ifndef _SCENE_MANAGER_H_
#define _SCENE_MANAGER_H_
/**
* \ingroup ControllerClient
*/
/**
* \file lighting_controller_client/inc/SceneManager.h
* This file provides definitions for scene manager
*/
/******************************************************************************
* Copyright AllSeen Alliance. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************************/
#include <LSFTypes.h>
#include <Manager.h>
#include <LSFResponseCodes.h>
#include <ControllerClientDefs.h>
#include <list>
namespace lsf {
class ControllerClient;
/**
* scene callback class
*/
class SceneManagerCallback {
public:
virtual ~SceneManagerCallback() { }
/**
* Response to SceneManager::GetAllSceneIds.
*
* @param responseCode The response code
* @param sceneIDs The list of scene ID's
*/
virtual void GetAllSceneIDsReplyCB(const LSFResponseCode& responseCode, const LSFStringList& sceneIDs) { }
/**
* Response to SceneManager::GetSceneName.
*
* @param responseCode The response code: \n
* LSF_OK - operation succeeded \n
* LSF_ERR_NOT_FOUND - the scene not found \n
* LSF_ERR_INVALID_ARGS - Language not supported \n
* @param sceneID The id of the scene
* @param language The language of the scene name
* @param sceneName The name of the scene
*/
virtual void GetSceneNameReplyCB(const LSFResponseCode& responseCode, const LSFString& sceneID, const LSFString& language, const LSFString& sceneName) { }
/**
* Response to SceneManager::SetSceneName.
*
* @param responseCode The response code: \n
* LSF_OK - operation succeeded \n
* LSF_ERR_INVALID_ARGS - Language not supported, length exceeds LSF_MAX_NAME_LENGTH \n
* LSF_ERR_EMPTY_NAME - scene name is empty \n
* LSF_ERR_RESOURCES - blob length is longer than MAX_FILE_LEN \n
* @param sceneID The id of the scene whose name was changed
* @param language language of the scene
*/
virtual void SetSceneNameReplyCB(const LSFResponseCode& responseCode, const LSFString& sceneID, const LSFString& language) { }
/**
* This signal is fired any time a scene's name is changed.
*
* @param sceneIDs The id of the scene whose name changed
*/
virtual void ScenesNameChangedCB(const LSFStringList& sceneIDs) { }
/**
* Response to SceneManager::CreateScene.
*
* @param responseCode The response code: \n
* LSF_OK - operation succeeded \n
* LSF_ERR_INVALID_ARGS - Language not supported, scene name is empty, Invalid Scene components specified, ame length exceeds \n
* LSF_ERR_RESOURCES - Could not allocate memory \n
* LSF_ERR_NO_SLOT - No slot for new Scene \n
* @param sceneID The id of the new Scene
*/
virtual void CreateSceneReplyCB(const LSFResponseCode& responseCode, const LSFString& sceneID) { }
/**
* Response to SceneManager::CreateSceneWithSceneElements.
*
* @param responseCode The response code: \n
* LSF_OK - operation succeeded \n
* LSF_ERR_INVALID_ARGS - Language not supported, scene name is empty, Invalid Scene components specified, ame length exceeds \n
* LSF_ERR_RESOURCES - Could not allocate memory \n
* LSF_ERR_NO_SLOT - No slot for new Scene \n
* @param sceneID The id of the new Scene
*/
virtual void CreateSceneWithSceneElementsReplyCB(const LSFResponseCode& responseCode, const LSFString& sceneID) { }
/**
* This signal is fired any time a scene is been created.
*
* @param sceneIDs The id of the new scene
*/
virtual void ScenesCreatedCB(const LSFStringList& sceneIDs) { }
/**
* Response to SceneManager::UpdateScene.
*
* @param responseCode The response code
* @param sceneID The id of the scene that was updated
*/
virtual void UpdateSceneReplyCB(const LSFResponseCode& responseCode, const LSFString& sceneID) { }
/**
* Response to SceneManager::UpdateSceneWithSceneElements.
*
* @param responseCode The response code
* @param sceneID The id of the scene that was updated
*/
virtual void UpdateSceneWithSceneElementsReplyCB(const LSFResponseCode& responseCode, const LSFString& sceneID) { }
/**
* This signal is fired any time a scene has been updated.
*
* @param sceneIDs The id of the updated scene
*/
virtual void ScenesUpdatedCB(const LSFStringList& sceneIDs) { }
/**
* Response to SceneManager::DeleteScene.
*
* @param responseCode The response code: \n
* LSF_OK - operation succeeded \n
* LSF_ERR_NOT_FOUND - can't find scene id \n
* @param sceneID The id of the deleted scene
*/
virtual void DeleteSceneReplyCB(const LSFResponseCode& responseCode, const LSFString& sceneID) { }
/**
* This signal is fired any time a scene has been deleted.
*
* @param sceneIDs The id of the deleted scene
*/
virtual void ScenesDeletedCB(const LSFStringList& sceneIDs) { }
/**
* Response to SceneManager::GetScene.
*
* @param responseCode The response code: \n
* return LSF_OK \n
* return LSF_ERR_NOT_FOUND - scene not found \n
* @param sceneID The id of the scene
* @param data The scene data
*/
virtual void GetSceneReplyCB(const LSFResponseCode& responseCode, const LSFString& sceneID, const Scene& data) { }
/**
* Response to SceneManager::GetSceneWithSceneElements.
*
* @param responseCode The response code: \n
* return LSF_OK \n
* return LSF_ERR_NOT_FOUND - scene not found \n
* @param sceneID The id of the scene
* @param sceneElementIDs The list of scene elements IDs that comprise the scene
*/
virtual void GetSceneWithSceneElementsReplyCB(const LSFResponseCode& responseCode, const LSFString& sceneID, const LSFStringList& sceneElementIDs) { }
/**
* Response to SceneManager::ApplyScene.
*
* @param responseCode The response code \n
* LSF_OK - on success \n
* LSF_ERR_NOT_FOUND - scene id not found in current list of scenes
* @param sceneID The id of the scene
*/
virtual void ApplySceneReplyCB(const LSFResponseCode& responseCode, const LSFString& sceneID) { }
/**
* This signal is fired any time a scene has been applied.
*
* @param sceneIDs The id of the scene
*/
virtual void ScenesAppliedCB(const LSFStringList& sceneIDs) { }
};
/**
* scene management class
*/
class SceneManager : public Manager {
friend class ControllerClient;
public:
/**
* SceneManager CTOR.
* @param controller - a reference to ControllerClient instance
* @param callback - a reference to SceneManagerCallback instance, to get the callback messages
*/
SceneManager(ControllerClient& controller, SceneManagerCallback& callback);
/**
* Get the IDs of all available scenes. \n
* Response comes in SceneManagerCallback::GetAllSceneIDsReplyCB
*/
ControllerClientStatus GetAllSceneIDs(void);
/**
* Get the name of the given Scene. \n
* Response in SceneManagerCallback::GetSceneNameReplyCB
*
* @param sceneID The id of the scene
* @param language The requested language
*/
ControllerClientStatus GetSceneName(const LSFString& sceneID, const LSFString& language = LSFString("en"));
/**
* Set the name of a Scene. \n
* Response in SceneManagerCallback::SetSceneNameReplyCB
*
* @param sceneID The id of the scene to modify
* @param sceneName The new scene name
* @param language The requested language
*/
ControllerClientStatus SetSceneName(const LSFString& sceneID, const LSFString& sceneName, const LSFString& language = LSFString("en"));
/**
* Create a new Scene. \n
* Response in SceneManagerCallback::CreateSceneReplyCB
*
* @param scene The scene data
* @param sceneName The scene name
* @param language The scene language
*/
ControllerClientStatus CreateScene(const Scene& scene, const LSFString& sceneName, const LSFString& language = LSFString("en"));
/**
* Create a new Scene with Scene Elements. \n
* Response in SceneManagerCallback::CreateSceneWithSceneElementsReplyCB
*
* @param sceneElementIDs The list of scene element IDs that comprise the Scene
* @param sceneName The scene name
* @param language The scene language
*/
ControllerClientStatus CreateSceneWithSceneElements(const LSFStringList& sceneElementIDs, const LSFString& sceneName, const LSFString& language = LSFString("en"));
/**
* Modify an existing scene. \n
* Response in SceneManagerCallback::UpdateSceneReplyCB \n
*
* @param sceneID The id of the scene to modify
* @param scene The scene to modify with
*/
ControllerClientStatus UpdateScene(const LSFString& sceneID, const Scene& scene);
/**
* Modify an existing scene with scene elements. \n
* Response in SceneManagerCallback::UpdateSceneWithSceneElementsReplyCB \n
*
* @param sceneID The id of the scene to modify
* @param sceneElementIDs The updated scene elements IDs list
*/
ControllerClientStatus UpdateSceneWithSceneElements(const LSFString& sceneID, const LSFStringList& sceneElementIDs);
/**
* Delete an existing scene. \n
* Response in SceneManagerCallback::DeleteSceneReplyCB
*
* @param sceneID The id of the scene to delete
*/
ControllerClientStatus DeleteScene(const LSFString& sceneID);
/**
* Get the information about the specified scene. \n
* Response in SceneManagerCallback::GetSceneReplyCB
*
* @param sceneID The id of the scene to find
*/
ControllerClientStatus GetScene(const LSFString& sceneID);
/**
* Get the information about the specified scene. \n
* Response in SceneManagerCallback::GetSceneWithSceneElementsReplyCB
*
* @param sceneID The id of the scene to find
*/
ControllerClientStatus GetSceneWithSceneElements(const LSFString& sceneID);
/**
* Apply a scene. \n
* Activate an already created scene. Make it happen. \n
* Response in SceneManagerCallback::ApplySceneReplyCB
*
* @param sceneID The ID of the scene to apply
*/
ControllerClientStatus ApplyScene(const LSFString& sceneID);
/**
* Get the Scene Info and Name. \n
* Combination of GetScene and GetScneneName. Responses are accordingly. \n
*
* @param sceneID The ID of the master scene
* @param language The requested language
*/
ControllerClientStatus GetSceneDataSet(const LSFString& sceneID, const LSFString& language = LSFString("en"));
private:
// Signal handlers:
void ScenesNameChanged(LSFStringList& idList) {
callback.ScenesNameChangedCB(idList);
}
void ScenesCreated(LSFStringList& idList) {
callback.ScenesCreatedCB(idList);
}
void ScenesUpdated(LSFStringList& idList) {
callback.ScenesUpdatedCB(idList);
}
void ScenesDeleted(LSFStringList& idList) {
callback.ScenesDeletedCB(idList);
}
void ScenesApplied(LSFStringList& idList) {
callback.ScenesAppliedCB(idList);
}
// asynch method response handlers
void GetAllSceneIDsReply(LSFResponseCode& responseCode, LSFStringList& idList) {
callback.GetAllSceneIDsReplyCB(responseCode, idList);
}
void GetSceneReply(ajn::Message& message);
void GetSceneWithSceneElementsReply(ajn::Message& message);
void ApplySceneReply(LSFResponseCode& responseCode, LSFString& lsfId) {
callback.ApplySceneReplyCB(responseCode, lsfId);
}
void DeleteSceneReply(LSFResponseCode& responseCode, LSFString& lsfId) {
callback.DeleteSceneReplyCB(responseCode, lsfId);
}
void SetSceneNameReply(LSFResponseCode& responseCode, LSFString& lsfId, LSFString& language) {
callback.SetSceneNameReplyCB(responseCode, lsfId, language);
}
void GetSceneNameReply(LSFResponseCode& responseCode, LSFString& lsfId, LSFString& language, LSFString& lsfName) {
callback.GetSceneNameReplyCB(responseCode, lsfId, language, lsfName);
}
void CreateSceneReply(LSFResponseCode& responseCode, LSFString& lsfId) {
callback.CreateSceneReplyCB(responseCode, lsfId);
}
void CreateSceneWithSceneElementsReply(LSFResponseCode& responseCode, LSFString& lsfId) {
callback.CreateSceneWithSceneElementsReplyCB(responseCode, lsfId);
}
void UpdateSceneReply(LSFResponseCode& responseCode, LSFString& lsfId) {
callback.UpdateSceneReplyCB(responseCode, lsfId);
}
void UpdateSceneWithSceneElementsReply(LSFResponseCode& responseCode, LSFString& lsfId) {
callback.UpdateSceneWithSceneElementsReplyCB(responseCode, lsfId);
}
SceneManagerCallback& callback;
};
}
#endif