Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

NEDElement Class Reference

#include <nedelement.h>

Inheritance diagram for NEDElement::

ChannelAttrNode ChannelNode ClassNode CompoundModuleNode ConnAttrNode ConnectionNode ConnectionsNode ConstNode CppCobjectNode CppincludeNode CppNoncobjectNode CppStructNode DisplayStringNode EnumFieldNode EnumFieldsNode EnumNode ExpressionNode FieldNode FieldsNode ForLoopNode FunctionNode GateNode GatesizeNode GatesizesNode GatesNode IdentNode ImportedFileNode ImportNode LoopVarNode MachineNode MachinesNode MessageNode NedFileNode NedFilesNode NetworkNode OperatorNode ParamNode ParamRefNode ParamsNode PropertiesNode PropertyNode SimpleModuleNode StructNode SubmoduleNode SubmodulesNode SubstmachineNode SubstmachinesNode SubstparamNode SubstparamsNode UnknownNode List of all members.

Public Methods

Constructor, destructor
 NEDElement ()
 NEDElement (NEDElement *parent)
virtual ~NEDElement ()
Common properties
virtual const char* getTagName () const=0
virtual int getTagCode () const=0
virtual long getId () const
virtual void setId (long id)
virtual const char* getSourceLocation () const
virtual void setSourceLocation (const char *loc)
Generic access to attributes (Methods have to be redefined in subclasses!)
virtual void applyDefaults ()
virtual int getNumAttributes () const=0
virtual const char* getAttributeName (int k) const=0
virtual int lookupAttribute (const char *attr) const
virtual const char* getAttribute (int k) const=0
virtual const char* getAttribute (const char *attr) const
virtual void setAttribute (int k, const char *value)=0
virtual void setAttribute (const char *attr, const char *value)
virtual const char* getAttributeDefault (int k) const=0
virtual const char* getAttributeDefault (const char *attr) const
Generic access to children and siblings
virtual NEDElement* getParent () const
virtual NEDElement* getFirstChild () const
virtual NEDElement* getLastChild () const
virtual NEDElement* getNextSibling () const
virtual void appendChild (NEDElement *node)
virtual void insertChildBefore (NEDElement *where, NEDElement *newnode)
virtual NEDElement* removeChild (NEDElement *node)
virtual NEDElement* getFirstChildWithTag (int tagcode) const
virtual NEDElement* getNextSiblingWithTag (int tagcode) const
virtual int getNumChildren () const
virtual int getNumChildrenWithTag (int tagcode) const

Static Protected Methods

bool stringToBool (const char *s)
const char* boolToString (bool b)
int stringToEnum (const char *s, const char *vals[], int nums[], int n)
const char* enumToString (int b, const char *vals[], int nums[], int n)

Detailed Description

Base class for objects in a NED object tree, the XML-based in-memory representation for NED files. An instance of a NEDElement subclass represent an XML element. NEDElement provides a DOM-like, generic access to the tree; subclasses additionally provide a typed interface.


Constructor & Destructor Documentation

NEDElement::NEDElement ( )
 

Constructor

NEDElement::NEDElement ( NEDElement * parent )
 

Constructor. Takes parent element.

NEDElement::~NEDElement ( ) [virtual]
 

Destructor. Destroys children too.


Member Function Documentation

void NEDElement::appendChild ( NEDElement * node ) [virtual]
 

Appends the given element at the end of the child element list.

The node pointer passed should not be NULL.

void NEDElement::applyDefaults ( ) [virtual]
 

Sets every attribute to its default value (as returned by getAttributeDefault()). Attributes without a default value are not affected.

This method is called from the constructors of derived classes.

const char * NEDElement::getAttribute ( const char * attr ) const [virtual]
 

Returns the value of the attribute with the given name. Relies on lookupAttribute() and getAttribute().

It returns NULL if the given attribute is not found.

const char * NEDElement::getAttribute ( int k ) const [pure virtual]
 

Pure virtual method, it should be redefined in subclasses to return the value of the kth attribute (i.e. the attribute with the name getAttributeName(k)).

It should return NULL if k is out of range (i.e. negative or greater than getNumAttributes()).

Reimplemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CppincludeNode, CppStructNode, CppCobjectNode, CppNoncobjectNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode.

const char * NEDElement::getAttributeDefault ( const char * attr ) const [virtual]
 

Returns the default value of the given attribute, as defined in the DTD. Relies on lookupAttribute() and getAttributeDefault().

It returns NULL if the given attribute is not found.

const char * NEDElement::getAttributeDefault ( int k ) const [pure virtual]
 

Pure virtual method, it should be redefined in subclasses to return the default value of the kth attribute, as defined in the DTD.

It should return NULL if k is out of range (i.e. negative or greater than getNumAttributes()).

Reimplemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CppincludeNode, CppStructNode, CppCobjectNode, CppNoncobjectNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode.

const char * NEDElement::getAttributeName ( int k ) const [pure virtual]
 

Pure virtual method, it should be redefined in subclasses to return the name of the kth attribute as defined in the DTD.

It should return NULL if k is out of range (i.e. negative or greater than getNumAttributes()).

Reimplemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CppincludeNode, CppStructNode, CppCobjectNode, CppNoncobjectNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode.

NEDElement * NEDElement::getFirstChild ( ) const [virtual]
 

Returns pointer to the first child element, or NULL if this element has no children.

NEDElement * NEDElement::getFirstChildWithTag ( int tagcode ) const [virtual]
 

Returns pointer to the first child element with the given tag code, or NULL if this element has no such children.

long NEDElement::getId ( ) const [virtual]
 

Returns a unique id, originally set by the contructor.

NEDElement * NEDElement::getLastChild ( ) const [virtual]
 

Returns pointer to the last child element, or NULL if this element has no children.

NEDElement * NEDElement::getNextSibling ( ) const [virtual]
 

Returns pointer to the next sibling of this element (i.e. the next child in the parent element). Return NULL if there're no subsequent elements.

getFirstChild() and getNextSibling() can be used to loop through the child list:

 for (NEDElement *child=node->getFirstChild(); child; child = child->getNextSibling())
 {
    ...
 }
 

NEDElement * NEDElement::getNextSiblingWithTag ( int tagcode ) const [virtual]
 

Returns pointer to the next sibling of this element with the given tag code. Return NULL if there're no such subsequent elements.

getFirstChildWithTag() and getNextSiblingWithTag() are a convient way to loop through elements with a certain tag code in the child list:

 for (NEDElement *child=node->getFirstChildWithTag(tagcode); child; child = child->getNextSiblingWithTag(tagcode))
 {
     ...
 }
 

int NEDElement::getNumAttributes ( ) const [pure virtual]
 

Pure virtual method, it should be redefined in subclasses to return the number of attributes defined in the DTD.

Reimplemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CppincludeNode, CppStructNode, CppCobjectNode, CppNoncobjectNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode.

int NEDElement::getNumChildren ( ) const [virtual]
 

Returns the number of child elements.

int NEDElement::getNumChildrenWithTag ( int tagcode ) const [virtual]
 

Returns the number of child elements with the given tag code.

NEDElement * NEDElement::getParent ( ) const [virtual]
 

Returns the parent element, or NULL if this element has no parent.

const char * NEDElement::getSourceLocation ( ) const [virtual]
 

Returns a string containing a file/line position showing where this element originally came from.

int NEDElement::getTagCode ( ) const [pure virtual]
 

Overridden in subclasses to return the numeric code (NED_xxx) of the XML element the class represents.

Reimplemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CppincludeNode, CppStructNode, CppCobjectNode, CppNoncobjectNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode.

const char * NEDElement::getTagName ( ) const [pure virtual]
 

Overridden in subclasses to return the name of the XML element the class represents.

Reimplemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CppincludeNode, CppStructNode, CppCobjectNode, CppNoncobjectNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode.

void NEDElement::insertChildBefore ( NEDElement * where,
NEDElement * newnode ) [virtual]
 

Inserts the given element just before the specified child element in the child element list.

The where element must be a child of this element. The node pointer passed should not be NULL.

int NEDElement::lookupAttribute ( const char * attr ) const [virtual]
 

Returns the index of the given attribute. It returns -1 if the attribute is not found. Relies on getNumAttributes() and getAttributeName().

NEDElement * NEDElement::removeChild ( NEDElement * node ) [virtual]
 

Removes the given element from the child element list.

The pointer passed should be a child of this element.

void NEDElement::setAttribute ( const char * attr,
const char * value ) [virtual]
 

Sets the value of the attribute with the given name. Relies on lookupAttribute() and setAttribute().

If the given attribute is not found, the call has no effect.

void NEDElement::setAttribute ( int k,
const char * val ) [pure virtual]
 

Pure virtual method, it should be redefined in subclasses to set the value of the kth attribute (i.e. the attribute with the name getAttributeName(k)).

If k is out of range (i.e. negative or greater than getNumAttributes()), the call should be ignored.

Reimplemented in NedFilesNode, NedFileNode, ImportNode, ImportedFileNode, ChannelNode, ChannelAttrNode, NetworkNode, SimpleModuleNode, CompoundModuleNode, ParamsNode, ParamNode, GatesNode, GateNode, MachinesNode, MachineNode, SubmodulesNode, SubmoduleNode, SubstparamsNode, SubstparamNode, GatesizesNode, GatesizeNode, SubstmachinesNode, SubstmachineNode, ConnectionsNode, ConnectionNode, ConnAttrNode, ForLoopNode, LoopVarNode, DisplayStringNode, ExpressionNode, OperatorNode, FunctionNode, ParamRefNode, IdentNode, ConstNode, CppincludeNode, CppStructNode, CppCobjectNode, CppNoncobjectNode, EnumNode, EnumFieldsNode, EnumFieldNode, MessageNode, ClassNode, StructNode, FieldsNode, FieldNode, PropertiesNode, PropertyNode, and UnknownNode.

void NEDElement::setId ( long id ) [virtual]
 

Unique id assigned by the constructor can be overwritten here.

void NEDElement::setSourceLocation ( const char * loc ) [virtual]
 

Sets location string (a string containing a file/line position showing where this element originally came from). Called by the (NED/XML) parser.


The documentation for this class was generated from the following file:
Generated at Mon Jun 16 23:37:42 2003 for OMNeT++NEDXML by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001