/** * * Copyright (c) 2009-2020, Kitty Barnett * * The source code in this file is provided to you under the terms of the * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt * * By copying, modifying or distributing this software, you acknowledge that * you have read and understood your obligations described above, and agree to * abide by those obligations. * */ #pragma once #include "llenvironment.h" #include "rlvcommon.h" // ============================================================================ // RlvEnvironment - viewer-side scripted environment changes // class RlvEnvironment : public RlvExtCommandHandler { public: RlvEnvironment(); ~RlvEnvironment() override; bool onReplyCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) override; bool onForceCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) override; protected: static LLEnvironment::EnvSelection_t getTargetEnvironment(); static LLSettingsSky::ptr_t getTargetSky(bool forSetCmd = false); typedef std::map> handler_map_t; typedef std::map> legacy_handler_map_t; static bool onHandleCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet, const std::string& strCmdPrefix, const handler_map_t& fnLookup, const legacy_handler_map_t& legacyFnLookup); /* * Command registration */ protected: void registerGetEnvFn(const std::string& strFnName, const std::function& getFn); template void registerSetEnvFn(const std::string& strFnName, const std::function& setFn); template void registerSkyFn(const std::string& strFnName, const std::function& getFn, const std::function& setFn); template void registerLegacySkyFn(const std::string& strFnName, const std::function& getFn, const std::function& setFn); // Command handling helpers template std::string handleGetFn(const std::function& fn); template ERlvCmdRet handleSetFn(const std::string& strRlvOption, const std::function& fn); template std::string handleLegacyGetFn(const std::function& getFn, U32 idxComponent); template ERlvCmdRet handleLegacySetFn(float optionValue, T value, const std::function& setFn, U32 idxComponent); /* * Member variables */ protected: handler_map_t m_GetFnLookup; handler_map_t m_SetFnLookup; legacy_handler_map_t m_LegacyGetFnLookup; legacy_handler_map_t m_LegacySetFnLookup; }; // ============================================================================