Class CAppConfig#
Defined in File app_config.h
Nested Relationships#
Nested Types#
Inheritance Relationships#
Base Types#
public sdv::IInterfaceAccess(Struct IInterfaceAccess)public sdv::core::IConfig(Struct IConfig)public sdv::installation::IAppInstall(Struct IAppInstall)
Class Documentation#
-
class CAppConfig : public sdv::IInterfaceAccess, public sdv::core::IConfig, public sdv::installation::IAppInstall#
Application configuration service.
In the configuration system objects, devices, basic services, complex services and apps are defined and will be started suring the load process. The objects are loaded in this order (system objects first, apps last) unless dependencies define a different order. Utilities, proxy and stub objects are not specified here, since they can be started ‘on-the-fly’ if needed. Loading a configuration extends the current configuration. Saving a configuration includes all objects since the last configuration not including the components present before the last load.
For the main application there are several configuration files:
Platform configuration (OS support, middleware support, vehicle bus and Ethernet interface configuration - system objects)
Vehicle interface configuration (DBC, port assignments - devices)
Vehicle abstraction interface configuration (basic services)
Application configuration (complex services and applications)
If components are added dynamically (or removed dynamically) they are added to and removed from the application configuration. The configuration files are located in the installation directory.
TODO: Add additional interface function: set component operation mode - config, running… When switching to config mode, switch the apps, complex services, basic services, devices and system objects (in that order) to config mode. When switching back to running mode, enable running mode for the system objects, devices, base services, complex services and apps (in that order).
Public Functions
-
CAppConfig() = default#
-
bool LoadInstallationManifests()#
Load/reload the installation manifests for core, executable and user components.
The installation manifests contain the module and component class information that is used for finding component classes. Standalone applications only load the core manifest. Server applications additionally load the manifest according to their instance ID.
- Returns:
Returns ‘true when successful; ‘false’ when not.
-
void UnloadInstallatonManifests()#
Unload all manifest during shutdown.
-
bool LoadAppConfigs()#
Load the configuration files listed in the settings.
Load the configuration files stored in the settings file (for server applications) or provided through the startup configuration (for local applications). For server applications, the system configurations are loaded and provided to the repository for starting the components. After the system configuration, the user configuration is loaded. The module section and path information in the configuration files is ignored (if available at all) for server applications. For local applications there are no system configurations to load and only the user configuration is loaded which was provided during startup. The loading of the modules precedes the loading and starting of the components.
- Returns:
Returns ‘true’ when the loading was successful. ‘False’ when not.
-
void SaveAppConfigs()#
Save the configuration files listed in the settings.
Remark
When running in maintenance mode, all configurations are updated. In all other modes, only the user application config is updated.
-
virtual sdv::core::EConfigProcessResult ProcessConfig(const sdv::u8string &ssContent) override#
Process the provided configuration by loading modules and creating objects/stubs/proxies defined in the configuration string. Processing a configuration resets the baseline before processing. Overload of sdv::core::IConfig::ProcessConfig.
- Attention
Configuration changes can only occur when the system is in configuration mode.
- Parameters:
ssContent – [in] The contents of the configuration file (TOML).
- Returns:
Returns a config process result enum value.
-
virtual sdv::core::EConfigProcessResult LoadConfig(const sdv::u8string &ssConfigPath) override#
Read file pointed to by the provided file path and load modules and create objects/stubs/proxies as defined in the configuration file. Loading a configuration resets the baseline before processing. Overload of sdv::core::IConfig::LoadConfig.
- Attention
Configuration changes can only occur when the system is in configuration mode.
- Parameters:
ssConfigPath – [in] Path to the file containing the configuration (TOML). The path can be an absolute as well as a relative path. In case a relative path is provided, the current directory is searched as well as all directories supplied through the AddConfigSearchDir function.
- Returns:
Returns a config process result enum value.
-
virtual bool SaveConfig(const sdv::u8string &ssConfigPath) const override#
Save a configuration file pointed to by the provided file path. All components are saved that were added after the last baseline with the configuration specific settings. Overload of sdv::core::IConfig::SaveConfig.
- Attention
Configuration changes can only occur when the system is in configuration mode.
- Parameters:
ssConfigPath – [in] Path to the file containing the configuration (TOML). The path can be an absolute as well as a relative path. In case a relative path is provided, the configuration is stored relative to the executable directory.
- Returns:
Returns ‘true’ on success (or no changes detected); ‘false’ otherwise.
-
virtual sdv::u8string GenerateConfigString() const override#
Generate the configuration TOML string. Overload of sdv::core::IConfig::GenerateConfigString.
- Returns:
The generated configuration string.
-
virtual void CloseConfig() override#
Close the current configuration. Overload of sdv::core::IConfig::CloseConfig.
This will close und unload the components and modules from the current configuration as well as dependent components that builds on top of the components being closed. Components that the current configuration depends on are not closed.
-
virtual bool AddConfigSearchDir(const sdv::u8string &ssDir) override#
Add a search path to a folder where a config file can be found. Overload of sdv::core::IConfig::AddDirectorySearchDir.
- Parameters:
ssDir – [in] Relative or absolute path to an existing folder.
- Returns:
Returns ‘true’ on success; ‘false’ otherwise.
-
virtual void ResetConfigBaseline() override#
Reset the configuration baseline. Overload of sdv::core::IConfig::ResetConfigBaseline.
The configuration baseline determines what belongs to the current configuration. Any object being added after this baseline will be stored in a configuration file.
Remark
When running as server, the config baseline is limited to the user configuration, which only consists of complex services. For standalone setups, the configuration can also contain basic services and devices.
-
virtual bool Install(const sdv::u8string &ssInstallName, const sdv::sequence<sdv::installation::SFileDesc> &seqFiles) override#
Make an installation onto the system. Overload of sdv::installation::IAppInstall::Install.
Make an installation with from component modules and supporting files. At least one component module must be provided for this installation to be successful (component attribute flag must be set). Components are only installed, not activated.
Remark
The system needs to run in configuration mode.
- Parameters:
ssInstallName – [in] Name of the installation. Must be unique to the system.
seqFiles – [in] Files belonging to the installation. This could be component modules as well as supporting files.
- Returns:
Returns whether the installation was successful - installation name was unique and at least one loadable component was provided.
-
virtual bool Update(const sdv::u8string &ssInstallName, const sdv::sequence<sdv::installation::SFileDesc> &seqFiles) override#
Update an installation. Overload of sdv::installation::IAppInstall::Update.
Stops a component if the component is running, makes an update and if the component was running, starts the component again.
- Todo:
: Currently limited to complex services only.
Remark
The system needs to run in configuration mode.
- Parameters:
ssInstallName – [in] Name of the installation. Must be unique to the system.
seqFiles – [in] Files belonging to the installation. This could be component modules as well as supporting files.
- Returns:
Returns whether the installation was successful - installation name was unique and at least one loadable component was provided.
-
virtual bool Uninstall(const sdv::u8string &ssInstallName) override#
Uninstall of a previous installation. Overload of sdv::installation::IAppInstall::Uninstall.
Stops a component if the component is running and removes the files and modules.
- Todo:
: Currently limited to complex services only.
Remark
The system needs to run in configuration mode.
- Parameters:
ssInstallName – [in] Installation name.
- Returns:
Returns whether the uninstallation was successful.
-
virtual sdv::sequence<sdv::u8string> GetInstallations() const override#
Get a sequence of installations. Overload of sdv::installation::IAppInstall::GetInstallations.
- Returns:
The sequence with installations.
-
virtual sdv::sequence<sdv::installation::SFileDesc> GetInstallationFiles(const sdv::u8string &ssInstallName) const override#
Get the installed files from the installation. Overload of sdv::installation::IAppInstall::GetInstallationFiles.
- Parameters:
ssInstallName – [in] The installation to get the files for.
- Returns:
Sequence containing the file structures without the binary file content.
-
std::filesystem::path FindInstalledModule(const std::filesystem::path &rpathRelModule)#
Find the module stored in the installation manifest (core, exe or user installations).
- Parameters:
rpathRelModule – [in] Reference to the path containing the relative path to a module.
- Returns:
Returns the full path if the module was found or an empty path when not.
-
std::string FindInstalledModuleManifest(const std::filesystem::path &rpathRelModule)#
Find the module stored in the installation manifest (core, exe or user installations).
- Parameters:
rpathRelModule – [in] Reference to the path containing the relative path to a module.
- Returns:
Returns the module manifest if the module was found or an empty string when not.
-
std::optional<sdv::SClassInfo> FindInstalledComponent(const std::string &rssClass) const#
Search for the installed component with the specific class name.
Find the first component containing a class with the specified name. The order of checking the installation manifest is core-manifest, manifest in executable directory and manifest in supplied installation directory. For standalone applications only the core and executable manifests are checked.
Remark
Components of system objects specified in the user installation are not returned.
- Parameters:
rssClass – [in] Reference to the class that should be searched for. The class is compared to the class name and the default name in the manifest.
- Returns:
Optionally returns the component class information.
-
bool RemoveFromConfig(const CInstallManifest &rManifest)#
Remove any components that are mentioned in the manifest from the configurations available in the settings file.
Remark
Only available when running as maintenance or main application. If running as main application limited to removal from the user configuration only.
- Parameters:
rManifest – [in] Reference to the manifest file containing the installation components.
- Returns:
Returns whether the removal was successful (also when there was nothing to remove) or not successful (when the components were in one of the system configurations and the application is not running as maintenance application).