QtGuiCallBacks.h

00001 #ifndef QTGUI_QTGUICALLBACKS_H
00002 #define QTGUI_QTGUICALLBACKS_H
00003 
00004 /*
00005  * RebeccaAIML, Artificial Intelligence Markup Language 
00006  * C++ api and engine.
00007  *
00008  * Copyright (C) 2005,2006,2007 Frank Hassanabad
00009  *
00010  * This file is part of RebeccaAIML.
00011  *
00012  * RebeccaAIML is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 3 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * RebeccaAIML is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00024  */
00025 
00026 //rebecca includes
00027 #include <rebecca/CallBacks.h>
00028 #include <rebecca/StringPimpl.h>
00029 //std includes
00030 #include <iostream>
00031 
00032 //Qt includes
00033 #include <QTextEdit>
00034 #include <QScrollBar>
00035 #include <QObject>
00036 
00037 namespace qtgui
00038 {
00039 
00040 using namespace rebecca;
00041 using namespace std;
00042 
00056 class QtGuiCallBacks : public QObject, public CallBacks
00057 {
00058     Q_OBJECT
00059 
00060     public:
00061         
00080         void storeGossip(const StringPimpl &gossip,
00081                          const StringPimpl &userId,
00082                          const StringPimpl &botId,
00083                          const StringPimpl &endUserId) 
00084         { 
00085             QString output;
00086             output += "[Gossip: ";
00087             output += gossip.c_str();
00088             output += " ]";
00089             emit addText(output);
00090         }
00091 
00109         void categoryLoaded(const StringPimpl &userId,
00110                             const StringPimpl &botId,
00111                             const StringPimpl &endUserId)
00112         {
00113             static int i = 0;
00114             const int numberOfCategories = 5000;
00115             
00116             /*
00117              * Clever way to say if "i" is a multiple 
00118              * of 5000 then print out the number of 
00119              * categories loaded so far.
00120              */
00121             if(++i % numberOfCategories == 0)
00122             {
00123                 QString num;
00124                 num.setNum(i);
00125                 QString output;
00126                 output += "[";
00127                 output += num;
00128                 output += " categories loaded]";
00129                 emit addText(output);
00130             }
00131         }
00132 
00144         void filePreLoad(const StringPimpl &fileName,
00145                          const StringPimpl &userId,
00146                          const StringPimpl &botId,
00147                          const StringPimpl &endUserId)
00148         {
00149             QString output;
00150             output += "[Loading      ";
00151             output += fileName.c_str();
00152             output += "]";
00153             emit addText(output);
00154         }
00155         
00167         void filePostLoad(const StringPimpl &fileName,
00168                           const StringPimpl &userId,
00169                           const StringPimpl &botId,
00170                           const StringPimpl &endUserId)
00171         {
00172             QString output;
00173             output += "[Done loading ";
00174             output += fileName.c_str();
00175             output += "]";
00176             emit addText(output);
00177         }
00178 
00196         void symbolicReduction(const StringPimpl &symbol,
00197                                const StringPimpl &userId,
00198                                const StringPimpl &botId,
00199                                const StringPimpl &endUserId)
00200         {
00201             QString output;
00202             output += "Symbolic reduction: ";
00203             output += symbol.c_str();
00204             emit addText(output);
00205         }
00206 
00221         void infiniteSymbolicReduction(const StringPimpl &userId,
00222                                        const StringPimpl &botId,
00223                                        const StringPimpl &endUserId)
00224         {
00225             emit addText("[Infinite Symbolic reduction detected]");
00226         }
00227         
00242         virtual void XMLParseError(const StringPimpl &message,
00243                                    const StringPimpl &userId,
00244                                    const StringPimpl &botId,
00245                                    const StringPimpl &endUserId)
00246         { 
00247             emit addText(message.c_str());
00248         } 
00249 
00264         virtual void XMLParseWarning(const StringPimpl &message,
00265                                      const StringPimpl &userId,
00266                                      const StringPimpl &botId,
00267                                      const StringPimpl &endUserId)
00268         { 
00269             emit addText(message.c_str());
00270         } 
00271 
00286         virtual void XMLParseFatalError(const StringPimpl &message,
00287                                         const StringPimpl &userId,
00288                                         const StringPimpl &botId,
00289                                         const StringPimpl &endUserId)
00290         { 
00291             emit addText(message.c_str());
00292         } 
00293         
00306         virtual void thatStarTagSizeExceeded(const StringPimpl &userId,
00307                                              const StringPimpl &botId,
00308                                              const StringPimpl &endUserId) 
00309         { 
00310             emit addText("[Warning thatStar Tag Size Exceeded]");
00311         }
00312         
00325         virtual void topicStarTagSizeExceeded(const StringPimpl &userId,
00326                                               const StringPimpl &botId,
00327                                               const StringPimpl &endUserId) 
00328         { 
00329             emit addText("[Warning topicStar Tag Size Exceeded]");
00330         }
00331 
00344         virtual void starTagSizeExceeded(const StringPimpl &userId,
00345                                          const StringPimpl &botId,
00346                                          const StringPimpl &endUserId)
00347         { 
00348             emit addText("[Warning star Tag Size Exceeded]");
00349         }
00350 
00364         virtual void inputTagNumericConversionError(const StringPimpl &message,
00365                                                     const StringPimpl &userId,
00366                                                     const StringPimpl &botId,
00367                                                     const StringPimpl &endUserId)
00368         { 
00369             QString output("inputTagNuermicConversionError:");
00370             output += message.c_str();
00371             emit addText(message.c_str());
00372         }
00373 
00386         virtual void inputTagSizeExceeded(const StringPimpl &userId,
00387                                           const StringPimpl &botId,
00388                                           const StringPimpl &endUserId) 
00389         { 
00390             emit addText("[Warning input Tag Size Exceeded]");
00391         } 
00392 
00406         virtual void starTagNumericConversionError(const StringPimpl &message,
00407                                                    const StringPimpl &userId,
00408                                                    const StringPimpl &botId,
00409                                                    const StringPimpl &endUserId)
00410         { 
00411             QString output("starTagNuermicConversionError:");
00412             output += message.c_str();
00413             emit addText(message.c_str());
00414         } 
00415 
00428         virtual void thatTagSizeExceeded(const StringPimpl &userId,
00429                                          const StringPimpl &botId,
00430                                          const StringPimpl &endUserId) 
00431         { 
00432             emit addText("thatTag Size exceeded");
00433         }
00434 
00448         virtual void thatTagNumericConversionError(const StringPimpl &message,
00449                                                    const StringPimpl &userId,
00450                                                    const StringPimpl &botId,
00451                                                    const StringPimpl &endUserId)
00452         { 
00453             QString output("thatTagNumericConversionError:");
00454             output += message.c_str();
00455             emit addText(output);
00456         } 
00457 
00471         virtual void topicStarTagNumericConversionError(const StringPimpl &message,
00472                                                         const StringPimpl &userId,
00473                                                         const StringPimpl &botId,
00474                                                         const StringPimpl &endUserId)
00475         { 
00476             QString output("topicStarTagNumericConversionError:");
00477             output += message.c_str();
00478             emit addText(output);
00479         }   
00480         
00494         virtual void thatStarTagNumericConversionError(const StringPimpl &message,
00495                                                        const StringPimpl &userId,
00496                                                        const StringPimpl &botId,
00497                                                        const StringPimpl &endUserId)
00498         { 
00499             QString output("thatStarTagNumericConversionError:");
00500             output += message.c_str();
00501             emit addText(output);
00502         }
00503 
00504     signals:
00505 
00512         void addText(const QString &text);
00513 };
00514 
00515 } //end of qtgui namespace
00516 
00517 #endif

Generated on Mon Aug 27 12:26:53 2007 for RebeccaAIML by  doxygen 1.5.3