index previous next




file name: addrman.hpp, addrman.cpp
classification: simulation
contents: class CAddressManager, enum EResult
use: provides a class for storing triples <SINT32 networkID, SINT32 nodeID, const CAddr& nodeAddress>
Searches can be conducted for <networkID, nodeID> (returning the nodeAddress) or for <networkID, nodeAddress> (returning the nodeID).


Note: the "nodeAddress" is the network address of a node with the (user) identifier nodeID. Since the same node may have different network addresses in different networks, the network ID must be stored as well.


 enum EResult: the return values for functions CAddressManager::Insert() and CAddressManager::CheckAddress().


global items used by CAddressManager:


member variables of class CAddressManager:

 EBool initCalled_: is set to True by Init(), to False by Dispose().

 CAddressList *listOfAddresses_: stores network addresses with the corresponding nodeID as key. It is needed for mapping the nodeID specified by the user (i.e., EvalSys) to the network address used by the network.

 CNodeList *listOfNodes_: stores node identifiers with the network address as key. It is needed for mapping the network address of a node to the nodeID.


member functions of class CAddressManager:

 CAddressManager (): sets initCalled to False and calls Init(), thus creating the necessary list structures. Internally, two lists are used: one stores the nodeAddress with the key <networkID, nodeID>, and one the nodeID with the key <networkID, nodeAddress>.

 virtual ~CAddressManager (): calls Dispose().

 EResult CheckAddress (SINT32 networkID, SINT32 nodeID, const CAddr& nodeAddress): Searches with the key <networkID, nodeID> in the internal address list and with the key <networkID, nodeAddress> in the internal nodeID list. Return values:

 EBool DeleteAddress (SINT32 networkID, const CAddr& nodeAddress): If the nodeAddress is associated with a nodeID, the association is deleted and True is returned. Otherwise, False is returned.

 EBool DeleteNodeID (SINT32 networkID, SINT32 nodeID): If the nodeID is associated with a node address, the association is deleted and True is returned. Else False is returned.

 virtual void Dispose(): If initCalled is True, the function deletes the list classes and sets initCalled to False. If it is already False, nothing happens.

 EBool FindAddress (SINT32 networkID, SINT32 nodeID, CAddr& nodeAddress): Returns True, if an associated network address exists. In that case, the address is copied into nodeAddress. If no association exists, False is returned and nodeAddress is not modified.

 EBool FindNodeID (SINT32 networkID, const CAddr& nodeAddress, SINT32 *nodeID): Returns True, if an associated nodeID exists. In that case, the value is copied into nodeID. If no association exists, False is returned and nodeID is not modified. If nodeID is NULL, an assert fails.

 virtual void Init(): If initCalled is False, the function creates the list classes needed to store the address triples and sets initCalled to True. If it is already True, nothing happens.

 EResult Insert (SINT32 networkID, SINT32 nodeID, const CAddr& nodeAddress): Stores the <networkID, nodeID, nodeAddress> triple if possible. The triple is only stored if there is no triple <networkID, nodeID, X> and no triple <networkID, Y, nodeAddress> stored for any X,Y. The function returns:

 void Reset (): calls Dispose(), then Init().


last modified: Fri Feb 5 18:55:54 1999