summaryrefslogtreecommitdiff
path: root/indra/llcommon/commoncontrol.h
blob: 13aa983a9904b632b8133e9eaec8ebd83745fe05 (plain)
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
/**
 * @file   commoncontrol.h
 * @author Nat Goodspeed
 * @date   2022-06-08
 * @brief  Access LLViewerControl LLEventAPI, if process has one.
 *
 * $LicenseInfo:firstyear=2022&license=viewerlgpl$
 * Copyright (c) 2022, Linden Research, Inc.
 * $/LicenseInfo$
 */

#if ! defined(LL_COMMONCONTROL_H)
#define LL_COMMONCONTROL_H

#include <vector>
#include "llexception.h"
#include "llsd.h"

namespace LL
{
    class CommonControl
    {
    public:
        struct Error: public LLException
        {
            Error(const std::string& what): LLException(what) {}
        };

        /// Exception thrown if there's no LLViewerControl LLEventAPI
        struct NoListener: public Error
        {
            NoListener(const std::string& what): Error(what) {}
        };

        struct ParamError: public Error
        {
            ParamError(const std::string& what): Error(what) {}
        };

        /// set control group.key to defined default value
        static
        LLSD set_default(const std::string& group, const std::string& key);

        /// set control group.key to specified value
        static
        LLSD set(const std::string& group, const std::string& key, const LLSD& value);

        /// toggle boolean control group.key
        static
        LLSD toggle(const std::string& group, const std::string& key);

        /// get the definition for control group.key, (! isDefined()) if bad
        /// ["name"], ["type"], ["value"], ["comment"]
        static
        LLSD get_def(const std::string& group, const std::string& key);

        /// get the value of control group.key
        static
        LLSD get(const std::string& group, const std::string& key);

        /// get defined groups
        static
        std::vector<std::string> get_groups();

        /// get definitions for all variables in group
        static
        LLSD get_vars(const std::string& group);

    private:
        static
        LLSD access(const LLSD& params);
    };
} // namespace LL

#endif /* ! defined(LL_COMMONCONTROL_H) */