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.
The configuration file is a TOML file with the following format:
[Configuration] Version = 100 # Configuration file version. [[Component]] Path = "my_module.sdv # Relative to the executable or absolute path to the module - not used for main and isolated # applications since the components must be installed. Class = "MyComponent" # Class name of the component. Name = "MyPersonalComponent" # Optional instance name of the component. If not provided, the name will automatically be the # default name of the component or if not available the class name of the component. AttributeXYZ = 123 # Additional settings for the component provided during initialization. [[Component]] Class = "MyComponent2" # Class name of the component - if also present in "my_module.sdv" doesn't need additional # 'Path' value. The component name is taken from the default name of the component. [[Component]] Class = "MyComponent" # Class name of the component; class is the same as before. Name = "MyPersonalComponent2" # Specific name identifying another instance of the component. [[Module]] Path = "my_other_module.sdv # Relative to the executable or absolute path to the module - not used for main and isolated # applications since the components must be installed. This path might contain components not # started, but known by the repository (utilities).
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 the installation manifests for core, executable and user components. Main and isolated applications only.
- Returns:
Returns ‘true when successful; ‘false’ when not.
-
void UnloadInstallatonManifests()#
Unload all manifest during shutdown.
-
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; ‘false’ otherwise.
-
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.
The configuration baseline determines what belongs to the current configuration. Any object being added after this baseline will be stored in a configuration file.
-
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<CInstallManifest::SComponent> 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. For main and isolated applications. The order of checking the installation manifest is core-manifest, manifest in executable directory and manifest in supplied installation directory.
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 manifest.