Download OMNeT++
Transcript
OMNeT++ Manual – Customization and Embedding
4. Add an entry to omnetpp.ini to tell Envir use your class instead of the default one. For RNGs, this
setting is rng-class in the [General] section.
Ini file entries that allow you to select your plugin classes are configuration-class, schedulerclass, rng-class, outputvectormanager-class, outputscalarmanager-class and snapshotmanagerclass, documented in section 8.2.6.
How plugin classes can access the configuration
The configuration is available to plugin classes via the config() method of cEnvir, which returns a
pointer to the configuration object (cConfiguration). This enables plugin classes to have their own
config entries.
An example which reads the parsim-debug boolean entry from the [General] section, with true as
default:
bool debug = ev.config()->getAsBool("General", "parsim-debug", true);
Startup sequence for the configuration plugin
For the configuration plugin, the startup sequence is the following (see cEnvir::setup() in the source
code):
1. First, omnetpp.ini (or the ini file(s) specified via the "-f" command-line option) are read.
2. Shared libraries in [General]/load-libs are loaded. (Also the ones specified with the "-l" commandline option.)
3. [General]/configuration-class is examined, and if it is present, a configuration object of the
given class is instantiated. The configuration object may read further entries from the ini file (e.g.
database connect parameters, or XML file name).
4. The original omnetpp.ini cInifile configuration object is deleted. No other settings are taken
from it.
5. [General]/load-libs from the new configuration object is processed.
6. Then everything goes on as normally, using the new configuration object.
13.5.4
Implementation of the user interface: simulation applications
The base class for simulation application is TOmnetApp. Specific user interfaces such as TCmdenv, TOmnetTkApp are derived from TOmnetApp.
TOmnetApp’s member functions are almost all virtual.
• Some of them implement the cEnvir functions (described in the previous section)
• Others implement the common part of all user interfaces (for example: reading options from the
configuration files; making the options effective within the simulation kernel)
• The run() function is pure virtual (it is different for each user interface).
TOmnetApp’s data members:
• a pointer to the object holding configuration file contents (type cInifile);
217