00001 #ifndef WHOISCACHE_H 00002 #define WHOISCACHE_H 00003 00004 #include <abuse/UrlRange.h> 00005 #include <string> 00006 #include <stdexcept> 00007 #include <abuse/ZeWhois.h> 00008 #include <map> 00009 //Extended Whois Cache Interface 00010 00011 //forward decl 00012 class CacheEntry; 00013 //type definition 00014 typedef std::map<UrlRange,CacheEntry*> CacheMap; 00015 00016 //generic Cache entry 00017 class CacheEntry 00018 { 00019 public: 00020 virtual const CacheMap& getChildren()const =0; 00021 virtual CacheMap& getChildren()=0; 00022 virtual ~CacheEntry(){} 00023 #ifdef _DEBUG 00024 virtual std::string dump()=0; 00025 #endif 00026 }; 00027 00028 //effective data entry 00029 class DataEntry: public virtual CacheEntry 00030 { 00031 public: 00032 virtual std::string getData()const=0; 00033 }; 00034 00035 //rir entry 00036 class RirEntry: public virtual CacheEntry 00037 { 00038 public: 00039 virtual std::string getRir()const=0; 00040 }; 00041 00042 class WhoisCache 00043 { 00044 public: 00045 struct CacheResult 00046 { 00047 ZeWhois::WhoisList results; 00048 const ZeWhois::RIR* pRir; 00049 bool bCompleted; 00050 CacheResult():bCompleted(false),pRir(&ZeWhois::rirFromRirHandle(ARINhandle)){} 00051 }; 00052 virtual CacheResult get(const Url& url)const=0; 00053 virtual void addRir(const UrlRange& nr,const std::string& rir)throw(std::runtime_error)=0; 00054 virtual void add(const ZeWhois::WhoisList& lst)throw(std::runtime_error)=0; 00055 virtual void remove(const UrlRange& range)=0; 00056 virtual const CacheMap& getTree()const=0; 00057 }; 00058 00059 #endif //WHOISCACHE_H