Agrarsense
Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
USensorManager Class Reference

#include <SensorManager.h>

Inheritance diagram for USensorManager:
Inheritance graph
[legend]
Collaboration diagram for USensorManager:
Collaboration graph
[legend]

Public Member Functions

 USensorManager ()
 
 ~USensorManager ()
 
TArray< ASensor * > GetAllSensors ()
 
TArray< ASensor * > GetAllSensorsOfType (ESensorTypes SensorType)
 

Static Public Member Functions

static USensorManagerGet ()
 

Public Attributes

FSensorSpawnedDelegate OnSensorSpawned
 
FSensorDestroyedDelegate OnSensorDestroyed
 

Static Private Member Functions

static void AddSensor (ASensor *SensorPtr)
 
static void RemoveSensor (ASensor *SensorPtr)
 

Private Attributes

TArray< ASensor * > Sensors
 

Static Private Attributes

static USensorManagerInstance = nullptr
 

Friends

class ASensor
 

Detailed Description

Sensor Manager.

Definition at line 22 of file SensorManager.h.

Constructor & Destructor Documentation

◆ USensorManager()

USensorManager::USensorManager ( )

Definition at line 23 of file SensorManager.cpp.

24{
25 if (Instance)
26 {
27 // If Instance exists, destroy this manager.
28 this->ConditionalBeginDestroy();
29 }
30 else
31 {
32 // Set Instance to this
33 Instance = this;
34 }
35}
static USensorManager * Instance
Definition: SensorManager.h:73

References Instance.

◆ ~USensorManager()

USensorManager::~USensorManager ( )

Definition at line 37 of file SensorManager.cpp.

38{
39 if (Instance == this)
40 {
41 Instance = nullptr;
42 }
43}

References Instance.

Member Function Documentation

◆ AddSensor()

void USensorManager::AddSensor ( ASensor SensorPtr)
staticprivate

Definition at line 45 of file SensorManager.cpp.

46{
48 if (Manager && SensorPtr)
49 {
50 Manager->Sensors.Add(SensorPtr);
51 Manager->OnSensorSpawned.Broadcast(SensorPtr);
52 }
53}
static USensorManager * Get()
TArray< ASensor * > Sensors
Definition: SensorManager.h:76
FSensorSpawnedDelegate OnSensorSpawned
Definition: SensorManager.h:51

References Get(), OnSensorSpawned, and Sensors.

Referenced by ASensor::BeginPlay().

◆ Get()

USensorManager * USensorManager::Get ( )
static

Get USensorManager instance pointer.

Definition at line 11 of file SensorManager.cpp.

12{
13 if (!Instance)
14 {
15 // If Instance doesn't exists, create it.
16 USensorManager* Manager = NewObject<USensorManager>();
17 Manager->AddToRoot();
18 }
19
20 return Instance;
21}

References Instance.

Referenced by AddSensor(), UAgrarsenseStatics::GetSensorManager(), RemoveSensor(), and UAgrarsenseSettings::Setup().

◆ GetAllSensors()

TArray< ASensor * > USensorManager::GetAllSensors ( )

Retrieves all sensors currently managed by this Sensor Manager.

Returns
An array of ASensor pointers representing all sensors.

Definition at line 65 of file SensorManager.cpp.

66{
67 return Sensors;
68}

References Sensors.

◆ GetAllSensorsOfType()

TArray< ASensor * > USensorManager::GetAllSensorsOfType ( ESensorTypes  SensorType)

Retrieves sensors of a specific type currently managed by this Sensor Manager.

Parameters
SensorTypeThe type of sensors to retrieve.
Returns
An array of ASensor pointers representing sensors of the specified type.

Definition at line 70 of file SensorManager.cpp.

71{
72 TArray<ASensor*> SensorsOfType;
73
74 for (ASensor* Sensor : Sensors)
75 {
76 if (Sensor && Sensor->GetSensorType() == SensorType)
77 {
78 SensorsOfType.Add(Sensor);
79 }
80 }
81
82 return SensorsOfType;
83}
Definition: Sensor.h:44

References Sensors.

◆ RemoveSensor()

void USensorManager::RemoveSensor ( ASensor SensorPtr)
staticprivate

Definition at line 55 of file SensorManager.cpp.

56{
58 if (Manager && SensorPtr)
59 {
60 Manager->Sensors.Remove(SensorPtr);
61 Manager->OnSensorDestroyed.Broadcast(SensorPtr);
62 }
63}
FSensorDestroyedDelegate OnSensorDestroyed
Definition: SensorManager.h:58

References Get(), OnSensorDestroyed, and Sensors.

Referenced by ASensor::EndPlay().

Friends And Related Function Documentation

◆ ASensor

friend class ASensor
friend

Definition at line 67 of file SensorManager.h.

Member Data Documentation

◆ Instance

USensorManager * USensorManager::Instance = nullptr
staticprivate

Definition at line 73 of file SensorManager.h.

Referenced by Get(), USensorManager(), and ~USensorManager().

◆ OnSensorDestroyed

FSensorDestroyedDelegate USensorManager::OnSensorDestroyed

On Sensor Destroyed event. Called right before starting to destroy things at Sensor::EndPlay.

Definition at line 58 of file SensorManager.h.

Referenced by RemoveSensor(), and UAgrarsenseSettings::Setup().

◆ OnSensorSpawned

FSensorSpawnedDelegate USensorManager::OnSensorSpawned

On Sensor spawned event. Called last in Sensor::BeginPlay

Definition at line 51 of file SensorManager.h.

Referenced by AddSensor(), and UAgrarsenseSettings::Setup().

◆ Sensors

TArray<ASensor*> USensorManager::Sensors
private

Definition at line 76 of file SensorManager.h.

Referenced by AddSensor(), GetAllSensors(), GetAllSensorsOfType(), and RemoveSensor().


The documentation for this class was generated from the following files: