MasterSceneManager.h 10.1 KB
Newer Older
Nicolas Metts's avatar
Nicolas Metts committed
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
#ifndef _MASTER_SCENE_MANAGER_H_
#define _MASTER_SCENE_MANAGER_H_
/**
 * \ingroup ControllerClient
 */
/**
 * \file  lighting_controller_client/inc/MasterSceneManager.h
 * This file provides definitions for controller client
 */

/******************************************************************************
 * 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 <list>

#include <Manager.h>
#include <ControllerClientDefs.h>

namespace lsf {

class ControllerClient;
/**
 * a callback class that its instance and members are given to the MasterScene to get the methods reply and signals that are coming from the controller service.
 */
class MasterSceneManagerCallback {
  public:
    virtual ~MasterSceneManagerCallback() { }

    /**
     * Response to MasterSceneManager::GetAllMasterSceneIDs
     *
     * @param responseCode        The response code
     * @param masterSceneList    The masterScene ID's
     */
    virtual void GetAllMasterSceneIDsReplyCB(const LSFResponseCode& responseCode, const LSFStringList& masterSceneList) { }

    /**
     * Response to MasterSceneManager::GetMasterSceneName
     *
     * @param responseCode    The response code
     * @param masterSceneID    The masterScene id
     * @param language
     * @param masterSceneName  The masterScene masterSceneName
     */
    virtual void GetMasterSceneNameReplyCB(const LSFResponseCode& responseCode, const LSFString& masterSceneID, const LSFString& language, const LSFString& masterSceneName) { }

    /**
     * Response to MasterSceneManager::SetMasterSceneName
     *
     * @param responseCode    The response code
     * @param masterSceneID    The Lamp masterScene id
     * @param language
     */
    virtual void SetMasterSceneNameReplyCB(const LSFResponseCode& responseCode, const LSFString& masterSceneID, const LSFString& language) { }

    /**
     * A masterScene has had its masterSceneName set
     *
     * @param masterSceneIDs    The masterScene id
     */
    virtual void MasterScenesNameChangedCB(const LSFStringList& masterSceneIDs) { }

    /**
     * Response to MasterSceneManager::CreateMasterScene
     *
     * @param responseCode    The response code
     * @param masterSceneID    The Lamp masterScene id
     * @param masterSceneID The Lamp masterScene
     */
    virtual void CreateMasterSceneReplyCB(const LSFResponseCode& responseCode, const LSFString& masterSceneID) { }

    /**
     *  A masterScene has been created
     *
     *  @param masterSceneIDs   The masterScene id
     */
    virtual void MasterScenesCreatedCB(const LSFStringList& masterSceneIDs) { }

    /**
     * Response to MasterSceneManager::GetMasterScene
     *
     * @param responseCode    The response code
     * @param masterSceneID    The Lamp masterScene id
     * @param masterScene The GroupID
     */
    virtual void GetMasterSceneReplyCB(const LSFResponseCode& responseCode, const LSFString& masterSceneID, const MasterScene& masterScene) { }

    /**
     * Response to MasterSceneManager::DeleteMasterScene
     *
     * @param responseCode    The response code
     * @param masterSceneID    The Lamp masterScene id
     */
    virtual void DeleteMasterSceneReplyCB(const LSFResponseCode& responseCode, const LSFString& masterSceneID) { }

    /**
     *  A masterScene has been deleted
     *
     *  @param masterSceneIDs   The masterScene id
     */
    virtual void MasterScenesDeletedCB(const LSFStringList& masterSceneIDs) { }

    /**
     * Response to MasterSceneManager::UpdateMasterScene
     *
     * @param responseCode    The response code
     * @param masterSceneID    The Lamp masterScene id
     */
    virtual void UpdateMasterSceneReplyCB(const LSFResponseCode& responseCode, const LSFString& masterSceneID) { }

    /**
     * A Lamp masterScene has been updated
     *
     * @param masterSceneIDs    The id of the Lamp masterScene
     */
    virtual void MasterScenesUpdatedCB(const LSFStringList& masterSceneIDs) { }

    /**
     * Response to MasterSceneManager::ApplyMasterScene
     *
     * @param responseCode    The response code
     * @param masterSceneID    The id of the scene masterScene
     */
    virtual void ApplyMasterSceneReplyCB(const LSFResponseCode& responseCode, const LSFString& masterSceneID) { }

    /**
     * A scene masterScene has been applied
     *
     * @param masterSceneIDs    The id of the scene masterScene
     */
    virtual void MasterScenesAppliedCB(const LSFStringList& masterSceneIDs) { }
};

/**
 * Master Scene Manager
 */
class MasterSceneManager : public Manager {

    friend class ControllerClient;

  public:
    /**
     * MasterSceneManager constructor
     */
    MasterSceneManager(ControllerClient& controller, MasterSceneManagerCallback& callback);

    /**
     * Get the IDs of all masterSceneList. \n
     * Response in MasterSceneManagerCallback::GetAllMasterSceneIDsReplyCB
     */
    ControllerClientStatus GetAllMasterSceneIDs(void);

    /**
     * Get the names of the masterScene. \n
     * Response in MasterSceneManagerCallback::GetMasterSceneNameCB
     *
     * @param masterSceneID    The masterScene id
     * @param language
     */
    ControllerClientStatus GetMasterSceneName(const LSFString& masterSceneID, const LSFString& language = LSFString("en"));

    /**
     * Set the masterSceneName of the specified masterScene. \n
     * Response in MasterSceneManagerCallback::SetMasterSceneNameReplyCB
     *
     * @param masterSceneID    The id of the masterScene
     * @param masterSceneName  The Master Scene Name
     * @param language
     */
    ControllerClientStatus SetMasterSceneName(const LSFString& masterSceneID, const LSFString& masterSceneName, const LSFString& language = LSFString("en"));

    /**
     * Create a new Scene masterScene. \n
     * Response in MasterSceneManagerCallback::CreateMasterSceneReplyCB
     *
     */
    ControllerClientStatus CreateMasterScene(const MasterScene& masterScene, const LSFString& masterSceneName, const LSFString& language = LSFString("en"));

    /**
     * Modify a masterScene. \n
     * Change master scene to another master scene. \n
     * Response in MasterSceneManagerCallback::UpdateMasterSceneReplyCB
     *
     * @param masterSceneID    The id of the masterScene to modify
     * @param masterScene
     */
    ControllerClientStatus UpdateMasterScene(const LSFString& masterSceneID, const MasterScene& masterScene);

    /**
     * Get the information about the masterScene. \n
     * Response in MasterSceneManagerCallback::GetMasterSceneReplyCB
     *
     * @param masterSceneID    Group id to get
     */
    ControllerClientStatus GetMasterScene(const LSFString& masterSceneID);

    /**
     * Delete a Lamp masterScene. \n
     * Response in MasterSceneManagerCallback::DeleteMasterSceneReplyCB
     *
     * @param masterSceneID    The id of the masterScene to delete
     */
    ControllerClientStatus DeleteMasterScene(const LSFString& masterSceneID);

    /**
     * Apply a scene masterScene. \n
     * Make the master scene happen. \n
     * Response in MasterSceneManagerCallback::ApplyMasterSceneReplyCB
     *
     * @param masterSceneID    The ID of the scene to apply
     */
    ControllerClientStatus ApplyMasterScene(const LSFString& masterSceneID);

    /**
     * Get the Master Scene Info and Name
     *
     * @param masterSceneID    The ID of the master scene
     * @param language
     */
    ControllerClientStatus GetMasterSceneDataSet(const LSFString& masterSceneID, const LSFString& language = LSFString("en"));

  private:

    // signal handlers
    void MasterScenesNameChanged(LSFStringList& idList) {
        callback.MasterScenesNameChangedCB(idList);
    }

    void MasterScenesCreated(LSFStringList& idList) {
        callback.MasterScenesCreatedCB(idList);
    }

    void MasterScenesDeleted(LSFStringList& idList) {
        callback.MasterScenesDeletedCB(idList);
    }

    void MasterScenesUpdated(LSFStringList& idList) {
        callback.MasterScenesUpdatedCB(idList);
    }

    void MasterScenesApplied(LSFStringList& idList) {
        callback.MasterScenesAppliedCB(idList);
    }

    // method response handlers
    void GetAllMasterSceneIDsReply(LSFResponseCode& responseCode, LSFStringList& idList) {
        callback.GetAllMasterSceneIDsReplyCB(responseCode, idList);
    }

    void GetMasterSceneNameReply(LSFResponseCode& responseCode, LSFString& lsfId, LSFString& language, LSFString& lsfName) {
        callback.GetMasterSceneNameReplyCB(responseCode, lsfId, language, lsfName);
    }

    void ApplyMasterSceneReply(LSFResponseCode& responseCode, LSFString& lsfId) {
        callback.ApplyMasterSceneReplyCB(responseCode, lsfId);
    }

    void SetMasterSceneNameReply(LSFResponseCode& responseCode, LSFString& lsfId, LSFString& language) {
        callback.SetMasterSceneNameReplyCB(responseCode, lsfId, language);
    }

    void CreateMasterSceneReply(LSFResponseCode& responseCode, LSFString& lsfId) {
        callback.CreateMasterSceneReplyCB(responseCode, lsfId);
    }

    void UpdateMasterSceneReply(LSFResponseCode& responseCode, LSFString& lsfId) {
        callback.UpdateMasterSceneReplyCB(responseCode, lsfId);
    }

    void GetMasterSceneReply(ajn::Message& message);

    void DeleteMasterSceneReply(LSFResponseCode& responseCode, LSFString& lsfId) {
        callback.DeleteMasterSceneReplyCB(responseCode, lsfId);
    }

    MasterSceneManagerCallback&   callback;
};


}

#endif