ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
ConfigReader Module

This Module provides the following features:

  • read values from an xml config file to have them available at server initialization,
  • expose above values as process variables; these may connect to other ApplicationCore modules if needed.

Example usage

  • Each server comes with a built-in config reader that will look for the file <servername>-config.xml. So for the server below:
    namespace ctk = ChimeratK
    struct Server : public ctk::Application {
    Server() : Application("testserver") {}
    ~Server() { shutdown(); }
    TestModule testModule{this, "TestModule", "The test module"};
    };
    void shutdown() override
    This will remove the global pointer to the instance and allows creating another instance afterwards.
    InvalidityTracer application module.
  • Values from testserver-config.xml can be accessed at server startup:
    Server::Server() {
    auto config_var = appConfig().get<int8_t>("module1/var8");
    auto config_arr = appConfig().get<std::vector<int8>>("module1/submodule/intArray");
    // ...
    }

Configuration will be published as process variables, according to the hierarchy constructed in the configuration file.

XML file structure

  • A valid configuration file may look like:
      <configuration>
        <variable name="var8" type="int8" value="-123"/>
        <variable name="bool" type="boolean" value="true"/>
        <module name="module1">
          <variable name="var8" type="int8" value="-123"/>
          <module name="submodule">
              <variable name="intArray" type="int32">
              <value i="0" v="10"/>
              <value i="1" v="9"/>
              <value i="2" v="8"/>
              <value i="7" v="3"/>
              <value i="8" v="2"/>
              <value i="9" v="1"/>
              <value i="3" v="7"/>
              <value i="4" v="6"/>
              <value i="5" v="5"/>
              <value i="6" v="4"/>
           </variable>
          </module>
        </module>
      </configuration>