ADD: added function to get all sensors as vector and map

This commit is contained in:
Henry Winkel
2024-03-14 18:23:00 +01:00
parent 87368640e2
commit 671f763f45
2 changed files with 39 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <sys/types.h> #include <sys/types.h>
#include <vector>
namespace Entities namespace Entities
{ {
@@ -69,6 +70,20 @@ namespace Entities
*/ */
std::shared_ptr<Sensor::SensorControl> getSensorByUUID(std::string uuid); std::shared_ptr<Sensor::SensorControl> getSensorByUUID(std::string uuid);
/**
* @brief Get the Sensor List As Vector of shared pointer of sensorcontrols
*
* @return std::vector<std::shared_ptr<Sensor::SensorControl>>
*/
std::vector<std::shared_ptr<Sensor::SensorControl>> getSensorListAsVector();
/**
* @brief Get the Sensor List As Map of shared pointer of sensorcontrols
*
* @return std::map<std::string, std::shared_ptr<Sensor::SensorControl>>
*/
std::map<std::string, std::shared_ptr<Sensor::SensorControl>> getSensorListAsMap();
/** /**

View File

@@ -87,6 +87,26 @@ namespace Entities
} }
std::vector<std::shared_ptr<Sensor::SensorControl>> SensorManager::getSensorListAsVector()
{
std::vector<std::shared_ptr<Sensor::SensorControl>> SensorVector;
for (auto [key, value] : SensorStore)
{
SensorVector.push_back(value);
}
return SensorVector;
}
std::map<std::string, std::shared_ptr<Sensor::SensorControl>> SensorManager::getSensorListAsMap()
{
return SensorStore;
}
size_t SensorManager::getSensorCount() size_t SensorManager::getSensorCount()
{ {
return SensorStore.size(); return SensorStore.size();
@@ -96,6 +116,7 @@ namespace Entities
void SensorManager::handlSensorMessages(std::string Message) void SensorManager::handlSensorMessages(std::string Message)
{ {
WHISPER::Message msg(Message); WHISPER::Message msg(Message);
@@ -263,6 +284,9 @@ namespace Entities
return Update; return Update;
} }