diff options
author | Tess Chu <tess@lindenlab.com> | 2007-10-02 22:38:38 +0000 |
---|---|---|
committer | Tess Chu <tess@lindenlab.com> | 2007-10-02 22:38:38 +0000 |
commit | cfd17f3322ec9c8efb120faa23adb83846272193 (patch) | |
tree | eefbf2fefcac737d4050fba10e072fe951cd4381 /indra/newview/llcommandhandler.h | |
parent | 97631054272eeb83155f70fec6a869efc39079e5 (diff) |
svn merge -r 70819:70853 svn+ssh://svn/svn/linden/branches/urldispatcher-for-merge
Diffstat (limited to 'indra/newview/llcommandhandler.h')
-rw-r--r-- | indra/newview/llcommandhandler.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/indra/newview/llcommandhandler.h b/indra/newview/llcommandhandler.h new file mode 100644 index 0000000000..65ce6c633b --- /dev/null +++ b/indra/newview/llcommandhandler.h @@ -0,0 +1,62 @@ +/** + * @file llcommandhandler.h + * @brief Central registry for text-driven "commands", most of + * which manipulate user interface. For example, the command + * "agent (uuid) about" will open the UI for an avatar's profile. + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ +#ifndef LLCOMMANDHANDLER_H +#define LLCOMMANDHANDLER_H + +/* To implement a command "foo" that takes one parameter, + a UUID, do this: + +class LLFooHandler : public LLCommandHandler +{ +public: + // Inform the system you handle commands starting + // with "foo" + LLFooHandler() : LLCommandHandler("foo") { } + + // Your code here + bool handle(const std::vector<std::string>& tokens) + { + if (tokens.size() < 1) return false; + LLUUID id( tokens[0] ); + return doFoo(id); + } +}; + +// Creating the object registers with the dispatcher. +LLFooHandler gFooHandler; +*/ + +class LLCommandHandler +{ +public: + LLCommandHandler(const char* command); + // Automatically registers object to get called when + // command is executed. + + virtual ~LLCommandHandler(); + + virtual bool handle(const std::vector<std::string>& params) = 0; + // Execute the command with a provided (possibly empty) + // list of parameters. + // Return true if you did something, false if the parameters + // are invalid or on error. +}; + + +class LLCommandDispatcher +{ +public: + static bool dispatch(const std::string& cmd, const std::vector<std::string>& params); + // Execute a command registered via the above mechanism, + // passing string parameters. + // Returns true if command was found and executed correctly. +}; + +#endif |