nedelement.h

Go to the documentation of this file.
00001 //==========================================================================
00002 // nedelement.h  -
00003 //
00004 //                     OMNeT++/OMNEST
00005 //            Discrete System Simulation in C++
00006 //
00007 // Contents:
00008 //   class NEDElement
00009 //
00010 //==========================================================================
00011 
00012 /*--------------------------------------------------------------*
00013   Copyright (C) 2002-2005 Andras Varga
00014 
00015   This file is distributed WITHOUT ANY WARRANTY. See the file
00016   `license' for details on this and other legal matters.
00017 *--------------------------------------------------------------*/
00018 
00019 #ifndef __NEDELEMENT_H
00020 #define __NEDELEMENT_H
00021 
00022 #ifdef _MSC_VER
00023 // disable 4786: "identifier was truncated to '255' characters" for STL in VC6.0
00024 // disable 4996: VC8.0 warnings on Unix syscalls
00025 #pragma warning(disable:4786 4996)
00026 #endif
00027 
00028 #include <string>
00029 
00035 class NEDElementUserData
00036 {
00037   public:
00039     NEDElementUserData() {}
00040 
00042     virtual ~NEDElementUserData() {}
00043 };
00044 
00054 class NEDElement
00055 {
00056   private:
00057     long id;
00058     std::string srcloc;
00059     NEDElement *parent;
00060     NEDElement *firstchild;
00061     NEDElement *lastchild;
00062     NEDElement *prevsibling;
00063     NEDElement *nextsibling;
00064     NEDElementUserData *userdata;
00065     static long lastid;
00066 
00067   protected:
00068     static bool stringToBool(const char *s);
00069     static const char *boolToString(bool b);
00070     static int stringToEnum(const char *s, const char *vals[], int nums[], int n);
00071     static const char *enumToString(int b, const char *vals[], int nums[], int n);
00072 
00073   public:
00076 
00080     NEDElement();
00081 
00085     NEDElement(NEDElement *parent);
00086 
00090     virtual ~NEDElement();
00092 
00095 
00100     virtual const char *getTagName() const = 0;
00101 
00106     virtual int getTagCode() const = 0;
00107 
00111     virtual long getId() const;
00112 
00116     virtual void setId(long id);
00117 
00122     virtual const char *getSourceLocation() const;
00123 
00128     virtual void setSourceLocation(const char *loc);
00130 
00133 
00140     virtual void applyDefaults();
00141 
00146     virtual int getNumAttributes() const = 0;
00147 
00155     virtual const char *getAttributeName(int k) const = 0;
00156 
00161     virtual int lookupAttribute(const char *attr) const;
00162 
00171     virtual const char *getAttribute(int k) const = 0;
00172 
00179     virtual const char *getAttribute(const char *attr) const;
00180 
00189     virtual void setAttribute(int k, const char *value) = 0;
00190 
00197     virtual void setAttribute(const char *attr, const char *value);
00198 
00206     virtual const char *getAttributeDefault(int k) const = 0;
00207 
00214     virtual const char *getAttributeDefault(const char *attr) const;
00216 
00219 
00223     virtual NEDElement *getParent() const;
00224 
00229     virtual NEDElement *getFirstChild() const;
00230 
00235     virtual NEDElement *getLastChild() const;
00236 
00252     virtual NEDElement *getNextSibling() const;
00253 
00258     virtual NEDElement *getPrevSibling() const;
00259 
00265     virtual void appendChild(NEDElement *node);
00266 
00274     virtual void insertChildBefore(NEDElement *where, NEDElement *newnode);
00275 
00281     virtual NEDElement *removeChild(NEDElement *node);
00282 
00287     virtual NEDElement *getFirstChildWithTag(int tagcode) const;
00288 
00303     virtual NEDElement *getNextSiblingWithTag(int tagcode) const;
00304 
00308     virtual int getNumChildren() const;
00309 
00313     virtual int getNumChildrenWithTag(int tagcode) const;
00315 
00323     NEDElement *getFirstChildWithAttribute(int tagcode, const char *attr, const char *attrvalue=NULL);
00324 
00329     NEDElement *getParentWithTag(int tagcode);
00331 
00334 
00338     virtual void setUserData(NEDElementUserData *data);
00339 
00344     virtual NEDElementUserData *getUserData() const;
00346 };
00347 
00348 #endif
00349 

Generated on Sat Oct 21 17:47:58 2006 for OMNeT++/OMNEST NEDXML by  doxygen 1.4.6