00001 #ifndef __COMMAND_H
00002 #define __COMMAND_H
00003
00004 #include <string>
00005 #include <sstream>
00006 #include <vector>
00007 using namespace std;
00008
00009 #include "GlobalConstants.h"
00010
00011 class CommandProcessor;
00012
00013 static const string showCommandString="show";
00014
00015 class Command {
00016 public:
00017 Command();
00018 virtual ~Command() {}
00019 virtual string getCommandString() = 0;
00020 virtual void run(std::ostream& out) = 0;
00021 virtual void getHtmlInterface(std::ostream& out);
00022 string getArg(int index);
00023 void setArg(int index, string value);
00024 void clear();
00025
00026
00027
00028 protected:
00029 virtual void getHelp(std::ostream& out);
00030
00031 void beginUl(std::ostream& out);
00032
00033 void endUl(std::ostream& out);
00034
00035 void preformatting(std::ostream& out);
00036
00037 void setNewlines(bool value);
00038
00039 void postformatting(std::ostream& out);
00040
00041 void beginForm(std::ostream& out);
00042
00043 void beginForm(std::ostream& out, string action, string method);
00044
00045 void endForm(std::ostream& out);
00046
00047 void formInput(std::ostream& out, string type, string name, string value);
00048
00049 void generateHtmlCmd(std::ostream& out, string command, string description);
00050
00051 void generateHtmlCmd(std::ostream& out, string description);
00052
00053 void generateHtmlSubcmd(std::ostream& out, string subcmd, string description);
00054
00055 void generateHtmlSubcmdArg1(std::ostream& out,
00056 string subcmd,
00057 string description,
00058 string buttonString);
00059
00060 void generateHtmlSubcmdArg1(std::ostream& out,
00061 string subcmd,
00062 string description,
00063 string buttonString,
00064 string value);
00065
00066 void generateHtmlSubcmdArg2(std::ostream& out,
00067 string subcmd,
00068 string description1,
00069 string description2,
00070 string buttonString);
00071
00072 void generateHtmlSubcmdArg3(std::ostream& out,
00073 string subcmd,
00074 string description1,
00075 string description2,
00076 string description3,
00077 string buttonString);
00078
00079 void generateHtmlSubcmdArg4(std::ostream& out,
00080 string subcmd,
00081 string description1,
00082 string description2,
00083 string description3,
00084 string description4,
00085 string buttonString);
00086
00087 void generateHtmlCheckbox(std::ostream& out, string description, string value, bool isChecked);
00088
00089 string m_args[MAX_COMMAND_ARGS];
00090 string m_output;
00091 int m_numArgs;
00092 bool m_ul;
00093 bool m_newlines;
00094
00095 };
00096
00097 #endif