Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

NodeAddress Class Reference

The NodeAddress class provides a means to uniquely identify nodes on screen. More...

List of all members.

Public Member Functions

 NodeAddress ()
 Default constructor; creates a new, empty NodeAddress.

 NodeAddress (const NodeAddress &addrParent, GenericNode *nd)
 Creates a new node address for the node nd, where the node address of nds parent node is addrParent.

 NodeAddress (const NodeAddress &addrParent, char *id)
 Creates a new node address leading to a node with node ID id.

 NodeAddress (NodeAddress &)
 Copy constructor.

 ~NodeAddress ()
 Deletes all data members and destroys the instance.

bool contains (char *id) const
 Tests whether a node address contains a given node ID.

bool operator== (const NodeAddress &na) const
 Equality operator.

NodeAddress operator= (const NodeAddress &na)
 Assignment operator.

void parentAddress (NodeAddress &pa)
 Calculates the node address of the immediate parent node.

const char * nodeID (void) const
 Returns the node ID of the node this address points to in a static buffer.

void print () const
 Prints the node address to stdout.

void sprint (char *buf)
 Prints the node address to a string buffer.


Public Attributes

unsigned char * addr
 An array that contains the node address.

unsigned int len
 The length of the addr array.


Detailed Description

The NodeAddress class provides a means to uniquely identify nodes on screen.

Although feature structures can contain shared data, the visible properties of two instances of a shared feature structure (e.g. visible vs. hidden, expanded vs. collapsed) can be different. Therefore, every node that can be displayed must have a unique address that not only encodes which data node it is associated with but also its exact position in the overall feature structure. This unique address is essentially a path from the topmost node in the overall structure to the substructure it identifies, very much like paths in standard feature structure descriptions. The format of a node address is as follows: Every single node in the data structure passed to grisu specifies an integer number in the "id" field of the record (see the communications protocol EBNF). This number is converted into an array of individual integers, each representing one indivdual digit, so 2436 becomes [2,4,3,6]. The full address of a node is calculated by concatenating all the id's of all the nodes from the root to this node. Node id's are prepended; thus the id of the root node will always end up to be the rightmost. The two uppper bits in each entry are reserved, where 0x80 indicates that the id of a new node starts at this position, and 0x40 indicates that the id of a node ends at this position.

Author:
Holger Wunsch


Constructor & Destructor Documentation

NodeAddress::NodeAddress  ) 
 

Default constructor; creates a new, empty NodeAddress.

Note that an empty node address is not equal to the node address of the root node, which contains exactly one node ID, the node ID of the root node in the data package.

NodeAddress::NodeAddress const NodeAddress &  addrParent,
GenericNode nd
 

Creates a new node address for the node nd, where the node address of nds parent node is addrParent.

Parameters:
addrParent the node address of the parent node
nd the node for which the new address is to be created.

NodeAddress::NodeAddress const NodeAddress &  addrParent,
char *  id
 

Creates a new node address leading to a node with node ID id.

Parameters:
addrParent the node address of the parent node
id the node ID of the node which the new address will be created for.

NodeAddress::NodeAddress NodeAddress &   ) 
 

Copy constructor.

NodeAddress::~NodeAddress  ) 
 

Deletes all data members and destroys the instance.


Member Function Documentation

bool NodeAddress::contains char *  id  )  const
 

Tests whether a node address contains a given node ID.

Parameters:
id the node ID to be tested
Returns:
true, if the ID occurs in the node address, false otherwise.

const char * NodeAddress::nodeID void   )  const
 

Returns the node ID of the node this address points to in a static buffer.

Returns:
a pointer to a static char buffer that contains the node ID.

NodeAddress NodeAddress::operator= const NodeAddress &  na  ) 
 

Assignment operator.

Parameters:
na the node address that is to be assigned to this node address.
Returns:
A NodeAddress object containing the new value.

bool NodeAddress::operator== const NodeAddress &  na  )  const
 

Equality operator.

Parameters:
na the node address this node address is to be compared to.
Returns:
true if the two node addresses are equal, false otherwise.

void NodeAddress::parentAddress NodeAddress &  pa  ) 
 

Calculates the node address of the immediate parent node.

Parameters:
pa [out] the parent address will be assigned to the object passed in pa. pa must be a valid instance of a NodeAddress (preferably created with the default constructor).

void NodeAddress::print  )  const
 

Prints the node address to stdout.

void NodeAddress::sprint char *  buf  ) 
 

Prints the node address to a string buffer.


Member Data Documentation

unsigned char* NodeAddress::addr
 

An array that contains the node address.

unsigned int NodeAddress::len
 

The length of the addr array.


Generated on Sun Apr 27 18:26:58 2003 for Grisu by doxygen1.3