Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

LiveBroadcastTableCommand.cpp

Go to the documentation of this file.
00001 #ifdef TEST
00002 #include "headers.h"
00003 
00004 const static string liveBroadcastTableCommandString = "lbt";
00005 const static string newCommandString = "new";
00006 const static string queryCommandString = "hasid";
00007 const static string deleteCommandString = "delete";
00008 const static string addCommandString = "add";
00009 const static string showAppCommandString = "showApp";
00010 
00011 LiveBroadcastTableCommand::LiveBroadcastTableCommand() : Command() {
00012     m_liveBroadcastTable = NULL;
00013 }
00014 
00015 
00016 void
00017 LiveBroadcastTableCommand::getHtmlInterface(std::ostream& s) {
00018     s << "<h2>Live Broadcast Table</h2>";
00019     beginUl(s);
00020     generateHtmlSubcmd(s, showAppCommandString, "show the Peekabooty live broadcast table");
00021     generateHtmlSubcmd(s, showCommandString, "show test live broadcast table");
00022     generateHtmlSubcmd(s, newCommandString, "Create test Live Broadcast Table");
00023     generateHtmlSubcmd(s, deleteCommandString, "Delete test Live Broadcast Table");
00024     generateHtmlSubcmdArg1(s, addCommandString, "Add an ID to test LBT: ", "Add");
00025     generateHtmlSubcmdArg1(s, queryCommandString, "Query for ID in test LBT: ", "Query");
00026     endUl(s);
00027 }
00028 
00029 
00030 void 
00031 LiveBroadcastTableCommand::getHelp(std::ostream& s) {
00032     s << getCommandString() << "\n"
00033         << "  " << showCommandString << "\n"
00034         << "  " << newCommandString << "\n"
00035         << "  " << deleteCommandString << "\n"
00036         << "  " << addCommandString << "\n"
00037         << "  " << queryCommandString << "\n";
00038 }
00039 
00040 
00041 void
00042 LiveBroadcastTableCommand::run(std::ostream& s) {
00043     if (m_args[1].empty()) {
00044         getHelp(s);
00045         return;
00046     }
00047     if (m_args[1] == showAppCommandString) {
00048         s << *(GlobalObjects::instance()->getNetworkLayer()->getLiveBroadcastTable());
00049     }
00050     if (m_args[1] == showCommandString) {
00051         if (m_liveBroadcastTable != NULL) {
00052             s << *m_liveBroadcastTable;
00053             return;
00054         }
00055     }
00056     else if (m_args[1] == newCommandString) {
00057         m_liveBroadcastTable = new LiveBroadcastTable();
00058     }
00059     else if (m_args[1] == deleteCommandString) {
00060         delete m_liveBroadcastTable;
00061         m_liveBroadcastTable = NULL;
00062     }
00063     else if (m_args[1] == addCommandString) {
00064         if (m_liveBroadcastTable != NULL) {
00065             m_liveBroadcastTable->addId(atoi(m_args[2].c_str()), NULL);
00066         }
00067     }
00068     else if (m_args[1] == queryCommandString) {
00069         if (m_liveBroadcastTable != NULL) {
00070             s << (m_liveBroadcastTable->hasId(atoi(m_args[2].c_str()), NULL)?"true":"false") << "\n";
00071         }
00072     }
00073     if (m_liveBroadcastTable != NULL) {
00074         s << *m_liveBroadcastTable;
00075     }
00076 }
00077 
00078 
00079 
00080 string
00081 LiveBroadcastTableCommand::getCommandString() {
00082     return liveBroadcastTableCommandString;
00083 }
00084 
00085 #endif
00086 
00087 

Generated at Thu Jul 11 13:31:50 2002 for Peekabooty by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001