diff options
author | Jacek Antonelli | 2008-08-15 23:45:11 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:11 -0500 |
commit | 215f423cbe18fe9ca14a26caef918d303bad28ff (patch) | |
tree | 0743442b286216cc8e19aa487c26f4e9345ffd64 /linden/indra/newview/llcommandhandler.h | |
parent | Second Life viewer sources 1.18.3.5-RC (diff) | |
download | meta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.zip meta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.tar.gz meta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.tar.bz2 meta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.tar.xz |
Second Life viewer sources 1.18.4.0-RC
Diffstat (limited to 'linden/indra/newview/llcommandhandler.h')
-rw-r--r-- | linden/indra/newview/llcommandhandler.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/linden/indra/newview/llcommandhandler.h b/linden/indra/newview/llcommandhandler.h new file mode 100644 index 0000000..50928e2 --- /dev/null +++ b/linden/indra/newview/llcommandhandler.h | |||
@@ -0,0 +1,85 @@ | |||
1 | /** | ||
2 | * @file llcommandhandler.h | ||
3 | * @brief Central registry for text-driven "commands", most of | ||
4 | * which manipulate user interface. For example, the command | ||
5 | * "agent (uuid) about" will open the UI for an avatar's profile. | ||
6 | * | ||
7 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
8 | * | ||
9 | * Copyright (c) 2007, Linden Research, Inc. | ||
10 | * | ||
11 | * Second Life Viewer Source Code | ||
12 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
13 | * to you under the terms of the GNU General Public License, version 2.0 | ||
14 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
15 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
16 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
18 | * | ||
19 | * There are special exceptions to the terms and conditions of the GPL as | ||
20 | * it is applied to this Source Code. View the full text of the exception | ||
21 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
22 | * online at http://secondlife.com/developers/opensource/flossexception | ||
23 | * | ||
24 | * By copying, modifying or distributing this software, you acknowledge | ||
25 | * that you have read and understood your obligations described above, | ||
26 | * and agree to abide by those obligations. | ||
27 | * | ||
28 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
29 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
30 | * COMPLETENESS OR PERFORMANCE. | ||
31 | * $/LicenseInfo$ | ||
32 | */ | ||
33 | #ifndef LLCOMMANDHANDLER_H | ||
34 | #define LLCOMMANDHANDLER_H | ||
35 | |||
36 | /* To implement a command "foo" that takes one parameter, | ||
37 | a UUID, do this: | ||
38 | |||
39 | class LLFooHandler : public LLCommandHandler | ||
40 | { | ||
41 | public: | ||
42 | // Inform the system you handle commands starting | ||
43 | // with "foo" | ||
44 | LLFooHandler() : LLCommandHandler("foo") { } | ||
45 | |||
46 | // Your code here | ||
47 | bool handle(const std::vector<std::string>& tokens) | ||
48 | { | ||
49 | if (tokens.size() < 1) return false; | ||
50 | LLUUID id( tokens[0] ); | ||
51 | return doFoo(id); | ||
52 | } | ||
53 | }; | ||
54 | |||
55 | // Creating the object registers with the dispatcher. | ||
56 | LLFooHandler gFooHandler; | ||
57 | */ | ||
58 | |||
59 | class LLCommandHandler | ||
60 | { | ||
61 | public: | ||
62 | LLCommandHandler(const char* command); | ||
63 | // Automatically registers object to get called when | ||
64 | // command is executed. | ||
65 | |||
66 | virtual ~LLCommandHandler(); | ||
67 | |||
68 | virtual bool handle(const std::vector<std::string>& params) = 0; | ||
69 | // Execute the command with a provided (possibly empty) | ||
70 | // list of parameters. | ||
71 | // Return true if you did something, false if the parameters | ||
72 | // are invalid or on error. | ||
73 | }; | ||
74 | |||
75 | |||
76 | class LLCommandDispatcher | ||
77 | { | ||
78 | public: | ||
79 | static bool dispatch(const std::string& cmd, const std::vector<std::string>& params); | ||
80 | // Execute a command registered via the above mechanism, | ||
81 | // passing string parameters. | ||
82 | // Returns true if command was found and executed correctly. | ||
83 | }; | ||
84 | |||
85 | #endif | ||