NEDElement Class Reference
[Data classes]

#include <nedelement.h>

Inheritance diagram for NEDElement:

ChannelElement ChannelInterfaceElement ClassDeclElement ClassElement CommentElement CompoundModuleElement ConditionElement ConnectionElement ConnectionGroupElement ConnectionsElement CplusplusElement EnumDeclElement EnumElement EnumFieldElement EnumFieldsElement ExpressionElement ExtendsElement FieldElement FilesElement FunctionElement GateElement GatesElement IdentElement ImportElement InterfaceNameElement LiteralElement LoopElement MessageDeclElement MessageElement ModuleInterfaceElement MsgFileElement NamespaceElement NedFileElement OperatorElement PackageElement PacketDeclElement PacketElement ParamElement ParametersElement PropertyDeclElement PropertyElement PropertyKeyElement SimpleModuleElement StructDeclElement StructElement SubmoduleElement SubmodulesElement TypesElement UnknownElement

List of all members.


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.

Public Member Functions

Constructor, destructor
 NEDElement ()
 NEDElement (NEDElement *parent)
virtual ~NEDElement ()
virtual NEDElementdup () const =0
virtual NEDElementdupTree () const
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)
virtual const NEDSourceRegiongetSourceRegion () const
virtual void setSourceRegion (const NEDSourceRegion &region)
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 NEDElementgetParent () const
virtual NEDElementgetFirstChild () const
virtual NEDElementgetLastChild () const
virtual NEDElementgetNextSibling () const
virtual NEDElementgetPrevSibling () const
virtual void appendChild (NEDElement *node)
virtual void insertChildBefore (NEDElement *where, NEDElement *newnode)
virtual NEDElementremoveChild (NEDElement *node)
virtual NEDElementgetFirstChildWithTag (int tagcode) const
virtual NEDElementgetNextSiblingWithTag (int tagcode) const
virtual int getNumChildren () const
virtual int getNumChildrenWithTag (int tagcode) const
Utility functions
NEDElementgetFirstChildWithAttribute (int tagcode, const char *attr, const char *attrvalue=NULL)
NEDElementgetParentWithTag (int tagcode)
User data
virtual void setUserData (NEDElementUserData *data)
virtual NEDElementUserDatagetUserData () const

Static Public Member Functions

Counters
static long getNumCreated ()
static long getNumExisting ()

Static Protected Member Functions

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


Constructor & Destructor Documentation

NEDElement::NEDElement (  ) 

Constructor.

NEDElement::NEDElement ( NEDElement parent  ) 

Constructor.

Takes parent element.

virtual NEDElement::~NEDElement (  )  [virtual]

Destructor.

Destroys children too.


Member Function Documentation

static bool NEDElement::stringToBool ( const char *  s  )  [static, protected]

static const char* NEDElement::boolToString ( bool  b  )  [static, protected]

static int NEDElement::stringToEnum ( const char *  s,
const char *  vals[],
int  nums[],
int  n 
) [static, protected]

static const char* NEDElement::enumToString ( int  b,
const char *  vals[],
int  nums[],
int  n 
) [static, protected]

static void NEDElement::validateEnum ( int  b,
const char *  vals[],
int  nums[],
int  n 
) [static, protected]

virtual NEDElement* NEDElement::dup (  )  const [pure virtual]

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

Recursive version of dup(): duplicates the whole subtree.

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

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

virtual long NEDElement::getId (  )  const [virtual]

Returns a unique id, originally set by the constructor.

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

The unique id assigned by the constructor can be overwritten here.

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

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

virtual 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.

virtual const NEDSourceRegion& NEDElement::getSourceRegion (  )  const [virtual]

Returns the source region, containing a line:col region in the source file that corresponds to this element.

virtual void NEDElement::setSourceRegion ( const NEDSourceRegion region  )  [virtual]

Sets source region, containing a line:col region in the source file that corresponds to this element.

Called by the (NED/XML) parser.

virtual 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.

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

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

virtual 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().

virtual 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()).

Implemented in FilesElement, NedFileElement, CommentElement, PackageElement, ImportElement, PropertyDeclElement, ExtendsElement, InterfaceNameElement, SimpleModuleElement, ModuleInterfaceElement, CompoundModuleElement, ChannelInterfaceElement, ChannelElement, ParametersElement, ParamElement, PropertyElement, PropertyKeyElement, GatesElement, GateElement, TypesElement, SubmodulesElement, SubmoduleElement, ConnectionsElement, ConnectionElement, ConnectionGroupElement, LoopElement, ConditionElement, ExpressionElement, OperatorElement, FunctionElement, IdentElement, LiteralElement, MsgFileElement, NamespaceElement, CplusplusElement, StructDeclElement, ClassDeclElement, MessageDeclElement, PacketDeclElement, EnumDeclElement, EnumElement, EnumFieldsElement, EnumFieldElement, MessageElement, PacketElement, ClassElement, StructElement, FieldElement, and UnknownElement.

Referenced by UnknownElement::getAttribute(), FieldElement::getAttribute(), StructElement::getAttribute(), ClassElement::getAttribute(), PacketElement::getAttribute(), MessageElement::getAttribute(), EnumFieldElement::getAttribute(), EnumFieldsElement::getAttribute(), EnumElement::getAttribute(), EnumDeclElement::getAttribute(), PacketDeclElement::getAttribute(), MessageDeclElement::getAttribute(), ClassDeclElement::getAttribute(), StructDeclElement::getAttribute(), CplusplusElement::getAttribute(), NamespaceElement::getAttribute(), MsgFileElement::getAttribute(), LiteralElement::getAttribute(), IdentElement::getAttribute(), FunctionElement::getAttribute(), OperatorElement::getAttribute(), ExpressionElement::getAttribute(), ConditionElement::getAttribute(), LoopElement::getAttribute(), ConnectionGroupElement::getAttribute(), ConnectionElement::getAttribute(), ConnectionsElement::getAttribute(), SubmoduleElement::getAttribute(), SubmodulesElement::getAttribute(), TypesElement::getAttribute(), GateElement::getAttribute(), GatesElement::getAttribute(), PropertyKeyElement::getAttribute(), PropertyElement::getAttribute(), ParamElement::getAttribute(), ParametersElement::getAttribute(), ChannelElement::getAttribute(), ChannelInterfaceElement::getAttribute(), CompoundModuleElement::getAttribute(), ModuleInterfaceElement::getAttribute(), SimpleModuleElement::getAttribute(), InterfaceNameElement::getAttribute(), ExtendsElement::getAttribute(), PropertyDeclElement::getAttribute(), ImportElement::getAttribute(), PackageElement::getAttribute(), CommentElement::getAttribute(), NedFileElement::getAttribute(), and FilesElement::getAttribute().

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

virtual void NEDElement::setAttribute ( int  k,
const char *  value 
) [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.

Implemented in FilesElement, NedFileElement, CommentElement, PackageElement, ImportElement, PropertyDeclElement, ExtendsElement, InterfaceNameElement, SimpleModuleElement, ModuleInterfaceElement, CompoundModuleElement, ChannelInterfaceElement, ChannelElement, ParametersElement, ParamElement, PropertyElement, PropertyKeyElement, GatesElement, GateElement, TypesElement, SubmodulesElement, SubmoduleElement, ConnectionsElement, ConnectionElement, ConnectionGroupElement, LoopElement, ConditionElement, ExpressionElement, OperatorElement, FunctionElement, IdentElement, LiteralElement, MsgFileElement, NamespaceElement, CplusplusElement, StructDeclElement, ClassDeclElement, MessageDeclElement, PacketDeclElement, EnumDeclElement, EnumElement, EnumFieldsElement, EnumFieldElement, MessageElement, PacketElement, ClassElement, StructElement, FieldElement, and UnknownElement.

Referenced by UnknownElement::setAttribute(), FieldElement::setAttribute(), StructElement::setAttribute(), ClassElement::setAttribute(), PacketElement::setAttribute(), MessageElement::setAttribute(), EnumFieldElement::setAttribute(), EnumFieldsElement::setAttribute(), EnumElement::setAttribute(), EnumDeclElement::setAttribute(), PacketDeclElement::setAttribute(), MessageDeclElement::setAttribute(), ClassDeclElement::setAttribute(), StructDeclElement::setAttribute(), CplusplusElement::setAttribute(), NamespaceElement::setAttribute(), MsgFileElement::setAttribute(), LiteralElement::setAttribute(), IdentElement::setAttribute(), FunctionElement::setAttribute(), OperatorElement::setAttribute(), ExpressionElement::setAttribute(), ConditionElement::setAttribute(), LoopElement::setAttribute(), ConnectionGroupElement::setAttribute(), ConnectionElement::setAttribute(), ConnectionsElement::setAttribute(), SubmoduleElement::setAttribute(), SubmodulesElement::setAttribute(), TypesElement::setAttribute(), GateElement::setAttribute(), GatesElement::setAttribute(), PropertyKeyElement::setAttribute(), PropertyElement::setAttribute(), ParamElement::setAttribute(), ParametersElement::setAttribute(), ChannelElement::setAttribute(), ChannelInterfaceElement::setAttribute(), CompoundModuleElement::setAttribute(), ModuleInterfaceElement::setAttribute(), SimpleModuleElement::setAttribute(), InterfaceNameElement::setAttribute(), ExtendsElement::setAttribute(), PropertyDeclElement::setAttribute(), ImportElement::setAttribute(), PackageElement::setAttribute(), CommentElement::setAttribute(), NedFileElement::setAttribute(), and FilesElement::setAttribute().

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

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

virtual 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.

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

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

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

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

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

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

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

Returns pointer to the next sibling of this element (i.e.

the next child in the parent element). Returns 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())
 {
    ...
 }
 

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

Returns pointer to the previous sibling of this element (i.e.

the previous child in the parent element). Returns NULL if there're no elements before this one.

virtual 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.

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

Inserts the given element just before the specified child element in the child element list, or at the end of the child list if NULL is specified as the insert position.

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

virtual 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.

virtual 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.

virtual 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))
 {
     ...
 }
 

virtual int NEDElement::getNumChildren (  )  const [virtual]

Returns the number of child elements.

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

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

NEDElement* NEDElement::getFirstChildWithAttribute ( int  tagcode,
const char *  attr,
const char *  attrvalue = NULL 
)

Returns first child element with the given tagcode and the given attribute (optionally) having the given value.

Returns NULL if not found.

NEDElement* NEDElement::getParentWithTag ( int  tagcode  ) 

Climb up in the element tree until it finds an element with the given tagcode.

Returns "this" if its tagcode already matches. Returns NULL if not found.

static long NEDElement::getNumCreated (  )  [inline, static]

Returns NEDElements constructed so far (this number can only increase).

static long NEDElement::getNumExisting (  )  [inline, static]

Returns NEDElements currently existing (created minus deleted).

Useful for detecting memory leaks.

virtual void NEDElement::setUserData ( NEDElementUserData data  )  [virtual]

Replaces user data object with the given one.

virtual NEDElementUserData* NEDElement::getUserData (  )  const [virtual]

Return pointer to the user data object, or NULL if setUserData() has not been called yet.


The documentation for this class was generated from the following file:

Generated on Wed Apr 3 14:40:29 2013 for OMNeT++ NEDXML by  doxygen 1.5.5