00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00015 #ifndef __FINDTEXT_HPP__
00016  #define __FINDTEXT_HPP__
00017 
00018 #include "pubsub.hpp"
00019 #include "cexception.hpp"
00020 
00021 
00022 
00023 #undef FindText
00024 
00025 class FindText;
00026 
00033 struct MsgBase {
00035        FindText& ft;
00036 
00040        MsgBase(FindText& ft_) : ft(ft_) {}
00041 };
00042 
00047 struct FoundMsg : MsgBase {
00049        const std::string fileName;
00051        const int lineNum;
00053        const std::string lineText;
00054 
00058        FoundMsg(FindText& ft, const std::string& file, int num,
00059          const std::string& txt) : MsgBase(ft), fileName(file), lineNum(num),
00060          lineText(txt) {}
00061 };
00062 
00067 struct InfoMsg : MsgBase {
00069        enum Type { opened, closed };
00070 
00072        const Type type;
00074        const std::string fileName;
00075 
00079        InfoMsg(FindText& ft, Type t, const std::string& fn) : MsgBase(ft),
00080          type(t), fileName(fn) {}
00081 };
00082 
00088 struct ErrorMsg : MsgBase {
00090        const std::string errMsg;
00091 
00095        ErrorMsg(FindText& ft, const std::string& err) : MsgBase(ft), errMsg(err)
00096          {}
00097 };
00098 
00105 class FindText {
00106  public:
00114       virtual void search(const std::string& dir, bool recur,
00115         const std::string& mask, const std::string& text)=0;
00116 
00122       virtual void stopSearch()=0;
00123 
00129       virtual Publisher<FoundMsg>& foundPub()=0;
00130 
00136       virtual Publisher<InfoMsg>& infoPub()=0;
00137 
00143       virtual Publisher<ErrorMsg>& errorPub()=0;
00144 
00148       virtual ~FindText() {}
00149 
00150  private:
00152       FindText& operator=(const FindText&);
00153 };
00154 
00158 namespace Factory {
00159 
00164  sh_ptr<FindText> newFindText();
00165 
00166 }
00167 
00168 #endif