00001 #ifndef __CATCHER_H 00002 #define __CATCHER_H 00003 00004 #include <vector> 00005 #include "Node.h" 00006 #include "IpAddress.h" 00007 #include "ObservableInterface.h" 00008 #include "Mutex.h" 00009 #include "randomc.h" 00010 00011 class Catcher : public BasicObject, public ObservableInterface 00012 { 00013 public: 00014 Catcher(); 00015 virtual ~Catcher(); 00016 00017 // 00018 // Accessors 00019 // 00020 int getNumberOfNodes(); 00021 bool getNode(int, Node*); 00022 Node* lookup(IpAddress ipAddr); 00023 Node* getUnconnectedNode(); 00024 00025 // 00026 // Mutators 00027 // 00028 int addNode(Node* node); 00029 bool deleteNode(Node*); 00030 00031 // 00032 // I/O ops 00033 // 00034 bool save(); 00035 bool save(string path); 00036 int load(); 00037 int load(string path); 00038 virtual void toStream(std::ostream& out); 00039 friend std::istream& operator >>(std::istream& in, Catcher& catcher); 00040 00041 protected: 00042 Node* isDup(IpAddress ipAddr); 00043 bool deleteNode(); 00044 void deleteAll(); 00045 00048 std::vector<Node*> m_nodeList; 00049 00051 Mutex m_nodeListLock; 00052 00053 TRanrotBGenerator m_randomNumberGenerator; 00054 }; 00055 00056 #endif