Agrarsense
SensorMapDataAsset.h
Go to the documentation of this file.
1// Copyright (c) 2023 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include "CoreMinimal.h"
9#include "Engine/DataAsset.h"
12#include "Containers/Map.h"
13#include "SensorMapDataAsset.generated.h"
14
15/*
16 * Data map asset for sensors. This data asset should be found in
17 * "/Game/Agrarsense/Data/Sensors/SensorMap.uasset"
18 */
19UCLASS(Blueprintable, BlueprintType)
20class AGRARSENSE_API USensorMapDataAsset : public UDataAsset
21{
22 GENERATED_BODY()
23
24public:
25 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Sensor map")
27
34 UFUNCTION(BlueprintCallable)
35 USensorDataAsset* GetAssetDataBySensorType(ESensorTypes SensorType, bool& MatchFound)
36 {
37 USensorDataAsset* sensorAsset = Sensors.FindRef(SensorType);
38
39 MatchFound = sensorAsset != nullptr;
40
41 return sensorAsset;
42
43 }
44
51 UFUNCTION(BlueprintCallable)
52 USensorDataAsset* GetAssetDataByUniqueIdentifier(const FString& UniqueIdentifier, bool& MatchFound) {
53 MatchFound = false;
54
55 // Iterate through the Sensors map
56 for (const TPair<ESensorTypes, USensorDataAsset*>& SensorPair : Sensors)
57 {
58 // Get the sensor's UniqueIdentifier
59 FString SensorUniqueIdentifier = SensorPair.Value->UniqueIdentifier;
60
61 // Check if the UniqueIdentifier of the current sensor matches the parameter
62 if (SensorUniqueIdentifier == UniqueIdentifier)
63 {
64 // Match found, set MatchFound to true and return the sensor
65 MatchFound = true;
66 return SensorPair.Value;
67 }
68 }
69
70 // No matching sensor found, return nullptr
71 return nullptr;
72 }
73};
ESensorTypes
Definition: SensorTypes.h:15
FString UniqueIdentifier