Class CAppSettings#

Inheritance Relationships#

Base Types#

Class Documentation#

class CAppSettings : public sdv::IInterfaceAccess, public sdv::app::IAppContext, public sdv::IAttributes#

Application settings class.

The application settings class is responsible for interpretation of the initial application startup configuration and reading and writing the application main settings. The startup configuration is a string using the TOML format and is defined as follows:

# Optional use of customized log handler
[LogHandler]
Class = ""      # Component class name of a custom logger (optional)
Path = ""       # Component module path of a custom logger (optional)
Tag = ""        # Program tag to use instead of the name SDV_LOG_<pid>
Filter = ""     # Lowest severity filter to use when logging (Trace, Debug, Info, Warning, Error, Fatal). Default severity
                # level filter is Info (meaning Debug and Trace messages are not being stored).
ViewFilter = "" # Lowest severity filter to use when logging (Trace, Debug, Info, Warning, Error, Fatal). Default severity
                # level filter is Error (meaning Debug, Trace, Info and Warning messages are not being shown).

# Application behavior definition
# Mode = "Standalone"  (default) app->no RPC + core services + additional configurations allowed
# Mode = "External"    app->RPC client only + local services + target service(s) --> connection information through listener
# Mode = "Isolated"    app->RPC client only + local services + target service(s) --> connection information needed
# Mode = "Main"        app->RPC server + core services --> access key needed
# Mode = "Essential"   app->local services + additional configurations allowed
# Mode = "Maintenance" app->RPC client only + local services + maintenance service --> connection information needed + access key
# Instance = 1234
[Application]
Mode = "Main"
Instance = 1234         # Optional instance ID to be used with main and isolated applications. Has no influence on other
                        # applications. Default instance ID is 1000. The connection listener is using the instance ID to allow
                        # connections from an external application to the main application. Furthermore, the instance ID is
                        # used to locate the installation of SDV components. The location of the SDV components is relative to
                        # the executable (unless a target directory is supplied) added with the instance and the installations:
                        # &lt;exe_path&gt;/&lt;instance&gt;/&lt;installation&gt;
InstallDir = "./test"   # Optional custom installation directory to be used with main and isolated applications. Has no
                        # influence on other applications. The default location for installations is the location of the
                        # executable. Specifying a different directory will change the location of installations to
                        # &lt;install_directory&gt;/&lt;instance&gt;/&lt;installation&gt;
                        # NOTE The directory of the core library and the directory of the running executable are always added
                        # to the system if they contain an installation manifest.

# Optional configuration that should be loaded (only for local applications).
Config = "abc.toml"

#Console output
[Console]
Report = "Silent"       # Either "Silent", "Normal" or "Verbose" for no, normal or extensive messages.

# Search directories

Todo:

Add config ignore list (e.g. platform.toml, vehicle_ifc.toml and vehicle_abstract.toml).

Add dedicated config (rather than standard config) as startup param.

The settings file is a TOML file with the following structure:

[Settings]
Version = 100

# The system configuration is divided into:
#  platform config     - containing all the components needed to interact with the OS,
#                        middleware, vehicle bus, Ethernet.
#  vehicle interface   - containing the vehicle bus interpretation components like data link
#                        based on DBC and devices for their abstraction.
#  vehicle abstraction - containing the vehicle abstraction services
# The configuration files are loaded exactly in that order, allowing the vehicle interface to
# depend on the platform and the vehicle abstraction to depend on the vehicle interface.
# The configurations are loaded if the PlatformConfig, VehIfcConfig and VehAbstrConfig keywords
# are present and describe a valid configuration file.
# A relative path is relative to the installation directory (being "exe_location/instance_id").
#
# Example:
#   PlatformConfig = "platform.toml"
#   VehIfcConfig = "vehicle_ifc.toml"
#   VehAbstrConfig = "vehicle_abstract.toml"
#
PlatformConfig = ""
VehIfcConfig = ""
VehAbstrConfig = ""

# The application config contains the configuration file that can be updated when services and
# apps are being added to the system (or being removed from the system). Load the application
# config by providing the "AppConfig" keyword as a string value. A relative path is relative to
# the installation directory (being "exe_location/instance_id").
#
# Example
#   AppConfig = "app_config.toml"
AppConfig = ""

Public Types

enum class EConfigType#

Configuration type.

Values:

enumerator platform_config#

Contains the platform configuration.

enumerator vehicle_interface_config#

Contains the vehicle interface configuration.

enumerator vehicle_abstraction_config#

Contains the vehicle abstraction configuration.

enumerator user_config#

Contains the user configuration.

Public Functions

CAppSettings()#

Constructor.

~CAppSettings()#

Destructor.

bool ProcessAppStartupConfig(const sdv::u8string &rssConfig)#

Process the application starrtup configuration.

Parameters:

rssConfig[in] Reference to the configuration content (TOML format).

Returns:

Returns ‘true’ when processing was successful; false when not.

bool LoadSettingsFile()#

Load the application settings file.

Remark

When there is no settings file, this is not an error. Default settings will be assumed.

Attention

Only works if the application is running in main, isolation or maintenance mode.

Returns:

Returns whether the loading was successful.

bool SaveSettingsFile()#

Save the application settings file (or create when not existing yet).

Attention

Only works if the application is running in main, isolation or maintenance mode.

Returns:

Returns whether the saving was successful.

bool IsMainApplication() const#

Return whether the current application is the main application.

Returns:

Returns ‘true’ when the current application is the main application; otherwise returns ‘false’.

bool IsIsolatedApplication() const#

Return whether the current application is an isolated application.

Returns:

Returns ‘true’ when the current application is an isolated application; otherwise returns ‘false’.

bool IsStandaloneApplication() const#

Return whether the current application is a standalone application.

Returns:

Returns ‘true’ when the current application is a standalone application; otherwise returns ‘false’.

bool IsEssentialApplication() const#

Return whether the current application is an essential application.

Returns:

Returns ‘true’ when the current application is an essential application; otherwise returns ‘false’.

bool IsMaintenanceApplication() const#

Return whether the current application is a maintenance application.

Returns:

Returns ‘true’ when the current application is a maintenance application; otherwise returns ‘false’.

bool IsExternalApplication() const#

Return whether the current application is an external application.

Returns:

Returns ‘true’ when the current application is an external application; otherwise returns ‘false’.

virtual sdv::app::EAppContext GetContextType() const override#

Return the application context mode. Overload of sdv::app::IAppContext::GetContextType.

Returns:

The context mode.

virtual uint32_t GetInstanceID() const override#

Return the core instance ID. Overload of sdv::app::IAppContext::GetContextType.

Get the instance. If not otherwise specified, the current instance depends on whether the application is running as main or isolated application, in which case the instance is 1000. In all other cases the instance is 0. An instance ID can be supplied through the app startup configuration.

Returns:

The core instance ID.

virtual uint32_t GetRetries() const override#

Return the number of retries to establish a connection. Overload of sdv::app::IAppContext::GetRetries.

Returns:

Number of retries.

std::string GetLoggerClass() const#

Get the class name of a logger service, if specified in the application startup configuration.

Returns:

The logger class name.

std::filesystem::path GetLoggerModulePath() const#

Get the logger service module path, if specified in the application startup configuration.

Returns:

The logger module path.

std::string GetLoggerProgramTag() const#

Get the logger program tag, if specified in the application startup configuration.

Returns:

The logger program tag.

sdv::core::ELogSeverity GetLoggerSeverityFilter() const#

Get the logger severity filter, if specified in the application startup configuration.

Returns:

The logger severity filter.

sdv::core::ELogSeverity GetConsoleSeverityFilter() const#

Get the console reporting severity file, if specified in the application startup configuration.

Returns:

The console reporting severity filter value.

bool IsConsoleSilent() const#

Should the console output be silent?

Returns:

Returns whether the console output is silent.

bool IsConsoleVerbose() const#

Should the console output be verbose?

Returns:

Returns whether the verbose console output is activated.

std::filesystem::path GetRootDir() const#

Get the root directory for the application.

Remark

Is only valid when used in main, isolated and maintenance applications.

Returns:

The location of root directory.

std::filesystem::path GetInstallDir() const#

Get the installation directory of user components (root directory / instance ID).

Remark

Is only valid when used in main, isolated and maintenance applications.

Returns:

The location of the installation director.

std::vector<std::filesystem::path> GetSystemConfigPaths() const#

Get a vector with the system configuration paths (relative to the installation directory) as specified in the settings file.

Returns:

The vector of system configuration paths.

std::filesystem::path GetConfigPath(EConfigType eType) const#

Get the stored or default configuration path name.

Attention

Setting a path is only valid when running as main application.

Returns:

The path name dependent on the configuration type. If no path name was configured, the default path name is returned.

bool EnableConfig(EConfigType eType)#

Enable a configuration file in the application settings.

Attention

The configuration file needs to be located at the root directory of the instance installation.

Attention

Setting a path is only valid when running as main application.

Parameters:

eType[in] The configuration type to set the path for.

Returns:

Returns ‘true’ when adding the config file path was successful (or when the path already exists in the settings); otherwise returns ‘false’.

bool DisableConfig(EConfigType eType)#

Disable and remove a configuration file from the application settings.

Attention

The configuration file needs to be located at the root directory of the instance installation.

Attention

Removing a psth is only valid when running as main application.

Parameters:

eType[in] The configuration type to remove the path from.

Returns:

Returns ‘true’ when the removal was successful.

std::filesystem::path GetUserConfigPath() const#

Get the path to the user copnfiguration (relative to the installation directory) as specified in the settings file.

Returns:

Path to the user configuration.

bool SetUserConfigPath(const std::filesystem::path &rpathConfig)#

Set the user configuration file into the application settings. If a user configuration file is stored already in the settings file, the configuration file name is replaced by the new configuration file name.

Remark

Setting the user config path is only valid for local applications. For server application, the path is managed by enabling the configuration.

Parameters:

rpathConfig[in] Reference to the path containing the configuration file name.

Returns:

Returns ‘true’ when setting the config file path was successful; otherwise returns ‘false’.

bool RemoveUserConfigPath()#

Remove the user configuration file from the application settings.

Attention

Removing the path is only valid when running as main application.

Returns:

Returns ‘true’ when the removal was successful.

virtual sdv::sequence<sdv::u8string> GetNames() const override#

Get a sequence with the available attribute names. Overload of sdv::IAttributes::GetNames.

Returns:

The sequence of attribute names.

virtual sdv::any_t Get(const sdv::u8string &ssAttribute) const override#

Get the attribute value. Overload of sdv::IAttributes::Get.

Parameters:

ssAttribute[in] Name of the attribute.

Returns:

The attribute value or an empty any-value if the attribute wasn’t found or didn’t have a value.

virtual bool Set(const sdv::u8string &ssAttribute, sdv::any_t anyAttribute) override#

Set the attribute value. Overload of sdv::IAttributes::Set.

Parameters:
  • ssAttribute[in] Name of the attribute.

  • anyAttribute[in] Attribute value to set.

Returns:

Returns ‘true’ when setting the attribute was successful or ‘false’ when the attribute was not found or the attribute is read-only or another error occurred.

virtual uint32_t GetFlags(const sdv::u8string &ssAttribute) const override#

Get the attribute flags belonging to a certain attribute. Overload of sdv::IAttributes::GetFlags.

Parameters:

ssAttribute[in] Name of the attribute.

Returns:

Returns the attribute flags (zero or more EAttributeFlags flags) or 0 when the attribute could not be found.

void Reset()#

Reset the settings after a shutdown.