3 | | The pingpong sample uses a text-based configuration file for reading parameters like local endpoints to use or bootstrapping information. This information is then set e.g. in the {{{AribaModule}}} when starting up. Therefore, using a configuration file is optional, you can use your own configuration file format or hardcode such information in your code. |
| 3 | The pingpong sample uses a text-based configuration file for reading parameters like local endpoints to use or bootstrapping information. This information is then set e.g. using {{{AribaModule::setProperty}}} when starting up. Therefore, using a configuration file is optional, you can use your own configuration file format or hardcode such information in your code. |
| 4 | |
| 5 | == !AribaModule Properties == |
| 6 | |
| 7 | Currently the !AribaModule class supports two properties that can be set |
| 8 | * {{{endpoints}}} |
| 9 | * {{{bootstrap.hints}}} |
| 10 | All other information -- like node names or spovnet names are set directly using the Ariba interface (see e.g. {{{PingPong.cpp}}}). |
| 11 | |
| 12 | The {{{endpoints}}} property defines the local endpoints where Ariba opens up server instances. If you don't configure the endpoints defaults will be used. A detailed description of the endpoint format is given further down. The {{{bootstrap.hints}}} property defines bootstrapping information the node uses to find the SpoVNet instance. This can either be static nodes or automatic bootstrap modules like mDNS. Again, see further down this page for a description of the bootstrap hints format. |
| 16 | If you want to read information from a settings file, you can use the built-in {{{Configuration}}} class. To define the filename, use the |
| 17 | {{{ |
| 18 | StartupWrapper::initConfig( config ); |
| 19 | }}} |
| 20 | function, as in the {{{main.cpp}}} of the !PingPong sample. The given configuration file will be read and is accessible throughout the whole process. You can check if there is a configuration file available using |
| 21 | {{{ |
| 22 | if( Configuration::haveConfig() ) |
| 23 | }}} |
| 24 | and get a reference to the configuration singleton using |
| 25 | {{{ |
| 26 | Configuration& config = Configuration::instance(); |
| 27 | }}} |
| 28 | |
| 29 | The format of the configuration file is one item per line using |
| 30 | {{{ |
| 31 | name = value |
| 32 | }}} |
| 33 | where value can be a string, integer, or {{{true|false}}}. Reading from the configuration file is parametrized using the desired type: |
| 34 | {{{ |
| 35 | string name = config.read<string>("name"); |
| 36 | int count = config.read<int>("count"); |
| 37 | bool enable = config.read<bool>("enable"); |
| 38 | }}} |