mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-07-01 21:25:11 +00:00
Update sdv_packager (#6)
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_ANY_H
|
||||
#define SDV_ANY_H
|
||||
|
||||
@@ -93,62 +106,148 @@ namespace sdv
|
||||
|
||||
/**
|
||||
* @brief Assignment constructor.
|
||||
* @param[in] tVal The value to assign.
|
||||
* @param[in] bVal The value to assign.
|
||||
*/
|
||||
any_t(bool bVal);
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment constructor.
|
||||
* @param[in] iVal The value to assign.
|
||||
*/
|
||||
any_t(int8_t iVal);
|
||||
any_t(int16_t iVal);
|
||||
any_t(int32_t iVal);
|
||||
#ifdef _WIN32
|
||||
any_t(long iVal);
|
||||
#endif
|
||||
any_t(int64_t iVal);
|
||||
#ifdef __linux__
|
||||
any_t(long long int iVal);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment constructor.
|
||||
* @param[in] uiVal The value to assign.
|
||||
*/
|
||||
any_t(uint8_t uiVal);
|
||||
any_t(uint16_t uiVal);
|
||||
any_t(uint32_t uiVal);
|
||||
#ifdef _WIN32
|
||||
any_t(unsigned long uiVal);
|
||||
#endif
|
||||
any_t(uint64_t uiVal);
|
||||
#ifdef __linux__
|
||||
any_t(unsigned long long int uiVal);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment constructor.
|
||||
* @param[in] cVal The value to assign.
|
||||
*/
|
||||
any_t(char cVal);
|
||||
any_t(char16_t cVal);
|
||||
any_t(char32_t cVal);
|
||||
any_t(wchar_t cVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment constructor.
|
||||
* @param[in] fVal The value to assign.
|
||||
*/
|
||||
any_t(float fVal);
|
||||
any_t(double fVal);
|
||||
any_t(long double fVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
template <typename TType>
|
||||
explicit any_t(TType tVal);
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief SDV string constructors.
|
||||
* @param[in] rssVal Reference to the string object.
|
||||
*/
|
||||
explicit any_t(const string& rssVal);
|
||||
explicit any_t(const u8string& rssVal);
|
||||
explicit any_t(const u16string& rssVal);
|
||||
explicit any_t(const u32string& rssVal);
|
||||
explicit any_t(const wstring& rssVal);
|
||||
any_t(const string& rssVal);
|
||||
any_t(const u8string& rssVal);
|
||||
any_t(const u16string& rssVal);
|
||||
any_t(const u32string& rssVal);
|
||||
any_t(const wstring& rssVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief C-style string constructors.
|
||||
* @param[in] sz Zero terminated string.
|
||||
* @param[in] szVal Zero terminated string.
|
||||
*/
|
||||
any_t(const char* sz);
|
||||
|
||||
any_t(const char* szVal);
|
||||
any_t(const char16_t* szVal);
|
||||
any_t(const char32_t* szVal);
|
||||
any_t(const wchar_t* szVal);
|
||||
/**
|
||||
* @brief C-style string constructors.
|
||||
* @param[in] sz Zero terminated string.
|
||||
* @}
|
||||
*/
|
||||
any_t(const char16_t* sz);
|
||||
|
||||
/**
|
||||
* @brief C-style string constructors.
|
||||
* @param[in] sz Zero terminated string.
|
||||
*/
|
||||
any_t(const char32_t* sz);
|
||||
|
||||
/**
|
||||
* @brief C-style string constructors.
|
||||
* @param[in] sz Zero terminated string.
|
||||
*/
|
||||
any_t(const wchar_t* sz);
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief STD string constructors.
|
||||
* @param[in] rssVal Reference to the string object.
|
||||
*/
|
||||
explicit any_t(const std::string& rssVal);
|
||||
explicit any_t(const std::u16string& rssVal);
|
||||
explicit any_t(const std::u32string& rssVal);
|
||||
explicit any_t(const std::wstring& rssVal);
|
||||
any_t(const std::string& rssVal);
|
||||
any_t(const std::u16string& rssVal);
|
||||
any_t(const std::u32string& rssVal);
|
||||
any_t(const std::wstring& rssVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief STD path constructor (will be stored as u8string).
|
||||
* @param[in] rpathVal Reference to the path object.
|
||||
*/
|
||||
any_t(const std::filesystem::path& rpathVal);
|
||||
|
||||
/**
|
||||
* @brief Interface constructor.
|
||||
* @param[in] ifcVal Interface pointer.
|
||||
*/
|
||||
any_t(interface_t ifcVal);
|
||||
|
||||
// Assignment already covered by any_t(uint64)
|
||||
///**
|
||||
// * brief Interface ID constructor.
|
||||
// * param[in] idIfcVal Interface ID.
|
||||
// */
|
||||
//any_t(interface_id idIfcVal);
|
||||
|
||||
// Assignment already covered by any_t(uint64)
|
||||
///**
|
||||
// * brief Exception ID constructor.
|
||||
// * param[in] idExceptVal Exception ID.
|
||||
// */
|
||||
//any_t(exception_id idExceptVal);
|
||||
|
||||
/**
|
||||
* @brief Enum constructor.
|
||||
* @tparam TEnum Type of enum.
|
||||
* @tparam TEnable Enable the function if the TType is an enum.
|
||||
* @param eVal The eunm value.
|
||||
*/
|
||||
template <typename TEnum, typename TEnable = std::enable_if_t<std::is_enum_v<TEnum>>>
|
||||
explicit any_t(TEnum eVal);
|
||||
|
||||
/**
|
||||
* @brief Assignment constructor.
|
||||
* @param[in] tVal The value to assign.
|
||||
@@ -171,11 +270,158 @@ namespace sdv
|
||||
|
||||
/**
|
||||
* @brief Assignment operator.
|
||||
* @param[in] tVal The value to assign.
|
||||
* @param[in] bVal The value to assign.
|
||||
* @return Reference to this class.
|
||||
*/
|
||||
template <typename TType>
|
||||
any_t& operator=(TType tVal);
|
||||
any_t& operator=(bool bVal);
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment operator.
|
||||
* @param[in] iVal The value to assign.
|
||||
* @return Reference to this class.
|
||||
*/
|
||||
any_t& operator=(int8_t iVal);
|
||||
any_t& operator=(int16_t iVal);
|
||||
any_t& operator=(int32_t iVal);
|
||||
#ifdef _WIN32
|
||||
any_t& operator=(long iVal);
|
||||
#endif
|
||||
any_t& operator=(int64_t iVal);
|
||||
#ifdef __linux__
|
||||
any_t& operator=(long long int iVal);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment operator.
|
||||
* @param[in] uiVal The value to assign.
|
||||
* @return Reference to this class.
|
||||
*/
|
||||
any_t& operator=(uint8_t uiVal);
|
||||
any_t& operator=(uint16_t uiVal);
|
||||
any_t& operator=(uint32_t uiVal);
|
||||
#ifdef _WIN32
|
||||
any_t& operator=(unsigned long uiVal);
|
||||
#endif
|
||||
any_t& operator=(uint64_t uiVal);
|
||||
#ifdef __linux__
|
||||
any_t& operator=(unsigned long long int uiVal);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment operator.
|
||||
* @param[in] cVal The value to assign.
|
||||
* @return Reference to this class.
|
||||
*/
|
||||
any_t& operator=(char cVal);
|
||||
any_t& operator=(char16_t cVal);
|
||||
any_t& operator=(char32_t cVal);
|
||||
any_t& operator=(wchar_t cVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment operator.
|
||||
* @param[in] fVal The value to assign.
|
||||
* @return Reference to this class.
|
||||
*/
|
||||
any_t& operator=(float fVal);
|
||||
any_t& operator=(double fVal);
|
||||
any_t& operator=(long double fVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief SDV string assignment operator.
|
||||
* @param[in] rssVal Reference to the string object.
|
||||
* @return Reference to this class.
|
||||
*/
|
||||
any_t& operator=(const string& rssVal);
|
||||
any_t& operator=(const u8string& rssVal);
|
||||
any_t& operator=(const u16string& rssVal);
|
||||
any_t& operator=(const u32string& rssVal);
|
||||
any_t& operator=(const wstring& rssVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief C-style string assignment operator.
|
||||
* @param[in] szVal Zero terminated string.
|
||||
* @return Reference to this class.
|
||||
*/
|
||||
any_t& operator=(const char* szVal);
|
||||
any_t& operator=(const char16_t* szVal);
|
||||
any_t& operator=(const char32_t* szVal);
|
||||
any_t& operator=(const wchar_t* szVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief STD string assignment operator.
|
||||
* @param[in] rssVal Reference to the string object.
|
||||
* @return Reference to this class.
|
||||
*/
|
||||
any_t& operator=(const std::string& rssVal);
|
||||
any_t& operator=(const std::u16string& rssVal);
|
||||
any_t& operator=(const std::u32string& rssVal);
|
||||
any_t& operator=(const std::wstring& rssVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief STD path assignment operator (will be stored as u8string).
|
||||
* @param[in] rpathVal Reference to the path object.
|
||||
* @return Reference to this class.
|
||||
*/
|
||||
any_t& operator=(const std::filesystem::path& rpathVal);
|
||||
|
||||
/**
|
||||
* @brief Interface assignment operator.
|
||||
* @param[in] ifcVal Interface pointer.
|
||||
* @return Reference to this class.
|
||||
*/
|
||||
any_t& operator=(interface_t ifcVal);
|
||||
|
||||
// Assignment already covered by operator=(uint64)
|
||||
///**
|
||||
// * brief Interface ID operator.
|
||||
// * param[in] idIfcVal Interface ID.
|
||||
// */
|
||||
//any_t& operator=(interface_id idIfcVal);
|
||||
|
||||
// Assignment already covered by operator=(uint64)
|
||||
///**
|
||||
// * brief Exception ID operator.
|
||||
// * param[in] idExceptVal Exception ID.
|
||||
// */
|
||||
//any_t& operator=(exception_id idExceptVal);
|
||||
|
||||
/**
|
||||
* @brief Enum assignment operator.
|
||||
* tparam TEnum Enum type.
|
||||
* @tparam TEnable Enable the function if the TType is an enum.
|
||||
* @param[in] eVal Enum value.
|
||||
* @return Reference to this class.
|
||||
*/
|
||||
template <typename TEnum, typename TEnable = std::enable_if_t<std::is_enum_v<TEnum>>>
|
||||
any_t& operator=(TEnum eVal);
|
||||
|
||||
/**
|
||||
* @brief Copy assignment operator.
|
||||
@@ -231,6 +477,7 @@ namespace sdv
|
||||
operator std::u16string() const;
|
||||
operator std::u32string() const;
|
||||
operator std::wstring() const;
|
||||
operator std::filesystem::path() const;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -247,12 +494,148 @@ namespace sdv
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* @brief Assign the value to the any. The any takes the value type based on the value.
|
||||
* @tparam TType The type of the value to set.
|
||||
* @param[in] tVal The value to set.
|
||||
* @brief Assignment function.
|
||||
* @param[in] bVal The value to assign.
|
||||
*/
|
||||
template <typename TType>
|
||||
void set(TType tVal);
|
||||
void set(bool bVal);
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment function.
|
||||
* @param[in] iVal The value to assign.
|
||||
*/
|
||||
void set(int8_t iVal);
|
||||
void set(int16_t iVal);
|
||||
void set(int32_t iVal);
|
||||
#ifdef _WIN32
|
||||
void set(long iVal);
|
||||
#endif
|
||||
void set(int64_t iVal);
|
||||
#ifdef __linux__
|
||||
void set(long long int iVal);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment function.
|
||||
* @param[in] uiVal The value to assign.
|
||||
*/
|
||||
void set(uint8_t uiVal);
|
||||
void set(uint16_t uiVal);
|
||||
void set(uint32_t uiVal);
|
||||
#ifdef _WIN32
|
||||
void set(unsigned long uiVal);
|
||||
#endif
|
||||
void set(uint64_t uiVal);
|
||||
#ifdef __linux__
|
||||
void set(unsigned long long int uiVal);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment function.
|
||||
* @param[in] cVal The value to assign.
|
||||
*/
|
||||
void set(char cVal);
|
||||
void set(char16_t cVal);
|
||||
void set(char32_t cVal);
|
||||
void set(wchar_t cVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief Assignment function.
|
||||
* @param[in] fVal The value to assign.
|
||||
*/
|
||||
void set(float fVal);
|
||||
void set(double fVal);
|
||||
void set(long double fVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief SDV string assignment function.
|
||||
* @param[in] rssVal Reference to the string object.
|
||||
*/
|
||||
void set(const string& rssVal);
|
||||
void set(const u8string& rssVal);
|
||||
void set(const u16string& rssVal);
|
||||
void set(const u32string& rssVal);
|
||||
void set(const wstring& rssVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief C-style string assignment function.
|
||||
* @param[in] szVal Zero terminated string.
|
||||
*/
|
||||
void set(const char* szVal);
|
||||
void set(const char16_t* szVal);
|
||||
void set(const char32_t* szVal);
|
||||
void set(const wchar_t* szVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @brief STD string assignment function.
|
||||
* @param[in] rssVal Reference to the string object.
|
||||
*/
|
||||
void set(const std::string& rssVal);
|
||||
void set(const std::u16string& rssVal);
|
||||
void set(const std::u32string& rssVal);
|
||||
void set(const std::wstring& rssVal);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief STD path assignment function (will be stored as u8string).
|
||||
* @param[in] rpathVal Reference to the path object.
|
||||
*/
|
||||
void set(const std::filesystem::path& rpathVal);
|
||||
|
||||
/**
|
||||
* @brief Interface assignment function.
|
||||
* @param[in] ifcVal Interface pointer.
|
||||
*/
|
||||
void set(interface_t ifcVal);
|
||||
|
||||
// Assignment already covered by set(uint64)
|
||||
///**
|
||||
// * brief Interface ID assignment function.
|
||||
// * param[in] idIfcVal Interface ID.
|
||||
// */
|
||||
//void set(interface_id idIfcVal);
|
||||
|
||||
// Assignment already covered by set(uint64)
|
||||
///**
|
||||
// * brief Exception ID assignment function.
|
||||
// * param[in] idExceptVal Exception ID.
|
||||
// */
|
||||
//void set(exception_id idExceptVal);
|
||||
|
||||
/**
|
||||
* @brief Enum assignment function.
|
||||
* tparam TEnum Enum type.
|
||||
* @tparam TEnable Enable the function if the TType is an enum.
|
||||
* @param[in] eVal Enum value.
|
||||
*/
|
||||
template <typename TEnum, typename TEnable = std::enable_if_t<std::is_enum_v<TEnum>>>
|
||||
void set(TEnum eVal);
|
||||
|
||||
/**
|
||||
* @brief Assign the value to the any. The value will be converted to the provided value type.
|
||||
@@ -273,7 +656,7 @@ namespace sdv
|
||||
|
||||
/**
|
||||
* @brief Comparison type.
|
||||
*/
|
||||
*/
|
||||
enum class ECompareType
|
||||
{
|
||||
compare_equal,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_APP_CONTROL_H
|
||||
#define SDV_APP_CONTROL_H
|
||||
|
||||
@@ -18,8 +31,8 @@ namespace sdv
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Default constructor; doesn't start the application control.
|
||||
*/
|
||||
* @brief Default constructor; doesn't start the application control.
|
||||
*/
|
||||
CAppControl() = default;
|
||||
|
||||
/**
|
||||
@@ -256,7 +269,7 @@ namespace sdv
|
||||
/**
|
||||
* @brief Get the application context.
|
||||
* @return The application context.
|
||||
*/
|
||||
*/
|
||||
EAppContext GetAppContext() const
|
||||
{
|
||||
return m_eContext;
|
||||
@@ -265,7 +278,7 @@ namespace sdv
|
||||
/**
|
||||
* @brief Get the core instance ID.
|
||||
* @return The core instance ID.
|
||||
*/
|
||||
*/
|
||||
uint32_t GetInstanceID() const
|
||||
{
|
||||
return m_uiInstanceID;
|
||||
@@ -292,9 +305,9 @@ namespace sdv
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the operation to config mode.
|
||||
* @pre The system is operating in running mode.
|
||||
*/
|
||||
* @brief Set the operation to config mode.
|
||||
* @pre The system is operating in running mode.
|
||||
*/
|
||||
void SetConfigMode()
|
||||
{
|
||||
IAppOperation* pAppOperation = core::GetObject<IAppOperation>("AppControlService");
|
||||
@@ -330,7 +343,7 @@ namespace sdv
|
||||
* @param[in] ssFilename Path to the file containing the configuration (TOML). The path can be absolute as well as relative.
|
||||
* In case a relative path is provided, the current directory is searched as well as all directories supplied through
|
||||
* the AddConfigSearchDir function.
|
||||
* @return Returns 'true' on success; 'false' otherwise.
|
||||
* @return Returns a config process result enum value.
|
||||
*/
|
||||
core::EConfigProcessResult LoadConfig(/*in*/ const sdv::u8string& ssFilename)
|
||||
{
|
||||
@@ -346,6 +359,52 @@ namespace sdv
|
||||
return eResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 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.
|
||||
* @remarks The function will only save when the configuration has changed.
|
||||
* @param[in] ssConfigPath 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.
|
||||
* @return Returns 'true' on success (or no changes detected); 'false' otherwise.
|
||||
*/
|
||||
bool SaveConfig(/*in*/ sdv::u8string ssConfigPath) const
|
||||
{
|
||||
const core::IConfig* pAppConfig = nullptr;
|
||||
sdv::TInterfaceAccessPtr ptrConfigObj = core::GetObject("ConfigService");
|
||||
if (ptrConfigObj) pAppConfig = ptrConfigObj.GetInterface<core::IConfig>();
|
||||
if (!pAppConfig) return false;
|
||||
return pAppConfig->SaveConfig(ssConfigPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Generate the configuration TOML string.
|
||||
* @return The generated configuration string.
|
||||
*/
|
||||
sdv::u8string GenerateConfigString() const
|
||||
{
|
||||
const core::IConfig* pAppConfig = nullptr;
|
||||
sdv::TInterfaceAccessPtr ptrConfigObj = core::GetObject("ConfigService");
|
||||
if (ptrConfigObj) pAppConfig = ptrConfigObj.GetInterface<core::IConfig>();
|
||||
if (!pAppConfig) return {};
|
||||
return pAppConfig->GenerateConfigString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Close the current configuration.
|
||||
* @details 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.
|
||||
*/
|
||||
void CloseConfig()
|
||||
{
|
||||
core::IConfig* pAppConfig = nullptr;
|
||||
sdv::TInterfaceAccessPtr ptrConfigObj = core::GetObject("ConfigService");
|
||||
if (ptrConfigObj) pAppConfig = ptrConfigObj.GetInterface<core::IConfig>();
|
||||
if (!pAppConfig) return;
|
||||
pAppConfig->CloseConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add a search path to a folder where a config file can be found.
|
||||
* @param[in] rpathDir Reference to the relative or absolute path to an existing folder.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_CRC_H
|
||||
#define SDV_CRC_H
|
||||
|
||||
@@ -12,7 +25,7 @@ namespace sdv
|
||||
* @tparam T The type to use for bit reflection.
|
||||
* @param[in] tValue The value to reflect. Must be a arithmetic or boolean type.
|
||||
* @return The reflected value.
|
||||
*/
|
||||
*/
|
||||
template <typename T>
|
||||
constexpr T reflect(T tValue)
|
||||
{
|
||||
@@ -53,7 +66,7 @@ namespace sdv
|
||||
* @param[in] pData Pointer to the value buffer.
|
||||
* @param[in] nCount Amount of values in the buffer.
|
||||
* @return The calculated CRC checksum.
|
||||
*/
|
||||
*/
|
||||
template <typename T>
|
||||
TCRCType calc_checksum(const T* pData, size_t nCount) noexcept;
|
||||
|
||||
@@ -62,25 +75,25 @@ namespace sdv
|
||||
* @remarks The CRC calculation occurs byte-wise regardless of the endianness of the the processor architecture.
|
||||
* @tparam T Type of the value buffer to calculate the CRC for.
|
||||
* @param[in] tValue The value to add to the calculation.
|
||||
*/
|
||||
*/
|
||||
template <typename T>
|
||||
void add(T tValue) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Get the currently calculated checksum.
|
||||
* @return The CRC checksum.
|
||||
*/
|
||||
*/
|
||||
TCRCType get_checksum() const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Set a CRC checksum to continue the calculation with additional data.
|
||||
* @param[in] tCrcValue The previously calculated CRC value.
|
||||
*/
|
||||
*/
|
||||
void set_checksum(TCRCType tCrcValue) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Reset the current calculation (resets the CRC value to its initial value).
|
||||
*/
|
||||
*/
|
||||
void reset() noexcept;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_EXCEPT_H
|
||||
#define SDV_EXCEPT_H
|
||||
|
||||
@@ -11,15 +24,15 @@
|
||||
namespace sdv
|
||||
{
|
||||
/**
|
||||
* @brief exception ID type
|
||||
*/
|
||||
* @brief exception ID type
|
||||
*/
|
||||
using exception_id = uint64_t;
|
||||
|
||||
/**
|
||||
* @brief Get the exception ID.
|
||||
* @tparam TException The exception type
|
||||
* @return The ID of the exception
|
||||
*/
|
||||
* @brief Get the exception ID.
|
||||
* @tparam TException The exception type
|
||||
* @return The ID of the exception
|
||||
*/
|
||||
template <typename TExcept>
|
||||
constexpr inline exception_id GetExceptionId() noexcept
|
||||
{
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_INTERFACE_H
|
||||
#define SDV_INTERFACE_H
|
||||
|
||||
@@ -8,6 +21,8 @@
|
||||
#define interface struct
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace sdv
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_INTERFACE_INL
|
||||
#define SDV_INTERFACE_INL
|
||||
|
||||
#ifndef SDV_INTERFACE_H
|
||||
#error Do not include "interface.inl" directly. Include "interface.h" instead!
|
||||
#include "interface.h"
|
||||
#endif //!defined SDV_INTERFACE_H
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
/**
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* @file interface_ptr.h
|
||||
* @brief This file provides all necessary definitions to use and implement interface maps.
|
||||
* @version 0.1
|
||||
* @date 2022.11.14
|
||||
* @author Thomas.pfleiderer@zf.com
|
||||
* @copyright Copyright ZF Friedrichshaven AG (c) 2022
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*/
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef INTERFACE_IMPL_H
|
||||
#define INTERFACE_IMPL_H
|
||||
|
||||
@@ -79,10 +82,24 @@ namespace sdv
|
||||
int m_uiUseSection = -1; ///< The number of the section to process the interface table entries for.
|
||||
int m_uiSection = -1; ///< The number of the section the interface table entries belong to.
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Helper struct for type reporting during static_assert.
|
||||
* @tparam T Type to report for the always_false struct.
|
||||
*/
|
||||
template <typename T>
|
||||
struct always_false : std::false_type
|
||||
{};
|
||||
|
||||
/**
|
||||
* @brief Variable for the always_false struct.
|
||||
* @tparam T Type to report for the always_false struct.
|
||||
*/
|
||||
template <typename T>
|
||||
constexpr bool always_false_v = always_false<T>::value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Interface map containing the supported interface definitions.
|
||||
* @pre The class using the interface map should derive from IInterfaceAccess.
|
||||
@@ -171,17 +188,16 @@ namespace sdv
|
||||
|
||||
/**
|
||||
* @brief Conditional check; when true continue the checking for interfaces.
|
||||
* @param condition The condition to be checked. When 'false' processing will be stopped; otherwise processing
|
||||
* continues. Example: @code SDV_INTERFACE_CHECK_CONDITION(CheckFunc()) @endcode
|
||||
* @param condition The condition to be checked. When 'false' processing will be stopped; otherwise processing continues.
|
||||
* Example: @code SDV_INTERFACE_CHECK_CONDITION(CheckFunc()) @endcode
|
||||
*/
|
||||
#define SDV_INTERFACE_CHECK_CONDITION(condition) \
|
||||
if (!(condition)) \
|
||||
return nullptr;
|
||||
if (!(condition)) return nullptr;
|
||||
|
||||
/**
|
||||
* @brief Use the condition, to select a section to process.
|
||||
* @param condition Condition to be checked. When 'true' processing will be limited to the section.
|
||||
* Example: @code SDV_INTERFACE_PROCESS_SECTION(CheckFunc(), 1) @endcode
|
||||
* Example: @code SDV_INTERFACE_SET_SECTION_CONDITION(CheckFunc(), 1) @endcode
|
||||
* @param section_number The section to be processed when the condition is true.
|
||||
*/
|
||||
#define SDV_INTERFACE_SET_SECTION_CONDITION(condition, section_number) \
|
||||
@@ -311,6 +327,26 @@ namespace sdv
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare the interface pointer with an interface.
|
||||
* @param[in] pInterface Pointer to the interface.
|
||||
* @return Returns whether the interfaces are equal.
|
||||
*/
|
||||
bool operator==(const IInterfaceAccess* pInterface) const
|
||||
{
|
||||
return static_cast<const IInterfaceAccess*>(m_pInterface) == pInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare the interface pointer with an interface.
|
||||
* @param[in] pInterface Pointer to the interface.
|
||||
* @return Returns whether the interfaces are not equal.
|
||||
*/
|
||||
bool operator!=(const IInterfaceAccess* pInterface) const
|
||||
{
|
||||
return static_cast<const IInterfaceAccess*>(m_pInterface) == pInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a pointer to the interface
|
||||
*/
|
||||
@@ -392,7 +428,7 @@ namespace sdv
|
||||
return rtMember.GetInterface(idInterface);
|
||||
}
|
||||
|
||||
// Warning of cppchgeck for a potential const variable cannot be applied due to the non-const nature of interfaces. Suppress
|
||||
// Warning of cppcheck for a potential const variable cannot be applied due to the non-const nature of interfaces. Suppress
|
||||
// warning.
|
||||
// cppcheck-suppress constParameterReference
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_ITERATOR_H
|
||||
#define SDV_ITERATOR_H
|
||||
|
||||
@@ -15,7 +28,7 @@ namespace sdv
|
||||
* @tparam TContainer Container type to use for this iterator.
|
||||
* @tparam bConstIterator When set, the iterator is a const iterator not allowing to change values within the container.
|
||||
* @tparam bReserseIterator When set, the iterator starts at the end instead of at the beginning and decreases the location.
|
||||
*/
|
||||
*/
|
||||
template <class TContainer, bool bConstIterator, bool bReverseIterator>
|
||||
class index_iterator
|
||||
{
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef LOCAL_SERVICE_ACCESS_H
|
||||
#define LOCAL_SERVICE_ACCESS_H
|
||||
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef MEM_SUPPORT_H
|
||||
#define MEM_SUPPORT_H
|
||||
|
||||
|
||||
1541
export/support/param_impl.h
Normal file
1541
export/support/param_impl.h
Normal file
File diff suppressed because it is too large
Load Diff
732
export/support/param_impl.inl
Normal file
732
export/support/param_impl.inl
Normal file
@@ -0,0 +1,732 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef PARAM_IMPL_INL
|
||||
#define PARAM_IMPL_INL
|
||||
|
||||
#ifndef PARAM_IMPL_H
|
||||
#include "param_impl.h"
|
||||
#endif //! defined PARAM_IMPL_H
|
||||
|
||||
#include <regex>
|
||||
#include <set>
|
||||
|
||||
/**
|
||||
* @brief Software Defined Vehicle framework.
|
||||
*/
|
||||
namespace sdv
|
||||
{
|
||||
template <typename TVar, typename TDefaultType>
|
||||
inline CSdvParamInfo::CSdvParamInfo(TVar&, const std::string& rssName, TDefaultType tDefaultVal, const std::string& rssUnit,
|
||||
const std::string& rssCategory, const std::string& rssDescription, uint32_t uiFlagsParam)
|
||||
{
|
||||
EParamType eTypeLocal = EParamType::boolean_param;
|
||||
|
||||
if constexpr (std::is_same_v<TVar, bool>)
|
||||
eTypeLocal = EParamType::boolean_param;
|
||||
else if constexpr (std::is_arithmetic_v<TVar>)
|
||||
eTypeLocal = EParamType::number_param; // No number limitation
|
||||
else if constexpr (TypeIsString<TVar>())
|
||||
eTypeLocal = EParamType::string_param; // No pattern
|
||||
else if constexpr (std::is_enum_v<TVar>)
|
||||
eTypeLocal = EParamType::enum_param; // No enumerator labels
|
||||
else
|
||||
static_assert(sdv::internal::always_false_v<TVar>, "The parameter type is not supported!");
|
||||
|
||||
any_t anyDefaultValLocal;
|
||||
if constexpr (std::is_enum_v<TVar>)
|
||||
{
|
||||
static_assert(std::is_same_v<std::remove_reference_t<std::remove_const_t<TVar>>, TDefaultType>,
|
||||
"The enum types of the value and the default value must be identical!");
|
||||
anyDefaultValLocal = static_cast<std::underlying_type_t<TVar>>(tDefaultVal);
|
||||
}
|
||||
else
|
||||
anyDefaultValLocal = tDefaultVal;
|
||||
|
||||
uint32_t uiFlagsLocal = uiFlagsParam;
|
||||
if (TypeIsReadOnly<TVar>())
|
||||
uiFlagsLocal |= static_cast<uint32_t>(EParamFlags::read_only);
|
||||
if (uiFlagsLocal & static_cast<uint32_t>(EParamFlags::read_only))
|
||||
uiFlagsLocal &= ~static_cast<uint32_t>(EParamFlags::locked); // Readonly cannot write
|
||||
Init(eTypeLocal, rssName, anyDefaultValLocal, rssUnit, rssCategory, rssDescription, uiFlagsLocal);
|
||||
|
||||
if constexpr (std::is_enum_v<TVar>)
|
||||
uExtInfo.sEnumInfo.seqLabels = internal::GetLabelMapHelper().GetLabelMap<TVar>();
|
||||
}
|
||||
|
||||
template <typename TVar, typename TDefaultType>
|
||||
inline CSdvParamInfo::CSdvParamInfo(TVar&, const std::string& rssName, TDefaultType tDefaultVal, const any_t& ranyLimitLow,
|
||||
bool bIncludeLow, const any_t& ranyLimitHigh, bool bIncludeHigh, const std::string& rssUnit, const std::string& rssCategory,
|
||||
const std::string& rssDescription, uint32_t uiFlagsParam)
|
||||
{
|
||||
static_assert(std::is_arithmetic_v<TVar> && !std::is_same_v<TVar, bool>,
|
||||
"The construct function for numeric types expects the type to be numeric.");
|
||||
uint32_t uiFlagsLocal = uiFlagsParam;
|
||||
if (TypeIsReadOnly<TVar>())
|
||||
uiFlagsLocal |= static_cast<uint32_t>(EParamFlags::read_only);
|
||||
if (uiFlagsLocal & static_cast<uint32_t>(EParamFlags::read_only))
|
||||
uiFlagsLocal &= ~static_cast<uint32_t>(EParamFlags::locked); // Readonly cannot write
|
||||
Init(EParamType::number_param, rssName, tDefaultVal, rssUnit, rssCategory, rssDescription, uiFlagsLocal);
|
||||
uExtInfo.sNumberInfo.anyLowerLimit = ranyLimitLow;
|
||||
uExtInfo.sNumberInfo.bIncludeLowerLinit = bIncludeLow;
|
||||
uExtInfo.sNumberInfo.anyUpperLimit = ranyLimitHigh;
|
||||
uExtInfo.sNumberInfo.bIncludeUpperLimit = bIncludeHigh;
|
||||
}
|
||||
|
||||
template <typename TVar, typename TDefaultType>
|
||||
inline CSdvParamInfo::CSdvParamInfo(TVar&, const std::string& rssName, TDefaultType tDefaultVal, const std::string& rssPattern,
|
||||
const std::string& rssUnit, const std::string& rssCategory, const std::string& rssDescription, uint32_t uiFlagsParam)
|
||||
{
|
||||
static_assert(TypeIsString<TVar>(), "The construct function for string types expects the type to be a string.");
|
||||
uint32_t uiFlagsLocal = uiFlagsParam;
|
||||
if (TypeIsReadOnly<TVar>())
|
||||
uiFlagsLocal |= static_cast<uint32_t>(EParamFlags::read_only);
|
||||
if (uiFlagsLocal & static_cast<uint32_t>(EParamFlags::read_only))
|
||||
uiFlagsLocal &= ~static_cast<uint32_t>(EParamFlags::locked); // Readonly cannot write
|
||||
Init(EParamType::string_param, rssName, tDefaultVal, rssUnit, rssCategory, rssDescription, uiFlagsLocal);
|
||||
uExtInfo.sStringInfo.ssPattern = rssPattern;
|
||||
}
|
||||
|
||||
template <typename TVar, typename TDefaultType>
|
||||
inline CSdvParamInfo::CSdvParamInfo(TVar&, const std::string& rssName, TDefaultType tDefaultVal,
|
||||
const sequence<SLabelInfo::SLabel>& rseqLabels, const std::string& rssCategory, const std::string& rssDescription,
|
||||
uint32_t uiFlagsParam)
|
||||
{
|
||||
static_assert(std::is_enum_v<TVar> || (std::is_integral_v<TVar> && !std::is_same_v<TVar, bool>),
|
||||
"The construct function for enumerators and bitmasks expects the type to be an enum or an integral type.");
|
||||
uint32_t uiFlagsLocal = uiFlagsParam;
|
||||
if (TypeIsReadOnly<TVar>())
|
||||
uiFlagsLocal |= static_cast<uint32_t>(EParamFlags::read_only);
|
||||
if (uiFlagsLocal & static_cast<uint32_t>(EParamFlags::read_only))
|
||||
uiFlagsLocal &= ~static_cast<uint32_t>(EParamFlags::locked); // Readonly cannot write
|
||||
if constexpr (std::is_enum_v<TVar>)
|
||||
{
|
||||
Init(EParamType::enum_param, rssName, static_cast<std::underlying_type_t<TVar>>(tDefaultVal), "",
|
||||
rssCategory, rssDescription, uiFlagsLocal);
|
||||
uExtInfo.sEnumInfo.seqLabels = rseqLabels;
|
||||
}
|
||||
else
|
||||
{
|
||||
Init(EParamType::bitmask_param, rssName, tDefaultVal, "", rssCategory, rssDescription, uiFlagsLocal);
|
||||
uExtInfo.sBitmaskInfo.seqLabels = rseqLabels;
|
||||
}
|
||||
}
|
||||
|
||||
inline CSdvParamInfo::CSdvParamInfo(const SParamInfo& rInfo) : SParamInfo(rInfo)
|
||||
{}
|
||||
|
||||
inline CSdvParamInfo::CSdvParamInfo(SParamInfo&& rInfo) : SParamInfo(std::move(rInfo))
|
||||
{}
|
||||
|
||||
inline CSdvParamInfo& CSdvParamInfo::operator=(const SParamInfo& rsInfo)
|
||||
{
|
||||
static_cast<SParamInfo&>(*this) = rsInfo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline CSdvParamInfo& CSdvParamInfo::operator=(SParamInfo&& rsInfo)
|
||||
{
|
||||
static_cast<SParamInfo&>(*this) = std::move(rsInfo);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline SParamInfo CSdvParamInfo::InfoStruct() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const u8string& CSdvParamInfo::Name() const
|
||||
{
|
||||
return SParamInfo::ssName;
|
||||
}
|
||||
|
||||
inline u8string CSdvParamInfo::Path() const
|
||||
{
|
||||
sdv::u8string ssPath;
|
||||
if (!SParamInfo::ssGroup.empty())
|
||||
ssPath += ssGroup + ".";
|
||||
ssPath += ssName;
|
||||
return ssPath;
|
||||
}
|
||||
|
||||
inline const any_t& CSdvParamInfo::DefaultVal() const
|
||||
{
|
||||
return SParamInfo::anyDefaultVal;
|
||||
}
|
||||
|
||||
inline const u8string& CSdvParamInfo::Group() const
|
||||
{
|
||||
return SParamInfo::ssGroup;
|
||||
}
|
||||
|
||||
inline const u8string& CSdvParamInfo::Description() const
|
||||
{
|
||||
return SParamInfo::ssDescription;
|
||||
}
|
||||
|
||||
inline const u8string& CSdvParamInfo::Unit() const
|
||||
{
|
||||
return SParamInfo::ssUnit;
|
||||
}
|
||||
|
||||
inline uint32_t CSdvParamInfo::Flags() const
|
||||
{
|
||||
return uiFlags;
|
||||
}
|
||||
|
||||
inline bool CSdvParamInfo::ReadOnly() const
|
||||
{
|
||||
return (uiFlags & static_cast<uint32_t>(EParamFlags::read_only)) ? true : false;
|
||||
}
|
||||
|
||||
inline bool CSdvParamInfo::Temporary() const
|
||||
{
|
||||
return (uiFlags & static_cast<uint32_t>(EParamFlags::temporary)) ? true : false;
|
||||
}
|
||||
|
||||
inline bool CSdvParamInfo::Dirty() const
|
||||
{
|
||||
return (uiFlags & static_cast<uint32_t>(EParamFlags::dirty)) ? true : false;
|
||||
}
|
||||
|
||||
inline bool CSdvParamInfo::Locked() const
|
||||
{
|
||||
return (uiFlags & static_cast<uint32_t>(EParamFlags::locked)) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
inline bool CSdvParamInfo::Boolean() const
|
||||
{
|
||||
return get_switch() == EParamType::boolean_param;
|
||||
}
|
||||
|
||||
inline bool CSdvParamInfo::Numeric() const
|
||||
{
|
||||
return get_switch() == EParamType::number_param;
|
||||
}
|
||||
|
||||
inline bool CSdvParamInfo::String() const
|
||||
{
|
||||
return get_switch() == EParamType::string_param;
|
||||
}
|
||||
|
||||
inline bool CSdvParamInfo::Enum() const
|
||||
{
|
||||
return get_switch() == EParamType::enum_param;
|
||||
}
|
||||
|
||||
inline bool CSdvParamInfo::Bitmask() const
|
||||
{
|
||||
return get_switch() == EParamType::bitmask_param;
|
||||
}
|
||||
|
||||
inline std::pair<any_t, bool> CSdvParamInfo::NumericLimitLow() const
|
||||
{
|
||||
if (!Numeric()) return {};
|
||||
return std::make_pair(uExtInfo.sNumberInfo.anyLowerLimit, uExtInfo.sNumberInfo.bIncludeLowerLinit);
|
||||
}
|
||||
|
||||
inline std::pair<any_t, bool> CSdvParamInfo::NumericLimitHigh() const
|
||||
{
|
||||
if (!Numeric()) return {};
|
||||
return std::make_pair(uExtInfo.sNumberInfo.anyUpperLimit, uExtInfo.sNumberInfo.bIncludeUpperLimit);
|
||||
}
|
||||
|
||||
inline std::string CSdvParamInfo::StringPattern() const
|
||||
{
|
||||
if (!String()) return {};
|
||||
return uExtInfo.sStringInfo.ssPattern;
|
||||
}
|
||||
|
||||
inline sequence<SLabelInfo::SLabel> CSdvParamInfo::EnumBitmaskLabels() const
|
||||
{
|
||||
if (Enum())
|
||||
return uExtInfo.sEnumInfo.seqLabels;
|
||||
else if (Bitmask())
|
||||
return uExtInfo.sBitmaskInfo.seqLabels;
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
||||
inline void CSdvParamInfo::Init(EParamType eTypeParam, const std::string& rssName, const any_t& ranyDefaultVal,
|
||||
const std::string& rssUnit, const std::string& rssCategory, const std::string& rssDescription, uint32_t uiFlagsParam)
|
||||
{
|
||||
switch_to(eTypeParam);
|
||||
uiFlags = uiFlagsParam;
|
||||
ssName = rssName;
|
||||
anyDefaultVal = ranyDefaultVal;
|
||||
ssUnit = rssUnit;
|
||||
ssGroup = rssCategory;
|
||||
ssDescription = rssDescription;
|
||||
}
|
||||
|
||||
namespace internal
|
||||
{
|
||||
template <typename... TInfoConstruct>
|
||||
inline CParamGuardian::CParamGuardian(bool bLockable, bool bAutoDirty, TInfoConstruct... tConstruct) :
|
||||
CSdvParamInfo(tConstruct...), m_bLockable(bLockable), m_bAutoDirty(bAutoDirty)
|
||||
{}
|
||||
|
||||
inline SParamInfo CParamGuardian::InfoStruct() const
|
||||
{
|
||||
sdv::SParamInfo sInfo = CSdvParamInfo::InfoStruct();
|
||||
sInfo.uiFlags = Flags();
|
||||
return sInfo;
|
||||
}
|
||||
|
||||
inline uint32_t CParamGuardian::Flags() const
|
||||
{
|
||||
uint32_t uiFlagsTemp = CSdvParamInfo::Flags() & ~static_cast<uint32_t>(EParamFlags::state_mask);
|
||||
if (m_bLocked)
|
||||
uiFlagsTemp |= static_cast<uint32_t>(EParamFlags::locked);
|
||||
if (m_bDirty)
|
||||
uiFlagsTemp |= static_cast<uint32_t>(EParamFlags::dirty);
|
||||
return uiFlagsTemp;
|
||||
}
|
||||
|
||||
inline bool CParamGuardian::UpdateDirty(const sdv::any_t& ranyValue)
|
||||
{
|
||||
if (!m_bAutoDirty) return false;
|
||||
bool bDirty = m_bDirty;
|
||||
m_bDirty |= ranyValue != m_anyStored;
|
||||
m_anyStored = ranyValue;
|
||||
return m_bDirty != bDirty;
|
||||
}
|
||||
|
||||
inline bool CParamGuardian::SetDirty()
|
||||
{
|
||||
bool bDirty = m_bDirty;
|
||||
m_bDirty = true;
|
||||
return m_bDirty != bDirty;
|
||||
}
|
||||
|
||||
inline bool CParamGuardian::ResetDirty()
|
||||
{
|
||||
bool bDirty = m_bDirty;
|
||||
m_bDirty = false;
|
||||
return m_bDirty != bDirty;
|
||||
}
|
||||
|
||||
inline bool CParamGuardian::Dirty() const
|
||||
{
|
||||
return m_bDirty;
|
||||
}
|
||||
|
||||
inline bool CParamGuardian::Lockable() const
|
||||
{
|
||||
return m_bLockable;
|
||||
}
|
||||
|
||||
inline bool CParamGuardian::Lock()
|
||||
{
|
||||
if (!m_bLockable)
|
||||
return false;
|
||||
bool bLocked = m_bLocked;
|
||||
m_bLocked = true;
|
||||
return m_bLocked != bLocked;
|
||||
}
|
||||
|
||||
inline bool CParamGuardian::Unlock()
|
||||
{
|
||||
if (!m_bLockable)
|
||||
return false;
|
||||
bool bLocked = m_bLocked;
|
||||
m_bLocked = false;
|
||||
return m_bLocked != bLocked;
|
||||
}
|
||||
|
||||
inline bool CParamGuardian::Locked() const
|
||||
{
|
||||
return m_bLocked;
|
||||
}
|
||||
|
||||
inline bool CParamGuardian::CheckRestrictions(const any_t& ranyValue)
|
||||
{
|
||||
if (Numeric())
|
||||
{
|
||||
// Check for lower limit
|
||||
auto prLimitLow = NumericLimitLow();
|
||||
if (!prLimitLow.first.empty())
|
||||
{
|
||||
if (prLimitLow.second)
|
||||
{
|
||||
if (ranyValue < prLimitLow.first) return false;
|
||||
} else
|
||||
{
|
||||
if (ranyValue <= prLimitLow.first) return false;
|
||||
}
|
||||
}
|
||||
// Check for higher limit
|
||||
auto prLimitHigh = NumericLimitHigh();
|
||||
if (!prLimitHigh.first.empty())
|
||||
{
|
||||
if (prLimitHigh.second)
|
||||
{
|
||||
if (ranyValue > prLimitHigh.first) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ranyValue >= prLimitHigh.first) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (String())
|
||||
{
|
||||
// Check for compatibility to the regular expression pattern.
|
||||
if (!StringPattern().empty())
|
||||
{
|
||||
std::regex regexPattern(StringPattern());
|
||||
if (!std::regex_match(static_cast<std::string>(ranyValue), regexPattern)) return false;
|
||||
}
|
||||
}
|
||||
else if (Enum())
|
||||
{
|
||||
// Check for occurrence in the label sequence
|
||||
auto seqLabels = EnumBitmaskLabels();
|
||||
if (std::find_if(seqLabels.begin(), seqLabels.end(), [&](const auto& rsLabel)
|
||||
{ return ranyValue == rsLabel.anyValue; }) == seqLabels.end()) return false;
|
||||
}
|
||||
else if (Bitmask())
|
||||
{
|
||||
// Check for the occurence of each set bit in the label sequence
|
||||
auto seqLabels = EnumBitmaskLabels();
|
||||
uint64_t uiBitmask = ranyValue;
|
||||
for (const auto& rsLabel : seqLabels)
|
||||
uiBitmask &= ~static_cast<uint64_t>(rsLabel.anyValue);
|
||||
if (uiBitmask) return false;
|
||||
}
|
||||
|
||||
// All okay; restrictions were checked
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename TVar>
|
||||
template <typename... TInfoConstruct>
|
||||
inline CParamValue<TVar>::CParamValue(TVar& rtVar, bool bLockable, bool bAutoDirty, TInfoConstruct... tConstruct) :
|
||||
CParamGuardian(bLockable, bAutoDirty, rtVar, tConstruct...), m_rtVar(rtVar)
|
||||
{
|
||||
// Assign the default value
|
||||
if constexpr (!CSdvParamInfo::TypeIsReadOnly<TVar>())
|
||||
{
|
||||
m_rtVar = DefaultVal().get<TVar>();
|
||||
UpdateDirty(DefaultVal());
|
||||
ResetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename TVar>
|
||||
inline bool CParamValue<TVar>::Set(const any_t& ranyValue)
|
||||
{
|
||||
// Assign the value
|
||||
if constexpr (!CSdvParamInfo::TypeIsReadOnly<TVar>())
|
||||
{
|
||||
if (!Locked() && !ReadOnly() && CheckRestrictions(ranyValue))
|
||||
{
|
||||
m_rtVar = ranyValue.get<TVar>();
|
||||
UpdateDirty(ranyValue);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename TVar>
|
||||
inline any_t CParamValue<TVar>::Get() const
|
||||
{
|
||||
// Remarks: in case of an enum, an explicit construction is needed.
|
||||
return sdv::any_t(m_rtVar);
|
||||
}
|
||||
} // namespace internal
|
||||
|
||||
inline std::shared_ptr<internal::CParamGuardian> CSdvParamMap::FindParamObject(const sdv::u8string& rssPath)
|
||||
{
|
||||
// Iterate through the registrations
|
||||
for (const SParamRegistration& rsRegistration : m_vecParamMapRegistration)
|
||||
{
|
||||
// Member parameter map entry
|
||||
if (rsRegistration.MemberMap() && rsRegistration.MemberMap()->Access())
|
||||
{
|
||||
auto ptrParameter = rsRegistration.MemberMap()->Access()->FindParamObject(rssPath);
|
||||
if (ptrParameter) return ptrParameter;
|
||||
}
|
||||
|
||||
// Parameter entry
|
||||
if (rsRegistration.Parameter() && rsRegistration.Parameter()->Path() == rssPath)
|
||||
return rsRegistration.Parameter();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
inline std::shared_ptr<const internal::CParamGuardian> CSdvParamMap::FindParamObject(const sdv::u8string& rssPath) const
|
||||
{
|
||||
// Iterate through the registrations
|
||||
for (const SParamRegistration& rsRegistration : m_vecParamMapRegistration)
|
||||
{
|
||||
// Member parameter map entry
|
||||
if (rsRegistration.MemberMap() && rsRegistration.MemberMap()->Access())
|
||||
{
|
||||
auto ptrParameter = rsRegistration.MemberMap()->Access()->FindParamObject(rssPath);
|
||||
if (ptrParameter)
|
||||
return ptrParameter;
|
||||
}
|
||||
|
||||
// Parameter entry
|
||||
if (rsRegistration.Parameter() && rsRegistration.Parameter()->Path() == rssPath)
|
||||
return rsRegistration.Parameter();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
inline sequence<u8string> CSdvParamMap::GetParamPaths() const
|
||||
{
|
||||
// Split path function (splits the group from the parameter names)
|
||||
auto fnSplitPath = [](const sdv::u8string& rssPath) -> std::pair<sdv::u8string, sdv::u8string>
|
||||
{
|
||||
size_t nPos = rssPath.find_last_of('.');
|
||||
if (nPos == sdv::u8string::npos)
|
||||
return std::make_pair("", rssPath);
|
||||
return std::make_pair(rssPath.substr(0, nPos), rssPath.substr(nPos + 1));
|
||||
};
|
||||
|
||||
std::set<u8string> setOneTime;
|
||||
sequence<u8string> seqPaths;
|
||||
for (const auto& rsRegistration : m_vecParamMapRegistration)
|
||||
{
|
||||
// Add a path to the sequence.
|
||||
auto fnAddPath = [&](const u8string& rssPath)
|
||||
{
|
||||
// Check if already present in the list
|
||||
if (setOneTime.find(rssPath) != setOneTime.end()) return;
|
||||
setOneTime.insert(rssPath);
|
||||
|
||||
// Sort the paths per group, so all paths belonging to one group is returned together.
|
||||
// Find thee first location where the group is larger than the one of this path.
|
||||
auto prPath = fnSplitPath(rssPath);
|
||||
auto itPos = seqPaths.begin();
|
||||
while (itPos != seqPaths.end())
|
||||
{
|
||||
auto prStoredPath = fnSplitPath(*itPos);
|
||||
if (prPath.first.compare(prStoredPath.first) < 0) break;
|
||||
++itPos;
|
||||
}
|
||||
|
||||
// Insert into the sequence
|
||||
seqPaths.insert(itPos, rssPath);
|
||||
};
|
||||
|
||||
// Add the chained member to the list
|
||||
if (rsRegistration.MemberMap() && rsRegistration.MemberMap()->Access())
|
||||
{
|
||||
auto seqNamesMemberMap = rsRegistration.MemberMap()->Access()->GetParamPaths();
|
||||
for (const auto& rssPath : seqNamesMemberMap)
|
||||
fnAddPath(rssPath);
|
||||
}
|
||||
|
||||
// Add the parameter to the list
|
||||
if (rsRegistration.Parameter())
|
||||
fnAddPath(rsRegistration.Parameter()->Path());
|
||||
}
|
||||
|
||||
return seqPaths;
|
||||
}
|
||||
|
||||
inline any_t CSdvParamMap::GetParam(const u8string& rssPath) const
|
||||
{
|
||||
auto ptrParam = FindParamObject(rssPath);
|
||||
if (!ptrParam) return {};
|
||||
return ptrParam->Get();
|
||||
}
|
||||
|
||||
inline bool CSdvParamMap::SetParam(const u8string& rssPath, any_t ranyValue)
|
||||
{
|
||||
auto ptrParam = FindParamObject(rssPath);
|
||||
if (!ptrParam) return false;
|
||||
return ptrParam->Set(ranyValue);
|
||||
}
|
||||
|
||||
inline SParamInfo CSdvParamMap::GetParamInfo(const u8string& rssPath) const
|
||||
{
|
||||
auto ptrParamInfo = FindParamObject(rssPath);
|
||||
if (!ptrParamInfo) return {};
|
||||
return ptrParamInfo.get()->InfoStruct();
|
||||
}
|
||||
|
||||
inline bool CSdvParamMap::IsParamDirty(const u8string& rssPath) const
|
||||
{
|
||||
auto ptrParam = FindParamObject(rssPath);
|
||||
if (!ptrParam) return false;
|
||||
return ptrParam->Dirty();
|
||||
}
|
||||
|
||||
inline void CSdvParamMap::SetParamDirtyFlag(const std::string& rssPath)
|
||||
{
|
||||
auto ptrParam = FindParamObject(rssPath);
|
||||
if (!ptrParam) return;
|
||||
ptrParam->SetDirty();
|
||||
}
|
||||
|
||||
inline void CSdvParamMap::ResetParamDirtyFlag(const u8string& rssPath)
|
||||
{
|
||||
auto ptrParam = FindParamObject(rssPath);
|
||||
if (!ptrParam) return;
|
||||
ptrParam->ResetDirty();
|
||||
}
|
||||
|
||||
inline bool CSdvParamMap::IsParamMapDirty() const
|
||||
{
|
||||
std::set<u8string> setOneTime;
|
||||
for (const auto& rsRegistration : m_vecParamMapRegistration)
|
||||
{
|
||||
// Member parameter map entry
|
||||
if (rsRegistration.MemberMap() && rsRegistration.MemberMap()->Access())
|
||||
{
|
||||
if (rsRegistration.MemberMap()->Access()->IsParamMapDirty())
|
||||
return true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parameter entry
|
||||
if (rsRegistration.Parameter())
|
||||
{
|
||||
// Check if already present in the list
|
||||
if (setOneTime.find(rsRegistration.Parameter()->Name()) != setOneTime.end())
|
||||
continue;
|
||||
setOneTime.insert(rsRegistration.Parameter()->Name());
|
||||
|
||||
// Check for dirtiness
|
||||
if (rsRegistration.Parameter()->Dirty())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void CSdvParamMap::ResetParamMapDirtyFlags()
|
||||
{
|
||||
std::set<u8string> setOneTime;
|
||||
for (const auto& rsRegistration : m_vecParamMapRegistration)
|
||||
{
|
||||
// Member parameter map entry
|
||||
if (rsRegistration.MemberMap() && rsRegistration.MemberMap()->Access())
|
||||
{
|
||||
rsRegistration.MemberMap()->Access()->ResetParamMapDirtyFlags();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parameter entry
|
||||
if (rsRegistration.Parameter())
|
||||
{
|
||||
// Check if already present in the list
|
||||
if (setOneTime.find(rsRegistration.Parameter()->Name()) != setOneTime.end())
|
||||
continue;
|
||||
setOneTime.insert(rsRegistration.Parameter()->Name());
|
||||
|
||||
// Reset dirtiness
|
||||
rsRegistration.Parameter()->ResetDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void CSdvParamMap::LockParamMap()
|
||||
{
|
||||
for (const auto& rsRegistration : m_vecParamMapRegistration)
|
||||
{
|
||||
// Member parameter map entry
|
||||
if (rsRegistration.MemberMap() && rsRegistration.MemberMap()->Access())
|
||||
{
|
||||
rsRegistration.MemberMap()->Access()->LockParamMap();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parameter entry
|
||||
if (rsRegistration.Parameter())
|
||||
{
|
||||
// Lock
|
||||
rsRegistration.Parameter()->Lock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void CSdvParamMap::UnlockParamMap()
|
||||
{
|
||||
for (const auto& rsRegistration : m_vecParamMapRegistration)
|
||||
{
|
||||
// Member parameter map entry
|
||||
if (rsRegistration.MemberMap() && rsRegistration.MemberMap()->Access())
|
||||
{
|
||||
rsRegistration.MemberMap()->Access()->UnlockParamMap();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parameter entry
|
||||
if (rsRegistration.Parameter())
|
||||
{
|
||||
// Lock
|
||||
rsRegistration.Parameter()->Unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename TVar, typename... TConstruct>
|
||||
inline std::shared_ptr<CSdvParamInfo> CSdvParamMap::RegisterParameter(TVar& rtVar, bool bLockable, bool bAutoDirty,
|
||||
TConstruct... tConstruct)
|
||||
{
|
||||
auto ptrParam = std::make_shared<internal::CParamValue<TVar>>(rtVar, bLockable, bAutoDirty, tConstruct...);
|
||||
m_vecParamMapRegistration.push_back(SParamRegistration(ptrParam));
|
||||
return ptrParam;
|
||||
}
|
||||
|
||||
inline void CSdvParamMap::RegisterMemberMap(const std::shared_ptr<internal::SMemberMapAccess>& rptrMember)
|
||||
{
|
||||
m_vecParamMapRegistration.push_back(SParamRegistration(rptrMember));
|
||||
}
|
||||
|
||||
inline void CSdvParamMap::InitParamMap()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
inline bool CSdvParamMap::BuildNecessary() const
|
||||
{
|
||||
return m_vecParamMapRegistration.empty();
|
||||
}
|
||||
|
||||
template <typename TType>
|
||||
constexpr bool CSdvParamInfo::TypeIsString()
|
||||
{
|
||||
using TType2 = std::remove_cv_t<TType>;
|
||||
using TRoot = std::remove_cv_t<std::remove_pointer_t<std::remove_extent_t<TType2>>>;
|
||||
constexpr bool bArray = std::is_array_v<TType2>;
|
||||
constexpr bool bPointer = std::is_pointer_v<TType2>;
|
||||
constexpr bool bCharacter = std::is_same_v<TRoot, char> || std::is_same_v<TRoot, char16_t> ||
|
||||
std::is_same_v<TRoot, char32_t> || std::is_same_v<TRoot, wchar_t>;
|
||||
constexpr bool bStdString = std::is_same_v<TType2, std:: string> || std::is_same_v<TType2, std::u16string> ||
|
||||
std::is_same_v<TType2, std::u32string> || std::is_same_v<TType2, std::wstring>;
|
||||
constexpr bool bSdvString = std::is_same_v<TType2, string> || std::is_same_v<TType2, u8string> ||
|
||||
std::is_same_v<TType2, u16string> || std::is_same_v<TType2, u32string> || std::is_same_v<TType2, wstring>;
|
||||
constexpr bool bStdPath = std::is_same_v<TType2, std::filesystem::path>;
|
||||
return bStdString || bSdvString || (bArray && bCharacter) || (bPointer && bCharacter) || bStdPath;
|
||||
}
|
||||
|
||||
template <typename TType>
|
||||
constexpr bool CSdvParamInfo::TypeIsReadOnly()
|
||||
{
|
||||
using TType2 = std::remove_cv_t<TType>;
|
||||
constexpr bool bArray = std::is_array_v<TType2>;
|
||||
constexpr bool bPointer = std::is_pointer_v<TType2>;
|
||||
return bArray || bPointer || std::is_const_v<TType>;
|
||||
}
|
||||
}; // namespace sdv
|
||||
|
||||
|
||||
#endif // !defined PARAM_IMPL_INL
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_PTR_H
|
||||
#define SDV_PTR_H
|
||||
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_PTR_INL
|
||||
#define SDV_PTR_INL
|
||||
|
||||
@@ -6,8 +19,8 @@
|
||||
#endif
|
||||
|
||||
#ifndef SDV_PTR_H
|
||||
#error Do not include "pointer.inl" directly. Include "pointer.h" instead!
|
||||
#endif //!defined SDV_PTR_H
|
||||
#include "pointer.h"
|
||||
#endif //! defined SDV_PTR_H
|
||||
|
||||
#include "pointer.h"
|
||||
#include <iostream>
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_PS_SUPPORT_H
|
||||
#define SDV_PS_SUPPORT_H
|
||||
|
||||
@@ -330,13 +343,12 @@ namespace sdv
|
||||
|
||||
// Interface map
|
||||
BEGIN_SDV_INTERFACE_MAP()
|
||||
SDV_INTERFACE_CHAIN_BASE(sdv::CSdvObject)
|
||||
SDV_INTERFACE_ENTRY(IMarshallObjectIdent)
|
||||
SDV_INTERFACE_ENTRY(IMarshallLink)
|
||||
END_SDV_INTERFACE_MAP()
|
||||
|
||||
// Object class type
|
||||
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::Proxy)
|
||||
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::proxy)
|
||||
|
||||
/**
|
||||
* @brief Set the identification. Overload of IMarshallObjectIdent::SetIdentification.
|
||||
@@ -396,13 +408,12 @@ namespace sdv
|
||||
|
||||
// Interface map
|
||||
BEGIN_SDV_INTERFACE_MAP()
|
||||
SDV_INTERFACE_CHAIN_BASE(sdv::CSdvObject)
|
||||
SDV_INTERFACE_ENTRY(IMarshallObjectIdent)
|
||||
SDV_INTERFACE_ENTRY(IMarshall)
|
||||
END_SDV_INTERFACE_MAP()
|
||||
|
||||
// Object class type
|
||||
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::Stub)
|
||||
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::stub)
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_PS_SUPPORT_INL
|
||||
#define SDV_PS_SUPPORT_INL
|
||||
|
||||
#ifndef SDV_PS_SUPPORT_H
|
||||
#error Do not include "pssup.inl" directly. Include "pssup.h" instead!
|
||||
#endif //!defined SDV_PS_SUPPORT_H
|
||||
#include "pssup.h"
|
||||
#endif //! defined SDV_PS_SUPPORT_H
|
||||
|
||||
#include "../interfaces/core_ps.h"
|
||||
#include "../interfaces/serdes/core_ps_serdes.h"
|
||||
@@ -23,8 +36,8 @@
|
||||
namespace serdes
|
||||
{
|
||||
/**
|
||||
* @brief Specialization of serializer/deserializer class for sdv::interface_t.
|
||||
*/
|
||||
* @brief Specialization of serializer/deserializer class for sdv::interface_t.
|
||||
*/
|
||||
template <>
|
||||
class CSerdes<sdv::interface_t>
|
||||
{
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_CORE_H
|
||||
#define SDV_CORE_H
|
||||
|
||||
@@ -48,6 +61,87 @@
|
||||
|
||||
namespace sdv
|
||||
{
|
||||
/**
|
||||
* @brief Get the object type string from the type
|
||||
* @param[in] eType The object type to get the string from.
|
||||
* @return The object type string.
|
||||
*/
|
||||
inline std::string ObjectType2String(sdv::EObjectType eType)
|
||||
{
|
||||
switch (eType)
|
||||
{
|
||||
case EObjectType::system_object:
|
||||
return "SystemObject";
|
||||
case EObjectType::device:
|
||||
return "Device";
|
||||
case EObjectType::platform_abstraction:
|
||||
return "PlatformAbstraction";
|
||||
case EObjectType::vehicle_bus:
|
||||
return "VehicleBus";
|
||||
case EObjectType::basic_service:
|
||||
return "BasicService";
|
||||
case EObjectType::sensor:
|
||||
return "Sensor";
|
||||
case EObjectType::actuator:
|
||||
return "Actuator";
|
||||
case EObjectType::complex_service:
|
||||
return "ComplexService";
|
||||
case EObjectType::vehicle_function:
|
||||
return "VehicleFunction";
|
||||
case EObjectType::application:
|
||||
return "Application";
|
||||
case EObjectType::proxy:
|
||||
return "Proxy";
|
||||
case EObjectType::stub:
|
||||
return "Stub";
|
||||
case EObjectType::utility:
|
||||
return "Utility";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the object type from the string
|
||||
* @param[in] rssType Reference to the string identifying the object type.
|
||||
* @return The object type or sdv::EObjectType::Undefined.
|
||||
*/
|
||||
inline EObjectType String2ObjectType(const std::string& rssType)
|
||||
{
|
||||
if (rssType == "SystemObject")
|
||||
return EObjectType::system_object;
|
||||
if (rssType == "Device")
|
||||
return EObjectType::device;
|
||||
if (rssType == "PlatformAbstraction")
|
||||
return EObjectType::platform_abstraction;
|
||||
if (rssType == "VehicleBus")
|
||||
return EObjectType::vehicle_bus;
|
||||
if (rssType == "BasicService")
|
||||
return EObjectType::basic_service;
|
||||
if (rssType == "Sensor")
|
||||
return EObjectType::sensor;
|
||||
if (rssType == "Actuator")
|
||||
return EObjectType::actuator;
|
||||
if (rssType == "ComplexService")
|
||||
return EObjectType::complex_service;
|
||||
if (rssType == "VehicleFunction")
|
||||
return EObjectType::complex_service;
|
||||
if (rssType == "Application")
|
||||
return EObjectType::application;
|
||||
if (rssType == "Proxy")
|
||||
return EObjectType::proxy;
|
||||
if (rssType == "Stub")
|
||||
return EObjectType::stub;
|
||||
if (rssType == "Utility")
|
||||
return EObjectType::utility;
|
||||
return EObjectType::undefined;
|
||||
}
|
||||
} // namespace sdv
|
||||
|
||||
|
||||
#ifndef SDV_NO_LOADER
|
||||
namespace sdv{
|
||||
|
||||
namespace core
|
||||
{
|
||||
namespace internal
|
||||
@@ -345,6 +439,6 @@ namespace sdv
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !defined SDV_NO_LOADER
|
||||
|
||||
#endif // !define SDV_CORE_H
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_SEQUENCE_H
|
||||
#define SDV_SEQUENCE_H
|
||||
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_SEQUENCE_INL
|
||||
#define SDV_SEQUENCE_INL
|
||||
|
||||
#ifndef SDV_SEQUENCE_H
|
||||
#error Do not include "sequence.inl" directly. Include "sequence.h" instead!
|
||||
#endif //!defined SDV_SEQUENCE_H
|
||||
#include "sequence.h"
|
||||
#endif //! defined SDV_SEQUENCE_H
|
||||
|
||||
namespace sdv
|
||||
{
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_SERDES_H
|
||||
#define SDV_SERDES_H
|
||||
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_SERDES_INL
|
||||
#define SDV_SERDES_INL
|
||||
|
||||
#ifndef SDV_SERDES_H
|
||||
#error Do not include "serdes.inl" directly. Include "serdes.h" instead!
|
||||
#endif //!defined SDV_SERDES_H
|
||||
#include "serdes.h"
|
||||
#endif //! defined SDV_SERDES_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
/**
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* @file signal_support.h
|
||||
* @brief This file provides base-implementations and helpers for signals and signal handling.
|
||||
* @version 0.1
|
||||
* @date 2022.11.14
|
||||
* @author Thomas.pfleiderer@zf.com
|
||||
* @copyright Copyright ZF Friedrichshaven AG (c) 2022
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*/
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SIGNAL_SUPPORT_H
|
||||
#define SIGNAL_SUPPORT_H
|
||||
|
||||
@@ -409,7 +412,7 @@ namespace sdv
|
||||
template <typename TType>
|
||||
void Write(TType tVal, const CTransaction& rTransaction = CTransaction())
|
||||
{
|
||||
if (m_pSignalWrite) m_pSignalWrite->Write(any_t(tVal), rTransaction.GetTransaction());
|
||||
if (m_pSignalWrite) m_pSignalWrite->Write(tVal, rTransaction.GetTransaction());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -747,7 +750,7 @@ namespace sdv
|
||||
CSignal signal;
|
||||
if (pRegister)
|
||||
signal = CSignal(*this, rssName,
|
||||
pRegister->RegisterTxSignal(rssName, any_t(tDefVal)),
|
||||
pRegister->RegisterTxSignal(rssName, tDefVal),
|
||||
true);
|
||||
return signal;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_STRING_H
|
||||
#define SDV_STRING_H
|
||||
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_STRING_INL
|
||||
#define SDV_STRING_INL
|
||||
|
||||
#ifndef SDV_STRING_H
|
||||
#error Do not include "string.inl" directly. Include "string.h" instead!
|
||||
#endif //!defined SDV_STRING_H
|
||||
#include "string.h"
|
||||
#endif //! defined SDV_STRING_H
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
@@ -2926,7 +2939,7 @@ namespace sdv
|
||||
template <typename TCharType, bool bUnicode, size_t nFixedSize>
|
||||
inline std::filesystem::path MakePath(const string_base<TCharType, bUnicode, nFixedSize>& rssPath)
|
||||
{
|
||||
std::filesystem::path path(MakeWString(rssPath).c_str());
|
||||
std::filesystem::path path(static_cast<std::wstring>(MakeWString(rssPath)));
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef VAPI_TASK_TIMER_H
|
||||
#define VAPI_TASK_TIMER_H
|
||||
|
||||
@@ -25,20 +38,21 @@ namespace sdv
|
||||
* @brief Constructor
|
||||
* @param[in] uiPeriod The period to create a timer for.
|
||||
* @param[in] fnCallback Callback function to be called on task execution.
|
||||
* @param[in] bUseSimTimer Use the simulated task timer instead of the actual task timer.
|
||||
*/
|
||||
CTaskTimer(uint32_t uiPeriod, std::function<void()> fnCallback) :
|
||||
CTaskTimer(uint32_t uiPeriod, std::function<void()> fnCallback, bool bUseSimTimer = false) :
|
||||
m_ptrCallback(std::make_unique<STimerCallback>(fnCallback))
|
||||
{
|
||||
if (!m_ptrCallback) return;
|
||||
if (!uiPeriod) return;
|
||||
|
||||
// Get the task timer service.
|
||||
sdv::core::ITaskTimer* pTaskTimer = sdv::core::GetObject<sdv::core::ITaskTimer>("TaskTimerService");
|
||||
if (!pTaskTimer)
|
||||
{
|
||||
sdv::core::ITaskTimer* pTaskTimer = nullptr;
|
||||
if (bUseSimTimer)
|
||||
pTaskTimer = sdv::core::GetObject<sdv::core::ITaskTimer>("SimulationTaskTimerService");
|
||||
if (!pTaskTimer) return;
|
||||
}
|
||||
else
|
||||
pTaskTimer = sdv::core::GetObject<sdv::core::ITaskTimer>("TaskTimerService");
|
||||
if (!pTaskTimer) return;
|
||||
|
||||
// Create the timer
|
||||
m_pTimer = pTaskTimer->CreateTimer(uiPeriod, m_ptrCallback.get());
|
||||
@@ -49,18 +63,20 @@ namespace sdv
|
||||
* @param[in] uiPeriod The period to create a timer for.
|
||||
* @param[in] pTask Pointer to the interface of the task object to be called. The object must expose
|
||||
* sdv::core::ITastExecute.
|
||||
*/
|
||||
CTaskTimer(uint32_t uiPeriod, sdv::IInterfaceAccess* pTask)
|
||||
* @param[in] bUseSimTimer Use the simulated task timer instead of the actual task timer.
|
||||
*/
|
||||
CTaskTimer(uint32_t uiPeriod, sdv::IInterfaceAccess* pTask, bool bUseSimTimer = false)
|
||||
{
|
||||
if (!uiPeriod) return;
|
||||
|
||||
// Get the task timer service.
|
||||
sdv::core::ITaskTimer* pTaskTimer = sdv::core::GetObject<sdv::core::ITaskTimer>("TaskTimerService");
|
||||
if (!pTaskTimer)
|
||||
{
|
||||
sdv::core::ITaskTimer* pTaskTimer = nullptr;
|
||||
if (bUseSimTimer)
|
||||
pTaskTimer = sdv::core::GetObject<sdv::core::ITaskTimer>("SimulationTaskTimerService");
|
||||
if (!pTaskTimer) return;
|
||||
}
|
||||
else
|
||||
pTaskTimer = sdv::core::GetObject<sdv::core::ITaskTimer>("TaskTimerService");
|
||||
if (!pTaskTimer)
|
||||
return;
|
||||
|
||||
// Create the timer
|
||||
m_pTimer = pTaskTimer->CreateTimer(uiPeriod, pTask);
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SDV_CONFIG_H
|
||||
#define SDV_CONFIG_H
|
||||
|
||||
@@ -43,11 +56,17 @@ namespace sdv::toml
|
||||
*/
|
||||
virtual operator bool() const;
|
||||
|
||||
/**
|
||||
* @brief Get the underlying interface.
|
||||
* @return The interface pointer.
|
||||
*/
|
||||
TInterfaceAccessPtr GetInterface();
|
||||
|
||||
/**
|
||||
* @brief Return the node name.
|
||||
* @return String containing the node name.
|
||||
*/
|
||||
sdv::u8string GetName();
|
||||
sdv::u8string GetName() const;
|
||||
|
||||
/**
|
||||
* @brief Retrurn the node qualified path including the parent path.
|
||||
@@ -55,19 +74,58 @@ namespace sdv::toml
|
||||
* to the node can be used to directly access the node.
|
||||
* @return String containing the qualified path to the node.
|
||||
*/
|
||||
sdv::u8string GetQualifiedPath();
|
||||
sdv::u8string GetQualifiedPath() const;
|
||||
|
||||
/**
|
||||
* @brief Get the node type.
|
||||
* @return The node type.
|
||||
*/
|
||||
ENodeType GetType();
|
||||
ENodeType GetType() const;
|
||||
|
||||
/**
|
||||
* @brief Return any associated comment text for this node.
|
||||
* @return The node comment or an empty string when there is not comment for this node.
|
||||
*/
|
||||
std::string GetComment() const;
|
||||
|
||||
/**
|
||||
* @brief Set comment for this node. Comments are placed before the node if this node is a table or an array and placed
|
||||
* behind the node if this node is a value node.
|
||||
* @param rssComment Reference to the comment string.
|
||||
*/
|
||||
void SetComment(const std::string& rssComment);
|
||||
|
||||
/**
|
||||
* @brief Get the node value if the node contains a value.
|
||||
* @return The node value.
|
||||
* @return The node value or empty when the node doesn't have a value.
|
||||
*/
|
||||
sdv::any_t GetValue();
|
||||
sdv::any_t GetValue() const;
|
||||
|
||||
/**
|
||||
* @brief Automatically cast the value to a string.
|
||||
* @return String to return or an empty string.
|
||||
*/
|
||||
std::string GetValueAsString() const;
|
||||
|
||||
/**
|
||||
* @brief Automatically cast the value to a path (only for string values).
|
||||
* @return Path to return or an empty path.
|
||||
*/
|
||||
std::filesystem::path GetValueAsPath() const;
|
||||
|
||||
/**
|
||||
* @brief Set the node value if the node is a value node.
|
||||
* @remarks The value type depends on the node type and will be converted if necessary.
|
||||
* @param[in] ranyValue Reference to the value to set.
|
||||
* @return Returns 'true' on successful setting; 'false' otherwise.
|
||||
*/
|
||||
bool SetValue(const sdv::any_t& ranyValue);
|
||||
|
||||
/**
|
||||
* @brief Delete the node including all child nodes.
|
||||
* @return Returns 'true' on successful setting; 'false' otherwise.
|
||||
*/
|
||||
bool Delete();
|
||||
|
||||
/**
|
||||
* @brief Clear the node class.
|
||||
@@ -76,7 +134,7 @@ namespace sdv::toml
|
||||
|
||||
/**
|
||||
* @brief Get the TOML string from this node including all children.
|
||||
* @return The TOMl string.
|
||||
* @return The TOML string.
|
||||
*/
|
||||
sdv::u8string GetTOML() const;
|
||||
|
||||
@@ -170,6 +228,140 @@ namespace sdv::toml
|
||||
*/
|
||||
CNode GetDirect(const sdv::u8string& rssNode) const;
|
||||
|
||||
/**
|
||||
* @brief Insert a value node before the provided position.
|
||||
* @remarks The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before
|
||||
* standard nodes.
|
||||
* @param[in] nIndex The index before which to insert the node. Can be larger than the count value as well as
|
||||
* sdv::toml::npos when adding the node at the end.
|
||||
* @param[in] rssName Reference to the name of the new value node. If this collection is an array, the name is ignored.
|
||||
* Otherwise the name must be unique within this collection.
|
||||
* @param[in] ranyValue The value to assign to the node. The value also determines the type of value node.
|
||||
* @return Returns the node when successfully inserted or an empty node when not.
|
||||
*/
|
||||
CNode InsertValue(size_t nIndex, const std::string& rssName, const sdv::any_t& ranyValue);
|
||||
|
||||
/**
|
||||
* @brief Add a value node to the collection.
|
||||
* @remarks The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before
|
||||
* standard nodes.
|
||||
* @param[in] rssName Reference to the name of the new array collection node. If this collection is an array, the name is
|
||||
* ignored. Otherwise the name must be unique within this collection.
|
||||
* @param[in] ranyValue The value to assign to the node. The value also determines the type of value node.
|
||||
* @return Returns the node when successfully added or an empty node when not.
|
||||
*/
|
||||
CNode AddValue(const std::string& rssName, const sdv::any_t& ranyValue);
|
||||
|
||||
/**
|
||||
* @brief Insert an array collection before the provided position.
|
||||
* @remarks The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before
|
||||
* standard nodes.
|
||||
* @param[in] nIndex The index before which to insert the node. Can be larger than the count value as well as
|
||||
* sdv::toml::npos when adding the node at the end.
|
||||
* @param[in] rssName Reference to the name of the new value node. If this collection is an array, the name is ignored.
|
||||
* Otherwise the name must be unique within this collection.
|
||||
* @return Returns the collection node when successfully inserted or an empty node when not.
|
||||
*/
|
||||
CNodeCollection InsertArray(size_t nIndex, const std::string& rssName);
|
||||
|
||||
/**
|
||||
* @brief Add an array collection to this collection.
|
||||
* @remarks The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before
|
||||
* standard nodes.
|
||||
* @param[in] rssName Reference to the name of the new array collection node. If this collection is an array, the name is
|
||||
* ignored. Otherwise the name must be unique within this collection.
|
||||
* @return Returns the collection node when successfully added or an empty node when not.
|
||||
*/
|
||||
CNodeCollection AddArray(const std::string& rssName);
|
||||
|
||||
/**
|
||||
* @brief Insert a table collection before the provided position.
|
||||
* @remarks The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before
|
||||
* standard nodes.
|
||||
* @param[in] nIndex The index before which to insert the node. Can be larger than the count value as well as
|
||||
* sdv::toml::npos when adding the node at the end.
|
||||
* @param[in] rssName Reference to the name of the new table collection node. If this collection is an array, the name is
|
||||
* ignored. Otherwise the name must be unique within this collection.
|
||||
* @param[in] bFavorInline When set, the node will be added as inline collection node. When not, the node will be inserted
|
||||
* as inline collection if the this collection is also inline, as standard when not.
|
||||
* @return Returns the collection node when successfully inserted or an empty node when not.
|
||||
*/
|
||||
CNodeCollection InsertTable(size_t nIndex, const std::string& rssName, bool bFavorInline = false);
|
||||
|
||||
/**
|
||||
* @brief Add a table collection to this collection.
|
||||
* @remarks The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before
|
||||
* standard nodes.
|
||||
* @param[in] rssName Reference to the name of the new table collection node. If this collection is an array, the name is
|
||||
* ignored. Otherwise the name must be unique within this collection.
|
||||
* @param[in] bFavorInline When set, the node will be added as inline collection node. When not, the node will be inserted
|
||||
* as inline collection if the this collection is also inline, as standard when not.
|
||||
* @return Returns the collection node when successfully added or an empty node when not.
|
||||
*/
|
||||
CNodeCollection AddTable(const std::string& rssName, bool bFavorInline = false);
|
||||
|
||||
/**
|
||||
* @brief Insert a table array collection before the provided position.
|
||||
* @remarks The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before
|
||||
* standard nodes.
|
||||
* @remarks A table array is an array with table inside. Inserting a table array node can also be done by creating an array,
|
||||
* if not existing already, and adding a table to the array.
|
||||
* @param[in] nIndex The index before which to insert the node. Can be larger than the count value as well as
|
||||
* sdv::toml::npos when adding the node at the end.
|
||||
* @param[in] rssName Reference to the name of the new table array node. If this collection is an array, the name is
|
||||
* ignored. Otherwise the name must be unique within this collection.
|
||||
* @param[in] bFavorInline When set, the node will be added as inline collection node. When not, the node will be inserted
|
||||
* as inline collection if the this collection is also inline, as standard when not.
|
||||
* @return Returns the collection node when successfully inserted or an empty node when not. The collection node represents
|
||||
* a table collection.
|
||||
*/
|
||||
CNodeCollection InsertTableArray(size_t nIndex, const std::string& rssName, bool bFavorInline = false);
|
||||
|
||||
/**
|
||||
* @brief Add a table array collection to this collection.
|
||||
* @remarks The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before
|
||||
* standard nodes.
|
||||
* @remarks A table array is an array with table inside. Inserting a table array node can also be done by creating an array,
|
||||
* if not existing already, and adding a table to the array.
|
||||
* @param[in] rssName Reference to the name of the new table array node. If this collection is an array, the name is
|
||||
* ignored. Otherwise the name must be unique within this collection.
|
||||
* @param[in] bFavorInline When set, the node will be added as inline collection node. When not, the node will be inserted
|
||||
* as inline collection if the this collection is also inline, as standard when not.
|
||||
* @return Returns the collection node when successfully inserted or an empty node when not. The collection node represents
|
||||
* a table collection.
|
||||
*/
|
||||
CNodeCollection AddTableArray(const std::string& rssName, bool bFavorInline = false);
|
||||
|
||||
/**
|
||||
* @brief Insert a TOML string to the collection. All nodes specified in the TOML will be added in the collection except
|
||||
* when the nodes already exist. Comment and whitespace are preserved when possible.
|
||||
* @remarks The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before
|
||||
* standard nodes.
|
||||
* @param[in] nIndex The index before which to insert the node. Can be larger than the count value as well as
|
||||
* sdv::toml::npos when adding the node at the end.
|
||||
* @param[in] rssTOML Reference to the TOML string containing the nodes. The TOML string can be empty, which is not an
|
||||
* error. If required the TOML nodes are converted to inline nodes.
|
||||
* @param[in] bAllowPartial When set, duplicate nodes (already present in this collection) will be ignored and do not
|
||||
* cause an error. When not set, duplicate nodes will cause the function to return without inserting any node.
|
||||
* @return Returns 1 if the complete TOMl could be inserted, 0 if no TOML could be inserted or -1 when the TOML could be
|
||||
* partially inserted.
|
||||
*/
|
||||
int InsertTOML(size_t nIndex, const std::string& rssTOML, bool bAllowPartial = false);
|
||||
|
||||
/**
|
||||
* @brief Add a TOML string to this collection. All nodes specified in the TOML will be added in the collection except
|
||||
* when the nodes already exist. Comment and whitespace are preserved when possible.
|
||||
* @remarks The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before
|
||||
* standard nodes.
|
||||
* @param[in] rssTOML Reference to the TOML string containing the nodes. The TOML string can be empty, which is not an
|
||||
* error. If required the TOML nodes are converted to inline nodes.
|
||||
* @param[in] bAllowPartial When set, duplicate nodes (already present in this collection) will be ignored and do not
|
||||
* cause an error. When not set, duplicate nodes will cause the function to return without inserting any node.
|
||||
* @return Returns 1 if the complete TOMl could be inserted, 0 if no TOML could be inserted or -1 when the TOML could be
|
||||
* partially inserted.
|
||||
*/
|
||||
int AddTOML(const std::string& rssTOML, bool bAllowPartial = false);
|
||||
|
||||
private:
|
||||
INodeCollection* m_pCollection = nullptr; ///< Pointer to the node collection interface.
|
||||
};
|
||||
@@ -225,8 +417,7 @@ namespace sdv::toml
|
||||
inline CNode::CNode(const TInterfaceAccessPtr& rptrNode)
|
||||
{
|
||||
m_pNodeInfo = rptrNode.GetInterface<INodeInfo>();
|
||||
if (!m_pNodeInfo)
|
||||
return;
|
||||
if (!m_pNodeInfo) return;
|
||||
m_ptrNode = rptrNode;
|
||||
}
|
||||
|
||||
@@ -250,26 +441,95 @@ namespace sdv::toml
|
||||
return m_pNodeInfo ? true : false;
|
||||
}
|
||||
|
||||
inline sdv::u8string CNode::GetName()
|
||||
inline TInterfaceAccessPtr CNode::GetInterface()
|
||||
{
|
||||
return m_ptrNode;
|
||||
}
|
||||
|
||||
inline sdv::u8string CNode::GetName() const
|
||||
{
|
||||
return m_pNodeInfo ? m_pNodeInfo->GetName() : sdv::u8string();
|
||||
}
|
||||
|
||||
inline sdv::u8string CNode::GetQualifiedPath()
|
||||
inline sdv::u8string CNode::GetQualifiedPath() const
|
||||
{
|
||||
return m_pNodeInfo ? m_pNodeInfo->GetPath(true) : sdv::u8string();
|
||||
}
|
||||
|
||||
inline ENodeType CNode::GetType()
|
||||
inline ENodeType CNode::GetType() const
|
||||
{
|
||||
return m_pNodeInfo ? m_pNodeInfo->GetType() : ENodeType::node_invalid;
|
||||
}
|
||||
|
||||
inline sdv::any_t CNode::GetValue()
|
||||
inline std::string CNode::GetComment() const
|
||||
{
|
||||
if (!m_pNodeInfo) return {};
|
||||
std::string ssComment;
|
||||
switch (GetType())
|
||||
{
|
||||
case ENodeType::node_boolean:
|
||||
case ENodeType::node_integer:
|
||||
case ENodeType::node_floating_point:
|
||||
case ENodeType::node_string:
|
||||
ssComment = m_pNodeInfo->GetComment(INodeInfo::ECommentType::comment_behind);
|
||||
if (ssComment.empty())
|
||||
ssComment = m_pNodeInfo->GetComment(INodeInfo::ECommentType::comment_before);
|
||||
break;
|
||||
default:
|
||||
ssComment = m_pNodeInfo->GetComment(INodeInfo::ECommentType::comment_before);
|
||||
if (ssComment.empty())
|
||||
ssComment = m_pNodeInfo->GetComment(INodeInfo::ECommentType::comment_behind);
|
||||
break;
|
||||
}
|
||||
return ssComment;
|
||||
}
|
||||
|
||||
inline void CNode::SetComment(const std::string& rssComment)
|
||||
{
|
||||
if (!m_pNodeInfo) return;
|
||||
switch (GetType())
|
||||
{
|
||||
case ENodeType::node_boolean:
|
||||
case ENodeType::node_integer:
|
||||
case ENodeType::node_floating_point:
|
||||
case ENodeType::node_string:
|
||||
m_pNodeInfo->SetComment(INodeInfo::ECommentType::comment_behind, rssComment);
|
||||
break;
|
||||
default:
|
||||
m_pNodeInfo->SetComment(INodeInfo::ECommentType::comment_before, rssComment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline sdv::any_t CNode::GetValue() const
|
||||
{
|
||||
return m_pNodeInfo ? m_pNodeInfo->GetValue() : sdv::any_t();
|
||||
}
|
||||
|
||||
inline std::string CNode::GetValueAsString() const
|
||||
{
|
||||
return m_pNodeInfo ? m_pNodeInfo->GetValue().get<std::string>() : std::string();
|
||||
}
|
||||
|
||||
inline std::filesystem::path CNode::GetValueAsPath() const
|
||||
{
|
||||
return m_pNodeInfo ? m_pNodeInfo->GetValue().get<std::filesystem::path>() : std::filesystem::path();
|
||||
}
|
||||
|
||||
inline bool CNode::SetValue(const sdv::any_t& ranyValue)
|
||||
{
|
||||
INodeUpdate* pNodeUpdate = m_ptrNode.GetInterface<INodeUpdate>();
|
||||
if (!pNodeUpdate) return false;
|
||||
return pNodeUpdate->ChangeValue(ranyValue);
|
||||
}
|
||||
|
||||
inline bool CNode::Delete()
|
||||
{
|
||||
INodeUpdate* pNodeUpdate = m_ptrNode.GetInterface<INodeUpdate>();
|
||||
if (!pNodeUpdate) return false;
|
||||
return pNodeUpdate->DeleteNode();
|
||||
}
|
||||
|
||||
inline void CNode::Clear()
|
||||
{
|
||||
m_ptrNode = nullptr;
|
||||
@@ -345,6 +605,105 @@ namespace sdv::toml
|
||||
return m_pCollection ? CNode(m_pCollection->GetNodeDirect(rssNode)) : CNode();
|
||||
}
|
||||
|
||||
inline CNode CNodeCollection::InsertValue(size_t nIndex, const std::string& rssName, const sdv::any_t& ranyValue)
|
||||
{
|
||||
INodeCollectionInsert* pInsert = m_ptrNode.GetInterface<INodeCollectionInsert>();
|
||||
if (!pInsert) return {};
|
||||
return CNode(pInsert->InsertValue(static_cast<uint32_t>(nIndex), rssName, ranyValue));
|
||||
}
|
||||
|
||||
inline CNode CNodeCollection::AddValue(const std::string& rssName, const sdv::any_t& ranyValue)
|
||||
{
|
||||
INodeCollectionInsert* pInsert = m_ptrNode.GetInterface<INodeCollectionInsert>();
|
||||
if (!pInsert) return {};
|
||||
return CNode(pInsert->InsertValue(npos, rssName, ranyValue));
|
||||
}
|
||||
|
||||
inline CNodeCollection CNodeCollection::InsertArray(size_t nIndex, const std::string& rssName)
|
||||
{
|
||||
INodeCollectionInsert* pInsert = m_ptrNode.GetInterface<INodeCollectionInsert>();
|
||||
if (!pInsert) return {};
|
||||
return CNodeCollection(pInsert->InsertArray(static_cast<uint32_t>(nIndex), rssName));
|
||||
}
|
||||
|
||||
inline CNodeCollection CNodeCollection::AddArray(const std::string& rssName)
|
||||
{
|
||||
INodeCollectionInsert* pInsert = m_ptrNode.GetInterface<INodeCollectionInsert>();
|
||||
if (!pInsert) return {};
|
||||
return CNodeCollection(pInsert->InsertArray(npos, rssName));
|
||||
}
|
||||
|
||||
inline CNodeCollection CNodeCollection::InsertTable(size_t nIndex, const std::string& rssName, bool bFavorInline /*= false*/)
|
||||
{
|
||||
INodeCollectionInsert* pInsert = m_ptrNode.GetInterface<INodeCollectionInsert>();
|
||||
if (!pInsert) return {};
|
||||
return CNodeCollection(pInsert->InsertTable(static_cast<uint32_t>(nIndex), rssName,
|
||||
bFavorInline ? INodeCollectionInsert::EInsertPreference::prefer_inline :
|
||||
INodeCollectionInsert::EInsertPreference::prefer_standard));
|
||||
}
|
||||
|
||||
inline CNodeCollection CNodeCollection::AddTable(const std::string& rssName, bool bFavorInline /*= false*/)
|
||||
{
|
||||
INodeCollectionInsert* pInsert = m_ptrNode.GetInterface<INodeCollectionInsert>();
|
||||
if (!pInsert) return {};
|
||||
return CNodeCollection(pInsert->InsertTable(npos, rssName,
|
||||
bFavorInline ? INodeCollectionInsert::EInsertPreference::prefer_inline :
|
||||
INodeCollectionInsert::EInsertPreference::prefer_standard));
|
||||
}
|
||||
|
||||
inline CNodeCollection CNodeCollection::InsertTableArray(size_t nIndex, const std::string& rssName,
|
||||
bool bFavorInline /*= false*/)
|
||||
{
|
||||
INodeCollectionInsert* pInsert = m_ptrNode.GetInterface<INodeCollectionInsert>();
|
||||
if (!pInsert) return {};
|
||||
return CNodeCollection(pInsert->InsertTableArray(static_cast<uint32_t>(nIndex), rssName,
|
||||
bFavorInline ? INodeCollectionInsert::EInsertPreference::prefer_inline :
|
||||
INodeCollectionInsert::EInsertPreference::prefer_standard));
|
||||
}
|
||||
|
||||
inline CNodeCollection CNodeCollection::AddTableArray(const std::string& rssName, bool bFavorInline /*= false*/)
|
||||
{
|
||||
INodeCollectionInsert* pInsert = m_ptrNode.GetInterface<INodeCollectionInsert>();
|
||||
if (!pInsert) return {};
|
||||
return CNodeCollection(pInsert->InsertTableArray(npos, rssName,
|
||||
bFavorInline ? INodeCollectionInsert::EInsertPreference::prefer_inline :
|
||||
INodeCollectionInsert::EInsertPreference::prefer_standard));
|
||||
}
|
||||
|
||||
inline int CNodeCollection::InsertTOML(size_t nIndex, const std::string& rssTOML, bool bAllowPartial /*= false*/)
|
||||
{
|
||||
INodeCollectionInsert* pInsert = m_ptrNode.GetInterface<INodeCollectionInsert>();
|
||||
if (!pInsert) return 0;
|
||||
INodeCollectionInsert::EInsertResult eRet = pInsert->InsertTOML(static_cast<uint32_t>(nIndex), rssTOML, !bAllowPartial);
|
||||
switch (eRet)
|
||||
{
|
||||
case INodeCollectionInsert::EInsertResult::insert_success:
|
||||
return 1;
|
||||
case INodeCollectionInsert::EInsertResult::insert_partly_success:
|
||||
return -1;
|
||||
case INodeCollectionInsert::EInsertResult::insert_fail:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline int CNodeCollection::AddTOML(const std::string& rssTOML, bool bAllowPartial /*= false*/)
|
||||
{
|
||||
INodeCollectionInsert* pInsert = m_ptrNode.GetInterface<INodeCollectionInsert>();
|
||||
if (!pInsert) return 0;
|
||||
INodeCollectionInsert::EInsertResult eRet = pInsert->InsertTOML(npos, rssTOML, !bAllowPartial);
|
||||
switch (eRet)
|
||||
{
|
||||
case INodeCollectionInsert::EInsertResult::insert_success:
|
||||
return 1;
|
||||
case INodeCollectionInsert::EInsertResult::insert_partly_success:
|
||||
return -1;
|
||||
case INodeCollectionInsert::EInsertResult::insert_fail:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline CTOMLParser::CTOMLParser(const std::string& rssConfig)
|
||||
{
|
||||
Process(rssConfig);
|
||||
|
||||
Reference in New Issue
Block a user