00001 // Define a "routing capable" node 00002 // Insures functionality to run routing algorithms 00003 00004 #ifndef __RNODE_H__ 00005 #define __RNODE_H__ 00006 00007 #include "nix/nixvec.h" 00008 00009 #include <set> 00010 #include <map> 00011 #include <vector> 00012 #include <deque> 00013 #include <algorithm> 00014 00015 #ifdef USE_HASH 00016 #include <hash_set> 00017 #endif 00018 00019 typedef unsigned long nodeid_t; // Node identifier 00020 typedef unsigned long dist_t; // Distance 00021 typedef unsigned int weight_t; // Weight 00022 typedef pair<nodeid_t, weight_t> NodeWeight_t; // Node/Distance Pair 00023 00024 const dist_t INF = 0xffffffff; 00025 const nodeid_t NODE_NONE = 0xffffffff; 00026 00027 class RNode { 00028 public : 00029 RNode( ); 00030 RNode( nodeid_t id); 00031 RNode( const RNode& n); 00032 virtual ~RNode(); 00033 virtual void AddAdj(nodeid_t a, int w = 1); 00034 // Get next adjacent node..pass in NODE_NONE to get first 00035 virtual const NodeWeight_t NextAdj( const NodeWeight_t&); 00036 virtual NixPair_t GetNix(nodeid_t); // Get neighbor index/length 00037 virtual Nixl_t GetNixl(); // Get bits needed for nix entry 00038 virtual nodeid_t GetNeighbor(Nix_t);// Get neighbor from nix 00039 //int const operator= (const dist_t& n) { return n == m_id;} 00040 //int const operator!= (const dist_t& n) { return n != m_id;} 00041 public : 00042 nodeid_t m_id; // This node identifier 00043 }; 00044 00045 // Declare the equal and not= operators 00046 //int operator== (const RNode& N, const dist_t& n) { return N.m_id == n;} 00047 //int operator!= (const RNode& N, const dist_t& n) { return N.m_id != n;} 00048 //int operator== (RNode& N, const dist_t& n) { return N.m_id == n;} 00049 //int operator!= (RNode& N, const dist_t& n) { return N.m_id != n;} 00050 00051 // Define the vector for nodes 00052 typedef vector<RNode*> RNodeVec_t; 00053 typedef RNodeVec_t::iterator RNodeVec_it; 00054 00055 // Define the deque for nodes 00056 typedef deque<RNode*> RNodeDeq_t; 00057 typedef RNodeDeq_t::iterator RNodeDeq_it; 00058 00059 // Define the vector for next hop neighbors 00060 typedef vector<nodeid_t> RoutingVec_t; 00061 typedef RoutingVec_t::iterator RoutingVec_it; 00062 00063 // Define the distance vector 00064 typedef vector<dist_t> DistVec_t; 00065 typedef DistVec_t::iterator DistVec_it; 00066 00067 #endif
1.3.3