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

MFNode Class Reference

Encapsulates a MFNode. More...

Inheritance diagram for MFNode:

FieldValue List of all members.

Public Methods

 MFNode (size_t length=0, const NodePtr *nodes=0) throw (std::bad_alloc)
 Construct from an array of Node pointers.

virtual ~MFNode () throw ()
 Destructor.

const NodePtrgetElement (size_t index) const throw ()
 Get element.

void setElement (size_t index, const NodePtr &node) throw ()
 Set element.

size_t getLength () const throw ()
 Get the length.

void setLength (size_t length) throw (std::bad_alloc)
 Set the length.

bool exists (const Node &node) const
 Determine if a node exists in this MFNode.

bool addNode (const NodePtr &node)
 Add a node.

bool removeNode (const Node &node)
 Remove a node.

void addElement (const NodePtr &node) throw (std::bad_alloc)
 Add an element to the end of the sequence.

void insertElement (size_t index, const NodePtr &node) throw (std::bad_alloc)
 Insert an element into the sequence.

void removeElement (size_t index) throw ()
 Remove an element from the sequence.

void clear () throw ()
 Remove all elements.

virtual std::auto_ptr< FieldValueclone () const throw (std::bad_alloc)
 Virtual copy constructor.

virtual FieldValueassign (const FieldValue &value) throw (std::bad_cast, std::bad_alloc)
 Virtual assignment.

virtual Type type () const throw ()
 Get the FieldValue::Type associated with this class.


Private Methods

virtual void print (std::ostream &) const
 Print to an output stream.


Private Attributes

std::vector< NodePtrnodes

Detailed Description

Encapsulates a MFNode.


Constructor & Destructor Documentation

MFNode size_t    length = 0,
const NodePtr   nodes = 0
throw (std::bad_alloc) [explicit]
 

Construct from an array of Node pointers.

Parameters:
length the length of the array
nodes a pointer to an array of Node pointers

~MFNode   throw () [virtual]
 

Destructor.


Member Function Documentation

void addElement const NodePtr   node throw (std::bad_alloc)
 

Add an element to the end of the sequence.

Parameters:
node the node to add.
Exceptions:
std::bad_alloc if memory allocation fails.

bool addNode const NodePtr   node
 

Add a node.

Add node to the array if it isn't already part of this MFNode. This method will not add NULLs.

Parameters:
node a pointer to the node to add
Returns:
true if a node was added, false otherwise.

FieldValue & assign const FieldValue   value throw (std::bad_cast, std::bad_alloc) [virtual]
 

Virtual assignment.

Returns:
a reference to the object.
Exceptions:
std::bad_cast if value is not an MFNode object.
std::bad_alloc if memory allocation fails.

Implements FieldValue.

void clear   throw ()
 

Remove all elements.

std::auto_ptr< FieldValue > clone   const throw (std::bad_alloc) [virtual]
 

Virtual copy constructor.

Returns:
a pointer to a copy of the object.
Exceptions:
std::bad_alloc if memory allocation fails.

Implements FieldValue.

bool exists const Node   node const
 

Determine if a node exists in this MFNode.

Parameters:
node 

const NodePtr & getElement size_t    index const throw ()
 

Get element.

Parameters:
index 
Returns:
a smart pointer to a Node

size_t getLength   const throw ()
 

Get the length.

Returns:
the number of nodes in the array

void insertElement size_t    index,
const NodePtr   node
throw (std::bad_alloc)
 

Insert an element into the sequence.

Parameters:
index the index where the new node should be inserted.
node a NodePtr.
Exceptions:
std::bad_alloc if memory allocation fails.
Precondition:
index is a valid index.

void print std::ostream &    out const [private, virtual]
 

Print to an output stream.

Any null elements in the MFNode will not get printed; VRML97 syntax does not accommodate NULL in an MFNode.

Parameters:
out an output stream.

Implements FieldValue.

void removeElement size_t    index throw ()
 

Remove an element from the sequence.

Parameters:
index the index of the value to remove.
Precondition:
index is a valid index.

bool removeNode const Node   node
 

Remove a node.

Remove node from the array, if it exists here. This method will not remove NULLs.

Parameters:
node a pointer to the node to remove
Returns:
true if a node was removed, false otherwise

void setElement size_t    index,
const NodePtr   node
throw ()
 

Set element.

Parameters:
index 
node 

void setLength size_t    length throw (std::bad_alloc)
 

Set the length.

Set the length of the node array. If the new length is less than the current length, the array is truncated. If the length is greater than the current length, the new positions at the end of the array are filled with null NodePtrs.

Parameters:
length the new length

FieldValue::Type type   const throw () [virtual]
 

Get the FieldValue::Type associated with this class.

Returns:
FieldValue::mfnode.

Implements FieldValue.