Class CAppControl#

Inheritance Relationships#

Base Types#

Class Documentation#

class CAppControl : public sdv::IInterfaceAccess, public sdv::app::IAppContext, public sdv::app::IAppControl, public sdv::app::IAppOperation, public sdv::app::IAppShutdownRequest, public sdv::IAttributes#

Application control class.

The application control class is responsible for the startup and shutdown of the system. Since the system is (re-)used in many applications, the startup behavior can be determined by the provided configuration as string as argument to the startup function. The configuration uses 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 (not for maintenance and isolated applications). This overrides the application
# config from the settings (only main application). Automatic saving the configuration is not supported.
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.

Public Functions

CAppControl()#

Constructor.

~CAppControl()#

Destructor.

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.

Returns:

The instance ID.

virtual uint32_t GetRetries() const override#

Return the number of retries to establish a connection.

Returns:

Number of retries.

virtual bool Startup(const sdv::u8string &ssConfig, IInterfaceAccess *pEventHandler) override#

Start the application. Overload of sdv::app::IAppControl::Startup.

The core will prepare for an application start based on the provided configuration. Per default, the application will be in running mode after successful startup.

Parameters:
  • ssConfig[in] String containing the configuration to be used by the core during startup. This configuration is optional. If not provided the application runs as standalone application without any RPC support.

  • pEventHandler[in] Pointer to the event handler receiving application events. For the handler to receive events, the handler needs to expose the IAppEvent interface. This pointer is optionally and can be NULL.

Returns:

Returns ‘true’ on successful start-up and ‘false’ on failed startup.

virtual void RunLoop() override#

Running loop until shutdown request is triggered.

virtual void Shutdown(bool bForce) override#

Initiate a shutdown of the application. Overload of sdv::app::IAppControl::Shutdown.

The objects will be called to shutdown allowing them to clean up and gracefully shutdown. If, for some reason, the object cannot shut down (e.g. pointers are still in use or threads are not finalized), the object will be kept alive and the application state will stay in shutting-down-state. In that case the exception is called. A new call to the shutdown function using the force-flag might force a shutdown. Alternatively the application can wait until the application state changes to not-started.

Remark

Application shutdown is only possible when all components are released.

Parameters:

bForce[in] When set, forces an application shutdown. This might result in loss of data and should only be used as a last resort.

virtual void RequestShutdown() override#

Request shutdown. Overload of sdv::app::IAppShutdownRequest::RequestShutdown.

virtual sdv::app::EAppOperationState GetOperationState() const override#

Get the current operation state. This information is also supplied through the event handler function. Overload of sdv::app::IAppOperation::GetOperationState.

Returns:

Returns the operation state of the application.

uint32_t GetInstance() const#

Get the current running instance.

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. A dedicated instance can be supplied through the app control.

Returns:

The instance number.

virtual void SetConfigMode() override#

Switch from running mode to the configuration mode. Overload of sdv::app::IAppOperation::SetConfigMode.

virtual void SetRunningMode() override#

Switch from the configuration mode to the running mode. Overload of sdv::app::IAppOperation::SetRunningMode.

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.

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

Get the installation directory of user components.

Returns:

The location of the user components. Only is valid when used in main and isolated applications.

void DisableAutoConfigUpdate()#

Disable the current auto update feature if enabled in the system settings.

void EnableAutoConfigUpdate()#

Enable the current auto update feature if enabled in the system settings.

void TriggerConfigUpdate()#

Trigger the config update if enabled in the system settings.

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.