00001 00002 /*========================================================================== 00003 * 00004 * Original source copyright (c) 2001, Carnegie Mellon University. 00005 * See copyright.cmu for details. 00006 * Modifications copyright (c) 2002, University of Massachusetts. 00007 * See copyright.umass for details. 00008 * 00009 *========================================================================== 00010 */ 00011 00012 #ifndef NULL 00013 #define NULL 0 00014 #endif 00015 00016 #ifndef _TEXTHANDLER_HPP 00017 #define _TEXTHANDLER_HPP 00018 00019 00036 00037 00038 // Might make more sense as TextSource and TextDestination with 00039 // functions in the middle of the chain inheriting from both. 00040 #include <cstdio> 00041 00042 class TextHandler { 00043 00044 public: 00045 TextHandler() { 00046 textHandler = NULL; 00047 } 00048 00050 virtual void foundDoc(char * docno) { 00051 docno = handleDoc(docno); 00052 if (textHandler != NULL) 00053 textHandler->foundDoc(docno); 00054 } 00056 virtual void foundWord(char * word) { 00057 word = handleWord(word); 00058 if (textHandler != NULL) 00059 textHandler->foundWord(word); 00060 } 00061 00063 virtual void foundSymbol(char * sym) { 00064 sym = handleSymbol(sym); 00065 if (textHandler != NULL) 00066 textHandler->foundSymbol(sym); 00067 } 00068 00070 virtual void setTextHandler(TextHandler * th) { 00071 textHandler = th; 00072 } 00073 00075 virtual char * handleDoc(char * docno) { return docno; } 00077 virtual char * handleWord(char * word) { return word; } 00079 virtual char * handleSymbol(char * sym) { return sym; } 00080 00081 protected: 00083 TextHandler * textHandler; 00084 }; 00085 00086 #endif 00087