xorp

Node< A > Class Template Reference

The base class of a node for building a hierarchy. More...

#include <node_base.hh>

Inheritance diagram for Node< A >:
NodeAccept NodeAny< T > NodeAssign NodeBin NodeElem NodeNext NodeProto NodeReject NodeSet NodeSubr NodeUn

List of all members.

Classes

struct  path

Public Types

typedef map< A, Edge< A > > adjacency
typedef ref_ptr< Node< A > > NodeRef

Public Member Functions

 Node (A a, bool trace=false)
nodename ()
bool set_nodename (A nodename)
 Set nodename DONT' USE THIS METHOD.
bool add_edge (NodeRef dst, int weight)
 Add a new edge.
bool update_edge_weight (NodeRef dst, int weight)
 Update edge weight.
bool get_edge_weight (NodeRef dst, int &weight)
 Get edge weight.
bool remove_edge (NodeRef dst)
 Remove an edge.
void drop_adjacencies ()
 Drop all adjacencies.
void garbage_collect ()
 Remove all edges that point at invalid nodes.
void set_valid (bool p)
 Set the valid state.
bool valid ()
void set_tentative (bool p)
 Set the tentative state.
bool tentative ()
 Get the tentative state.
void invalidate_weights ()
 Invalidate the weights.
bool valid_weight ()
 Is the current entry valid.
void set_adjacent_weights (NodeRef me, int delta_weight, PriorityQueue< A > &tentative)
 Set weights.
bool set_local_weight (int weight)
 Set local weight.
int get_local_weight ()
 get local weight.
void set_first_hop (NodeRef n)
 The first hop to this node.
NodeRef get_first_hop ()
 The first hop to this node.
void set_last_hop (NodeRef n)
 The node before this.
NodeRef get_last_hop ()
 The node before this.
bool delta (RouteCmd< A > &rcmd)
 Return the difference between this computation and the last.
void clear ()
 Clear all the references to other nodes as well as possible references to ourselves.
string pp () const
 Pretty print this node with its adjacencies.
string str () const
 Node (unsigned line)
unsigned line () const
virtual const Elementaccept (Visitor &v)=0
 Implementation of visitor.
virtual bool is_protocol_statement () const
 Test whether this is a "protocol" statement.
virtual bool is_accept_or_reject () const
 Test whether this is "accept" or "reject" statement.
template<>
string str () const

Private Attributes

bool _valid
_nodename
adjacency _adjacencies
bool _trace
bool _tentative
path _current
path _previous
unsigned _line

Detailed Description

template<typename A>
class Node< A >

The base class of a node for building a hierarchy.

Each node has a line number to associate it with a line in the configuration file. This is useful for reporting error location in semantic checks.

Nodes implement the visitor pattern [Inspired by Alexandrescu].


Constructor & Destructor Documentation

template<typename A>
Node< A >::Node ( unsigned  line) [inline]
Parameters:
linethe configuration line number where this node was created.

Member Function Documentation

template<typename A>
virtual const Element* Node< A >::accept ( Visitor v) [pure virtual]

Implementation of visitor.

Parameters:
vvisit node with this pattern.
Returns:
element at the end of node evaluation.
template<typename A >
bool Node< A >::add_edge ( NodeRef  dst,
int  weight 
)

Add a new edge.

Returns:
true on success. false if edge already exists.
template<typename A>
bool Node< A >::delta ( RouteCmd< A > &  rcmd)

Return the difference between this computation and the last.

Parameters:
rcmdthe new route to this node if it has changed.
Returns:
true if the node has changed.
template<typename A >
void Node< A >::drop_adjacencies ( )

Drop all adjacencies.

Used to revive invalid nodes.

template<typename A >
bool Node< A >::get_edge_weight ( NodeRef  dst,
int &  weight 
)

Get edge weight.

Returns:
true on success, false if the edge doesn't exist.
template<typename A>
virtual bool Node< A >::is_accept_or_reject ( ) const [inline, virtual]

Test whether this is "accept" or "reject" statement.

Returns:
true if this is "accept" or "reject" statement.

Reimplemented in NodeAccept, and NodeReject.

template<typename A>
virtual bool Node< A >::is_protocol_statement ( ) const [inline, virtual]

Test whether this is a "protocol" statement.

Returns:
true if this is a "protocol" statement.

Reimplemented in NodeProto.

template<typename A>
unsigned Node< A >::line ( ) const [inline]
Returns:
line number of configuration where node was created.
template<typename A >
A Node< A >::nodename ( )
Returns:
nodename
template<typename A>
void Node< A >::set_adjacent_weights ( NodeRef  me,
int  delta_weight,
PriorityQueue< A > &  tentative 
)

Set weights.

Visit all neighbours that are tentative and add this weight.

Parameters:
delta_weightto add to this node.
tentativeadd all updated adjacent nodes to the tentative set.
template<typename A >
bool Node< A >::set_local_weight ( int  weight)

Set local weight.

Set the weight on this node if its tentative and less than the previous value.

Returns:
true if its accepted.
template<typename A>
bool Node< A >::set_nodename ( nodename)

Set nodename DONT' USE THIS METHOD.

Changing the nodename could alter the result of the comparison function, causing confusion in the spt map.

Returns:
true on success.
template<typename A >
string Node< A >::str ( ) const
Returns:
C++ string with the human-readable ASCII representation of the node.
template<typename A >
bool Node< A >::update_edge_weight ( NodeRef  dst,
int  weight 
)

Update edge weight.

Returns:
true on success, false if the edge doesn't exist.
template<typename A>
bool Node< A >::valid ( ) [inline]
Returns:
true if this node is not marked for deletion.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations