Skip to content

Commit

Permalink
Updated docu for config and example.
Browse files Browse the repository at this point in the history
  • Loading branch information
Peguen committed Apr 26, 2024
1 parent aca5d69 commit 557637a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
20 changes: 12 additions & 8 deletions doc/rst/configuration/runtime_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,41 @@ The corresponding structure reflects the configuration file (:ref:`configuration
Custom types
============

In order to exclude configuration errors, custom datatypes for IP addresses and sizes are introduced.
In order to exclude configuration errors, custom datatypes for IP addresses and sizes (constrained integer) are introduced.

For assigning an ip address simply assign a string with the desired address.
Decimal and hexadecimal format is supported.
In case the ip address is not valid, the type will throw a std::invalid_argument exception.

You can use the ip address like a normal string object. For example:
The ip address can be used like a normal string object. For example:

.. code-block:: c++

eCAL::Config::IpAddressV4 ip_address = std::string("192.168.7.1"); // in hex: "C0.A8.7.1"
std::cout << ip_address << "\n";

Sizes are specified with a minimum (default: 0), step (default: 1) and maximum (default: maximum of int) value.
ConstrainedInteger are specified with a minimum (default: 0), step (default: 1) and maximum (default: maximum of int) value.
In case the assigned value does not fit into the specified limitation, the type will throw a std::invalid_argument exception.

You can use the size object like a normal integer.
The size object can be used like a normal integer.

.. code-block:: c++

eCAL::Config::LimitSize<1024, 512, 8192> size_4mb = 1024 + 6 * 512;
eCAL::Config::ConstrainedInteger<1024, 512, 8192> size_4mb = 1024 + 6 * 512;
std::cout << size_4mb << "\n";

For specifying sizes in the ecal configuration object, refer to the .ini file or "ecal/types/ecal_config_types.h" for the limitations.

Initialization of the configuration
===================================

The configuration will be first initialized with the default .ini file found in the system.
In case the .ini to use is specified vial command line parameter, this one is chosen instead.
If it cannot find any .ini file, default values will be used for the first initialization of the configuration.
The configuration will be first initialized with the default values specified by eCAL.
If you want to use the systems eCAL .ini file, call the InitConfigWithDefaultIni() function of the config object.

In case the .ini to use is specified via command line parameter, this one is chosen instead.
The object will throw an error, in case the specified .ini file cannot be found.

It is also possible to specify the .ini by calling the function InitConfig(std::string _ini_path) of the config object.

* |fa-file-alt| :file:`hello_config/main.cpp`:

Expand Down
6 changes: 6 additions & 0 deletions doc/rst/configuration/src/hello_config/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ int main(int argc, char** argv)
// Create a configuration object with the command line arguments
eCAL::Config::eCALConfig custom_config(argc, argv);

// Use the .ini file of the system ...
custom_config.InitConfigWithDefaultIni();

// .. or specify an own .ini file to use
custom_conig.InitConfig("C:\\eCAL_local.ini");

// Set the values in a try/catch block, as wrong configuration leads to exceptions
try
{
Expand Down

0 comments on commit 557637a

Please sign in to comment.