Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Catcher Class Reference

Maintains a list of all discovered nodes. More...

#include <catcher.h>

Inheritance diagram for Catcher::

BasicObject ObservableInterface List of all members.

Public Methods

 Catcher ()
 Create the catcher. More...

virtual ~Catcher ()
 Delete the node list. More...

int getNumberOfNodes ()
 Return the number of nodes we know about. More...

bool getNode (int, Node *)
 Get a copy of the node at the index specified. More...

Nodelookup (IpAddress ipAddr)
 Search the node list for the specified IP address. More...

NodegetUnconnectedNode ()
 Gets a node that may be worth connecting to. More...

int addNode (Node *node)
 Adds a node to the list. More...

bool deleteNode (Node *)
 Delete the node specified. More...

bool save ()
 Save node list to default host file. More...

bool save (string path)
 Write the Catcher configuration to a file. More...

int load ()
 Read host list from default host list file. More...

int load (string path)
 Read Catcher configuration from file. More...

virtual void toStream (std::ostream &out)

Protected Methods

NodeisDup (IpAddress ipAddr)
 Return the node found in the table if it is a duplicate, NULL otherwise. More...

bool deleteNode ()
 Find a good node to delete and delete it. More...

void deleteAll ()
 Delete all the nodes in the list. More...


Protected Attributes

std::vector< Node *> m_nodeList
 Pointer to an array of pointers to Nodes. This is a list of all known nodes. We must do it this way because MaxHosts is configurable. More...

Mutex m_nodeListLock
 Mutex for the node list. More...

TRanrotBGenerator m_randomNumberGenerator

Friends

std::istream & operator>> (std::istream &in, Catcher &catcher)

Detailed Description

Maintains a list of all discovered nodes.

This is where the memory for the nodes is stored. Lots of other classes make pointers to these nodes.

Definition at line 11 of file catcher.h.


Constructor & Destructor Documentation

Catcher::Catcher
 

Create the catcher.

Create an empty node list.

Definition at line 12 of file catcher.cpp.

Catcher::~Catcher [virtual]
 

Delete the node list.

Definition at line 20 of file catcher.cpp.


Member Function Documentation

int Catcher::addNode Node * node
 

Adds a node to the list.

Returns:
1 if the node was added to the list 0 if the node already existed -1 if there was no more room in the table for another node

Definition at line 53 of file catcher.cpp.

Referenced by NodeManagerCommand::addNode(), and NetworkLayer::handleImHerePacket().

void Catcher::deleteAll [protected]
 

Delete all the nodes in the list.

Definition at line 270 of file catcher.cpp.

Referenced by load(), and ~Catcher().

bool Catcher::deleteNode [protected]
 

Find a good node to delete and delete it.


A good node to delete is, in order of priority:
1) one we have tried to connect to before and failed
2) one which we have never connected to

The only reason you try to delete nodes from your list is when you run out of space.

Returns:
true on sucessful delete. false if there was nothing left to delete.

Definition at line 212 of file catcher.cpp.

Referenced by addNode().

bool Catcher::deleteNode Node * node
 

Delete the node specified.

Definition at line 240 of file catcher.cpp.

Referenced by NodeManagerCommand::run().

bool Catcher::getNode int index,
Node * node
 

Get a copy of the node at the index specified.

The copy will be placed in the "node" argument passed in. Return false if the index is invalid, true otherwise.

Definition at line 104 of file catcher.cpp.

Referenced by NodeManagerCommand::getHtmlInterface().

int Catcher::getNumberOfNodes
 

Return the number of nodes we know about.

Definition at line 93 of file catcher.cpp.

Referenced by SummaryScreenCommand::getHtmlInterface(), and NodeManagerCommand::getHtmlInterface().

Node * Catcher::getUnconnectedNode
 

Gets a node that may be worth connecting to.

The order of priority of nodes returned is:

  1. Nodes you have connected to before
  2. Node you have never connected to before
  3. Node you tried to connect to but failed

Definition at line 127 of file catcher.cpp.

Referenced by LinkLayerInterface::peerConnectImpl().

Node * Catcher::isDup IpAddress ipAddr [protected]
 

Return the node found in the table if it is a duplicate, NULL otherwise.

Definition at line 30 of file catcher.cpp.

Referenced by addNode().

int Catcher::load string path
 

Read Catcher configuration from file.

Returns:
true if file sucessfully read false if the file could not be opened

Definition at line 299 of file catcher.cpp.

int Catcher::load
 

Read host list from default host list file.

Definition at line 288 of file catcher.cpp.

Referenced by GlobalObjects::init().

Node * Catcher::lookup IpAddress ipAddr
 

Search the node list for the specified IP address.

A pointer to the node found is returned in the second parameter. If nothing has been found, the second parameter is set to NULL.

Returns:
true if the address is found, false otherwise

Definition at line 361 of file catcher.cpp.

Referenced by LinkLayerInterface::accept(), NodeManagerCommand::addNode(), NodeManagerCommand::run(), and ConnectionManagerCommand::run().

bool Catcher::save string path
 

Write the Catcher configuration to a file.

Returns:
true if successful, false otherwise.

Definition at line 340 of file catcher.cpp.

bool Catcher::save
 

Save node list to default host file.

Definition at line 330 of file catcher.cpp.

Referenced by NodeManagerCommand::addNode(), addNode(), deleteNode(), and GlobalObjects::destroyImpl().

void Catcher::toStream std::ostream & out [virtual]
 

Reimplemented from BasicObject.

Definition at line 375 of file catcher.cpp.


Friends And Related Function Documentation

std::istream& operator>> std::istream & in,
Catcher & catcher
[friend]
 


Member Data Documentation

std::vector<Node*> Catcher::m_nodeList [protected]
 

Pointer to an array of pointers to Nodes. This is a list of all known nodes. We must do it this way because MaxHosts is configurable.

Definition at line 48 of file catcher.h.

Mutex Catcher::m_nodeListLock [protected]
 

Mutex for the node list.

Definition at line 51 of file catcher.h.

TRanrotBGenerator Catcher::m_randomNumberGenerator [protected]
 

Definition at line 53 of file catcher.h.


The documentation for this class was generated from the following files:
Generated at Thu Jul 11 13:31:55 2002 for Peekabooty by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001