Search code examples
omnet++

The usage of “@class” keyword in Omnet++


I was trying to understand the usage of "@class" keyword in Omnet++, what is the "@class" keyword uses in Omnet++? What is the use of the input parameter of @class? If I don't use of @class keyword, what problems are occurred? For example, in the following code:

simple UDPBasicAppNew extends UDPBasicApp
{
    parameters:

        @class(UDPBasicAppNew);
        int numberOfMessages = default(10000000);
}

If the line "@class(UDPBasicAppNew);" is removed, what problems are occurred?

Thanks in advance


Solution

  • According to OMNeT++ Simulation Manual:

    IMPORTANT
    When you extend a simple module type both in NED and in C++, you must use the @class property to tell NED to use the new C++ class -- otherwise the new module type inherits the C++ class of the base!

    It means that if one declares UDPBasicAppNew as:

    simple UDPBasicAppNew extends UDPBasicApp {
      parameters:
        int numberOfMessages;
    }
    

    the C++ class named UDPBasicApp will be used for UDPBasicAppNew.

    However, if one declares UDPBasicAppNew this way:

    simple UDPBasicAppNew extends UDPBasicApp {
      parameters:
        @class(UDPBasicAppNew);
        int numberOfMessages;
    }
    

    the C++ class named UDPBasicAppNew will be used for UDPBasicAppNew.