StaticEffectManager.h 10.8 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
#ifndef _STATIC_EFFECT_MANAGER_H_
#define _STATIC_EFFECT_MANAGER_H_
/**
 * \ingroup ControllerClient
 */
/**
 * \file lighting_controller_client/inc/StaticEffectManager.h
 * This file provides definitions for staticEffect 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 <ControllerClientDefs.h>

#include <list>
#include <LSFResponseCodes.h>

namespace lsf {

class ControllerClient;

/**
 * A callback class which object delivered to the StaticEffectManager and its object and methods delivered as a handle to get method replies and signals related to presence of the lamps.
 */
class StaticEffectManagerCallback {
  public:
    /**
     * Destructor
     */
    virtual ~StaticEffectManagerCallback() { }

    /**
     * Response to StaticEffectManager::GetStaticEffect. \n
     * response code LSF_OK on success. \n
     *      LSF_ERR_NOT_FOUND - static effect with requested id is not found. \n
     * @param responseCode          The return code
     * @param staticEffectID    The id of the StaticEffect
     * @param staticEffect      The static effect information
     *
     */
    virtual void GetStaticEffectReplyCB(const LSFResponseCode& responseCode, const LSFString& staticEffectID, const StaticEffect& staticEffect) { }

    /**
     * Response to StaticEffectManager::GetAllStaticEffectIDs. \n
     * response code LSF_OK on success. \n
     * @param responseCode          The return code
     * @param staticEffectIDs   A list of LSFString's
     */
    virtual void GetAllStaticEffectIDsReplyCB(const LSFResponseCode& responseCode, const LSFStringList& staticEffectIDs) { }

    /**
     * Response to StaticEffectManager::GetStaticEffectName. \n
     * Response code LSF_OK on success. \n
     * @param responseCode    The return code
     * @param staticEffectID    The id of the StaticEffect
     * @param language
     * @param staticEffectName  The name of the StaticEffect
     */
    virtual void GetStaticEffectNameReplyCB(const LSFResponseCode& responseCode, const LSFString& staticEffectID, const LSFString& language, const LSFString& staticEffectName) { }

    /**
     * Response to StaticEffectManager::SetStaticEffectName. \n
     * response code LSF_OK on success. \n
     *      LSF_ERR_INVALID_ARGS - language not supported, name is too long. \n
     *      LSF_ERR_EMPTY_NAME - staticEffect name is empty. \n
     *      LSF_ERR_RESOURCES - blob is too big. \n
     * @param responseCode    The return code
     * @param staticEffectID    The id of the StaticEffect
     * @param language
     */
    virtual void SetStaticEffectNameReplyCB(const LSFResponseCode& responseCode, const LSFString& staticEffectID, const LSFString& language) { }

    /**
     * A StaticEffect has been renamed
     *
     * @param staticEffectIDs    The id of the StaticEffect
     */
    virtual void StaticEffectsNameChangedCB(const LSFStringList& staticEffectIDs) { }

    /**
     * Response to StaticEffectManager::CreateStaticEffect. \n
     * response code LSF_OK on success. \n
     *      LSF_ERR_INVALID_ARGS - language not supported, name is too long. \n
     *      LSF_ERR_EMPTY_NAME - staticEffect name is empty. \n
     *      LSF_ERR_RESOURCES - blob is too big. \n
     * @param responseCode    The return code
     * @param staticEffectID    The id of the new StaticEffect
     */
    virtual void CreateStaticEffectReplyCB(const LSFResponseCode& responseCode, const LSFString& staticEffectID) { }

    /**
     * A StaticEffect has been created
     *
     * @param staticEffectIDs    The id of the StaticEffect
     */
    virtual void StaticEffectsCreatedCB(const LSFStringList& staticEffectIDs) { }

    /**
     * Response to StaticEffectManager::UpdateStaticEffect. \n
     * response code LSF_OK on success. \n
     *      LSF_ERR_INVALID_ARGS - language not supported, name is too long. \n
     *      LSF_ERR_RESOURCES - blob is too big. \n
     * @param responseCode    The return code
     * @param staticEffectID    The id of the new StaticEffect
     */
    virtual void UpdateStaticEffectReplyCB(const LSFResponseCode& responseCode, const LSFString& staticEffectID) { }

    /**
     * A StaticEffect has been updated
     *
     * @param staticEffectIDs    The id of the StaticEffect
     */
    virtual void StaticEffectsUpdatedCB(const LSFStringList& staticEffectIDs) { }

    /**
     * Response to StaticEffectManager::DeleteStaticEffect. \n
     * response code LSF_OK on success. \n
     *      LSF_ERR_NOT_FOUND - static effect with requested id is not found. \n
     * @param responseCode    The return code
     * @param staticEffectID    The id of the StaticEffect
     */
    virtual void DeleteStaticEffectReplyCB(const LSFResponseCode& responseCode, const LSFString& staticEffectID) { }

    /**
     * A StaticEffect has been deleted
     *
     * @param staticEffectIDs    The id of the StaticEffect
     */
    virtual void StaticEffectsDeletedCB(const LSFStringList& staticEffectIDs) { }
};

/**
 * a class manage the status of the lamps
 */
class StaticEffectManager : public Manager {

    friend class ControllerClient;

  public:
    /**
     * class constructor
     */
    StaticEffectManager(ControllerClient& controller, StaticEffectManagerCallback& callback);

    /**
     * Get all static effect ids. \n
     * Return asynchronous all static effect ids which are not the default lamp state. \n
     * Response in StaticEffectManagerCallback::GetAllStaticEffectIDsReplyCB. \n
     * @return CONTROLLER_CLIENT_OK on success to send the request. \n
     */
    ControllerClientStatus GetAllStaticEffectIDs(void);

    /**
     * Get existing static effect. \n
     * Response in StaticEffectManagerCallback::GetStaticEffectReplyCB. \n
     * @param staticEffectID type LSFString which is static effect id. \n
     * Return asynchronously the static effect response code, unique id and requested lamp state \n
     * response code LSF_OK on success. \n
     *      LSF_ERR_NOT_FOUND - static effect with requested id is not found. \n
     */
    ControllerClientStatus GetStaticEffect(const LSFString& staticEffectID);

    /**
     * Get the name of a StaticEffect. \n
     * Response in StaticEffectManagerCallback::GetStaticEffectNameReplyCB. \n
     * Return asynchronously the static effect name, id, language and response code. \n
     *
     * @param staticEffectID    The id of the StaticEffect
     * @param language
     */
    ControllerClientStatus GetStaticEffectName(const LSFString& staticEffectID, const LSFString& language = LSFString("en"));

    /**
     * Set the name of a StaticEffect. \n
     * Return asynchronously the static effect new name, id, language and response code. \n
     * Response in StaticEffectManagerCallback::SetStaticEffectNameReplyCB
     *
     * @param staticEffectID    The id of the StaticEffect
     * @param staticEffectName  The new name of the StaticEffect
     * @param language
     */
    ControllerClientStatus SetStaticEffectName(const LSFString& staticEffectID, const LSFString& staticEffectName, const LSFString& language = LSFString("en"));

    /**
     * Create a new staticEffect. \n
     * Response in StaticEffectManagerCallback::CreateStaticEffectReplyCB. \n
     * Return asynchronously the static effect response code and auto generated unique id. \n
     *
     * @param staticEffect The new static effect information
     * @param staticEffectName
     * @param language
     */
    ControllerClientStatus CreateStaticEffect(const StaticEffect& staticEffect, const LSFString& staticEffectName, const LSFString& language = LSFString("en"));

    /**
     * Update an existing StaticEffect. \n
     * Response in StaticEffectManagerCallback::UpdateStaticEffectReplyCB. \n
     * Return asynchronously the static effect response code and unique id. \n
     *
     * @param staticEffectID    The id of the StaticEffect
     * @param staticEffect      The new static effect information
     */
    ControllerClientStatus UpdateStaticEffect(const LSFString& staticEffectID, const StaticEffect& staticEffect);

    /**
     * Delete a staticEffect. \n
     * Return asynchronously the static effect response code and unique id. \n
     * Response in StaticEffectManagerCallback::DeleteStaticEffectReplyCB. \n
     *
     * @param staticEffectID    The id of the StaticEffect to delete
     */
    ControllerClientStatus DeleteStaticEffect(const LSFString& staticEffectID);

  private:

    // signal handlers
    void StaticEffectsNameChanged(LSFStringList& idList) {
        callback.StaticEffectsNameChangedCB(idList);
    }

    void StaticEffectsCreated(LSFStringList& idList) {
        callback.StaticEffectsCreatedCB(idList);
    }

    void StaticEffectsUpdated(LSFStringList& idList) {
        callback.StaticEffectsUpdatedCB(idList);
    }

    void StaticEffectsDeleted(LSFStringList& idList) {
        callback.StaticEffectsDeletedCB(idList);
    }

    // method reply handlers
    void GetAllStaticEffectIDsReply(LSFResponseCode& responseCode, LSFStringList& idList) {
        callback.GetAllStaticEffectIDsReplyCB(responseCode, idList);
    }

    void GetStaticEffectReply(ajn::Message& message);

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

    void SetStaticEffectNameReply(LSFResponseCode& responseCode, LSFString& lsfId, LSFString& language) {
        callback.SetStaticEffectNameReplyCB(responseCode, lsfId, language);
    }

    void CreateStaticEffectReply(LSFResponseCode& responseCode, LSFString& lsfId) {
        callback.CreateStaticEffectReplyCB(responseCode, lsfId);
    }

    void UpdateStaticEffectReply(LSFResponseCode& responseCode, LSFString& lsfId) {
        callback.UpdateStaticEffectReplyCB(responseCode, lsfId);
    }

    void DeleteStaticEffectReply(LSFResponseCode& responseCode, LSFString& lsfId) {
        callback.DeleteStaticEffectReplyCB(responseCode, lsfId);
    }

    StaticEffectManagerCallback& callback;
};

}

#endif