Main Page Modules Class Hierarchy Compound List File List Compound Members

# nedelement.h

    00001 //==========================================================================
    00002 // nedelement.h  - part of the OMNeT++ Discrete System Simulation System
    00003 //
    00004 // Contents:
    00005 //   class NEDElement
    00006 //
    00007 //==========================================================================
    00008
    00009 /*--------------------------------------------------------------*
    00010   Copyright (C) 2002-2003 Andras Varga
    00011
    00012   This file is distributed WITHOUT ANY WARRANTY. See the file
    00013   `license' for details on this and other legal matters.
    00014 *--------------------------------------------------------------*/
    00015
    00016 #ifndef __NEDELEMENT_H
    00017 #define __NEDELEMENT_H
    00018
    00019 #ifdef _MSC_VER
    00020 // disable tons of "identifier was truncated to '255' characters in the debug
    00021 // information" warnings that comes as bonus with using STL
    00022 #pragma warning(disable:4786)
    00023 #endif
    00024
    00025 #include <string>
    00026
    00036 class NEDElement
    00037 {
    00038   private:
    00039     int id;
    00040     std::string srcloc;
    00041     NEDElement *parent;
    00042     NEDElement *firstchild;
    00043     NEDElement *lastchild;
    00044     NEDElement *prevsibling;
    00045     NEDElement *nextsibling;
    00046     static long lastid;
    00047
    00048   protected:
    00049     static bool stringToBool(const char *s);
    00050     static const char *boolToString(bool b);
    00051     static int stringToEnum(const char *s, const char *vals[], int nums[], int n);
    00052     static const char *enumToString(int b, const char *vals[], int nums[], int n);
    00053
    00054   public:
    00057
    00061     NEDElement();
    00062
    00066     NEDElement(NEDElement *parent);
    00067
    00071     virtual ~NEDElement();
    00073
    00076
    00081     virtual const char *getTagName() const = 0;
    00082
    00087     virtual int getTagCode() const = 0;
    00088
    00092     virtual long getId() const;
    00093
    00097     virtual void setId(long id);
    00098
    00103     virtual const char *getSourceLocation() const;
    00104
    00109     virtual void setSourceLocation(const char *loc);
    00111
    00114
    00121     virtual void applyDefaults();
    00122
    00127     virtual int getNumAttributes() const = 0;
    00128
    00136     virtual const char *getAttributeName(int k) const = 0;
    00137
    00142     virtual int lookupAttribute(const char *attr) const;
    00143
    00152     virtual const char *getAttribute(int k) const = 0;
    00153
    00160     virtual const char *getAttribute(const char *attr) const;
    00161
    00170     virtual void setAttribute(int k, const char *value) = 0;
    00171
    00178     virtual void setAttribute(const char *attr, const char *value);
    00179
    00187     virtual const char *getAttributeDefault(int k) const = 0;
    00188
    00195     virtual const char *getAttributeDefault(const char *attr) const;
    00197
    00200
    00204     virtual NEDElement *getParent() const;
    00205
    00210     virtual NEDElement *getFirstChild() const;
    00211
    00216     virtual NEDElement *getLastChild() const;
    00217
    00233     virtual NEDElement *getNextSibling() const;
    00234
    00240     virtual void appendChild(NEDElement *node);
    00241
    00249     virtual void insertChildBefore(NEDElement *where, NEDElement *newnode);
    00250
    00256     virtual NEDElement *removeChild(NEDElement *node);
    00257
    00262     virtual NEDElement *getFirstChildWithTag(int tagcode) const;
    00263
    00278     virtual NEDElement *getNextSiblingWithTag(int tagcode) const;
    00279
    00283     virtual int getNumChildren() const;
    00284
    00288     virtual int getNumChildrenWithTag(int tagcode) const;
    00290 };
    00291
    00292 #endif
    00293