From 75872a3051a614ad23d13bb2a639a3998af804e2 Mon Sep 17 00:00:00 2001 From: Oprea Alexandru Date: Sun, 12 May 2024 14:37:34 +0300 Subject: [PATCH] Finished settings wrapper --- .../ConfigCatPercentageOptionsWrapper.cpp | 4 +++ .../Wrapper/ConfigCatTargetingRuleWrapper.cpp | 9 ++++++ .../ConfigCatSettingsWrapper.cpp | 28 ++++++++++++----- .../ConfigCatPercentageOptionsWrapper.h | 22 +++++++++++++ .../Wrapper/ConfigCatTargetingRulesWrapper.h | 21 +++++++++++++ .../ConfigCatSettingsWrapper.h | 31 +++++++++++-------- 6 files changed, 95 insertions(+), 20 deletions(-) create mode 100644 Source/ConfigCat/Private/Wrapper/ConfigCatPercentageOptionsWrapper.cpp create mode 100644 Source/ConfigCat/Private/Wrapper/ConfigCatTargetingRuleWrapper.cpp rename Source/ConfigCat/Private/{Wrapper => Wrappers}/ConfigCatSettingsWrapper.cpp (69%) create mode 100644 Source/ConfigCat/Public/Wrapper/ConfigCatPercentageOptionsWrapper.h create mode 100644 Source/ConfigCat/Public/Wrapper/ConfigCatTargetingRulesWrapper.h rename Source/ConfigCat/Public/{Wrapper => Wrappers}/ConfigCatSettingsWrapper.h (66%) diff --git a/Source/ConfigCat/Private/Wrapper/ConfigCatPercentageOptionsWrapper.cpp b/Source/ConfigCat/Private/Wrapper/ConfigCatPercentageOptionsWrapper.cpp new file mode 100644 index 0000000..cd3a8f7 --- /dev/null +++ b/Source/ConfigCat/Private/Wrapper/ConfigCatPercentageOptionsWrapper.cpp @@ -0,0 +1,4 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Wrapper/ConfigCatPercentageOptionsWrapper.h" \ No newline at end of file diff --git a/Source/ConfigCat/Private/Wrapper/ConfigCatTargetingRuleWrapper.cpp b/Source/ConfigCat/Private/Wrapper/ConfigCatTargetingRuleWrapper.cpp new file mode 100644 index 0000000..702a47d --- /dev/null +++ b/Source/ConfigCat/Private/Wrapper/ConfigCatTargetingRuleWrapper.cpp @@ -0,0 +1,9 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Wrapper/ConfigCatTargetingRulesWrapper.h" + +UConfigCatTargetingRulesWrapper* UConfigCatTargetingRulesWrapper::CreateTargetingRules(const configcat::TargetingRules& InPercentageOptions) +{ + return {}; +} diff --git a/Source/ConfigCat/Private/Wrapper/ConfigCatSettingsWrapper.cpp b/Source/ConfigCat/Private/Wrappers/ConfigCatSettingsWrapper.cpp similarity index 69% rename from Source/ConfigCat/Private/Wrapper/ConfigCatSettingsWrapper.cpp rename to Source/ConfigCat/Private/Wrappers/ConfigCatSettingsWrapper.cpp index f070a9d..810ea1c 100644 --- a/Source/ConfigCat/Private/Wrapper/ConfigCatSettingsWrapper.cpp +++ b/Source/ConfigCat/Private/Wrappers/ConfigCatSettingsWrapper.cpp @@ -1,6 +1,10 @@ // Fill out your copyright notice in the Description page of Project Settings. -#include "Wrapper/ConfigCatSettingsWrapper.h" +#include "Wrappers/ConfigCatSettingsWrapper.h" + +#include "Wrapper/ConfigCatPercentageOptionsWrapper.h" +#include "Wrapper/ConfigCatTargetingRulesWrapper.h" +#include "Wrappers/ConfigCatValueWrapper.h" using namespace configcat; @@ -41,10 +45,25 @@ FString UConfigCatSettingWrapper::GetVariationId() const return {}; } +UConfigCatValueWrapper* UConfigCatSettingWrapper::GetValue() const +{ + return UConfigCatValueWrapper::CreateValue(Setting.value); +} + +UConfigCatTargetingRulesWrapper* UConfigCatSettingWrapper::GetTargetingRules() const +{ + return UConfigCatTargetingRulesWrapper::CreateTargetingRules(Setting.targetingRules); +} + +UConfigCatPercentageOptionsWrapper* UConfigCatSettingWrapper::GetPercentageOptions() const +{ + return UConfigCatPercentageOptionsWrapper::CreatePercentageOptions(Setting.percentageOptions); +} + UConfigCatSettingsWrapper* UConfigCatSettingsWrapper::CreateSettings(const std::shared_ptr& InSettings) { UConfigCatSettingsWrapper* Result = NewObject(); - Result->SetSettings(InSettings); + Result->Settings = InSettings; return Result; } @@ -63,9 +82,4 @@ TMap UConfigCatSettingsWrapper::GetSettings( } return Result; -} - -void UConfigCatSettingsWrapper::SetSettings(const std::shared_ptr& InSettings) -{ - Settings = InSettings; } \ No newline at end of file diff --git a/Source/ConfigCat/Public/Wrapper/ConfigCatPercentageOptionsWrapper.h b/Source/ConfigCat/Public/Wrapper/ConfigCatPercentageOptionsWrapper.h new file mode 100644 index 0000000..8b7c52c --- /dev/null +++ b/Source/ConfigCat/Public/Wrapper/ConfigCatPercentageOptionsWrapper.h @@ -0,0 +1,22 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "ConfigCatCppSDK/Include/config.h" +#include "UObject/Object.h" +#include "ConfigCatPercentageOptionsWrapper.generated.h" + +/** + * + */ +UCLASS() +class CONFIGCAT_API UConfigCatPercentageOptionsWrapper : public UObject +{ + GENERATED_BODY() + + +public: + static UConfigCatPercentageOptionsWrapper* CreatePercentageOptions(const configcat::PercentageOptions& InPercentageOptions); + +}; diff --git a/Source/ConfigCat/Public/Wrapper/ConfigCatTargetingRulesWrapper.h b/Source/ConfigCat/Public/Wrapper/ConfigCatTargetingRulesWrapper.h new file mode 100644 index 0000000..be666e8 --- /dev/null +++ b/Source/ConfigCat/Public/Wrapper/ConfigCatTargetingRulesWrapper.h @@ -0,0 +1,21 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "ConfigCatCppSDK/Include/config.h" +#include "UObject/Object.h" +#include "ConfigCatTargetingRulesWrapper.generated.h" + +/** + * + */ +UCLASS() +class CONFIGCAT_API UConfigCatTargetingRulesWrapper : public UObject +{ + GENERATED_BODY() + +public: + static UConfigCatTargetingRulesWrapper* CreateTargetingRules(const configcat::TargetingRules& InPercentageOptions); +}; + diff --git a/Source/ConfigCat/Public/Wrapper/ConfigCatSettingsWrapper.h b/Source/ConfigCat/Public/Wrappers/ConfigCatSettingsWrapper.h similarity index 66% rename from Source/ConfigCat/Public/Wrapper/ConfigCatSettingsWrapper.h rename to Source/ConfigCat/Public/Wrappers/ConfigCatSettingsWrapper.h index 29aa912..601c732 100644 --- a/Source/ConfigCat/Public/Wrapper/ConfigCatSettingsWrapper.h +++ b/Source/ConfigCat/Public/Wrappers/ConfigCatSettingsWrapper.h @@ -8,8 +8,12 @@ #include "ConfigCatSettingsWrapper.generated.h" -UENUM() -enum EConfigCatSettingTypeWrapper +class UConfigCatPercentageOptionsWrapper; +class UConfigCatTargetingRulesWrapper; +class UConfigCatValueWrapper; + +UENUM(BlueprintType) +enum EConfigCatSettingTypeWrapper : uint8 { Boolean = 0, String = 1, @@ -17,7 +21,7 @@ enum EConfigCatSettingTypeWrapper Double = 3, }; -UCLASS(DisplayName="Config Cat Settings", Hidden) +UCLASS(DisplayName="Config Cat Setting", Hidden) class UConfigCatSettingWrapper : public UObject { GENERATED_BODY() @@ -25,6 +29,12 @@ class UConfigCatSettingWrapper : public UObject public: static UConfigCatSettingWrapper* CreateSetting(const configcat::Setting& InSetting); + UFUNCTION(BlueprintPure, Category = "ConfigCat|Setting") + FString GetVariationId() const; + + UFUNCTION(BlueprintPure, Category = "ConfigCat|Setting") + FString GetPercentageOptionsAttribute() const; + UFUNCTION(BlueprintPure, Category = "ConfigCat|Setting") bool HasInvalidType() const; @@ -32,21 +42,19 @@ class UConfigCatSettingWrapper : public UObject EConfigCatSettingTypeWrapper GetType() const; UFUNCTION(BlueprintPure, Category = "ConfigCat|Setting") - FString GetPercentageOptionsAttribute() const; + UConfigCatValueWrapper* GetValue() const; UFUNCTION(BlueprintPure, Category = "ConfigCat|Setting") - FString GetVariationId() const; + UConfigCatTargetingRulesWrapper* GetTargetingRules() const; - //TODO: add these: - // TargetingRules targetingRules; - // PercentageOptions percentageOptions; - // SettingValue value; + UFUNCTION(BlueprintPure, Category = "ConfigCat|Setting") + UConfigCatPercentageOptionsWrapper* GetPercentageOptions() const; configcat::Setting Setting; }; UCLASS(DisplayName="Config Cat Settings", Hidden) -class CONFIGCAT_API UConfigCatSettingsWrapper : public UObject +class UConfigCatSettingsWrapper : public UObject { GENERATED_BODY() @@ -56,8 +64,5 @@ class CONFIGCAT_API UConfigCatSettingsWrapper : public UObject UFUNCTION(BlueprintPure, Category = "ConfigCat|Settings") TMap GetSettings() const; - void SetSettings(const std::shared_ptr& InSettings); - -private: std::shared_ptr Settings; };