Error in cxmlelement.h and how to use cxmlelement to read the xml file and build the module

13 views
Skip to first unread message

SHanan

unread,
Jan 8, 2018, 1:11:50 PM1/8/18
to OMNeT++ Users

I want to build three simple modules using .xml instead of .ned then build a network using these three modules.

I start with the first simple module (Firewall) but I have a problem in Firewall.cc file:
- it is give an error on #include "cxmlelement.h" and
is it correct to use cXMLElement *xmlPosture; xmlPosture = cPar("Firewall_n").xmlValue(); in initialize method to read the xml file and build the module ?

could any body advise how to start I am still new to omnet++?


the Firewall.cc is: 


#include <string.h>
#include <cxmlelement.h>
#include <omnetpp.h>
using namespace omnetpp;



class Firewall : public cSimpleModule

{

protected:

    virtual void initialize() override;

    virtual void handleMessage(cMessage *msg) override;

};

Define_Module(Firewall);

void Firewall::initialize()

{

    cXMLElement *xmlPosture;
    xmlPosture = cPar("Firewall_n").xmlValue();
   cXMLElementList Entities = xmlPostureW->getElementsByTagName("parameters");
   cXMLElementList Entities = xmlPostureW->getElementsByTagName("gates");


}

void Firewall::handleMessage(cMessage *msg)

{ }


the Firewall_n.xml  is: 


<?xml version="1.0" encoding="ISO-8859-1"?>

<ned-file filename="C:/omnet/omnetpp-5.2/samples/test1/Firewall.ned">
<comment locid="banner" content="&#10;&#10;&#10;&#10;&#10;"/>
<simple-module name="Firewall">
    <comment locid="trailing" content="&#10;&#10;"/>
    <parameters>
        <param type="int" is-volatile="true" name="number_of_cpu"/>
        <param type="string" is-volatile="true" name="memory_type"/>
        <param type="int" is-volatile="true" name="memory_size">
            <property name="unit">
                <property-key>
                    <literal type="spec" text="GiB" value="GiB"/>
                </property-key>
            </property>
        </param>
        <param type="int" is-volatile="true" name="disk_size">
            <property name="unit">
                <property-key>
                    <literal type="spec" text="GiB" value="GiB"/>
                </property-key>
            </property>
        </param>
        <property name="display">
            <property-key>
                <literal type="string" text="&quot;i=device/firewall&quot;" value="i=device/firewall"/>
            </property-key>
        </property>
    </parameters>
    <gates>
        <gate name="out" type="output"/>
    </gates>
</simple-module>


Attila Török

unread,
Jan 9, 2018, 2:32:04 PM1/9/18
to OMNeT++ Users
You don't need to #include <cxmlelement.h>, because it is already included by <omnetpp.h>.
(It would be <omnetpp/cxmlelement.h> anyways.)

--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.

SHanan

unread,
Jan 9, 2018, 2:35:11 PM1/9/18
to OMNeT++ Users
Yes I reached to this point  and it is working now . 
thank you
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages