Skip to content

Commit

Permalink
Finished settings wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
pasotee committed May 12, 2024
1 parent a390945 commit 75872a3
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Fill out your copyright notice in the Description page of Project Settings.


#include "Wrapper/ConfigCatPercentageOptionsWrapper.h"
Original file line number Diff line number Diff line change
@@ -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 {};
}
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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<const configcat::Settings>& InSettings)
{
UConfigCatSettingsWrapper* Result = NewObject<UConfigCatSettingsWrapper>();
Result->SetSettings(InSettings);
Result->Settings = InSettings;
return Result;
}

Expand All @@ -63,9 +82,4 @@ TMap<FString, UConfigCatSettingWrapper*> UConfigCatSettingsWrapper::GetSettings(
}

return Result;
}

void UConfigCatSettingsWrapper::SetSettings(const std::shared_ptr<const configcat::Settings>& InSettings)
{
Settings = InSettings;
}
Original file line number Diff line number Diff line change
@@ -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);

};
21 changes: 21 additions & 0 deletions Source/ConfigCat/Public/Wrapper/ConfigCatTargetingRulesWrapper.h
Original file line number Diff line number Diff line change
@@ -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);
};

Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,53 @@

#include "ConfigCatSettingsWrapper.generated.h"

UENUM()
enum EConfigCatSettingTypeWrapper
class UConfigCatPercentageOptionsWrapper;
class UConfigCatTargetingRulesWrapper;
class UConfigCatValueWrapper;

UENUM(BlueprintType)
enum EConfigCatSettingTypeWrapper : uint8
{
Boolean = 0,
String = 1,
Int = 2,
Double = 3,
};

UCLASS(DisplayName="Config Cat Settings", Hidden)
UCLASS(DisplayName="Config Cat Setting", Hidden)
class UConfigCatSettingWrapper : public UObject
{
GENERATED_BODY()

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;

UFUNCTION(BlueprintPure, Category = "ConfigCat|Setting")
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()

Expand All @@ -56,8 +64,5 @@ class CONFIGCAT_API UConfigCatSettingsWrapper : public UObject
UFUNCTION(BlueprintPure, Category = "ConfigCat|Settings")
TMap<FString, UConfigCatSettingWrapper*> GetSettings() const;

void SetSettings(const std::shared_ptr<const configcat::Settings>& InSettings);

private:
std::shared_ptr<const configcat::Settings> Settings;
};

0 comments on commit 75872a3

Please sign in to comment.