1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-13 05:53:06 +01:00

change api for getBoatDataValues

This commit is contained in:
wellenvogel
2021-12-05 21:25:12 +01:00
parent 461d4924ad
commit 7b4ab178c2
7 changed files with 57 additions and 42 deletions

View File

@@ -334,6 +334,11 @@ bool GwBoatData::isValid(String name){
if (it == values.end()) return false;
return it->second->isValid();
}
GwBoatItemBase* GwBoatData::getBase(String name){
auto it=values.find(name);
if (it == values.end()) return NULL;
return it->second;
}
double GwBoatData::getDoubleValue(String name,double defaultv){
auto it=values.find(name);
if (it == values.end()) return defaultv;

View File

@@ -71,7 +71,7 @@ class GwBoatItemBase{
virtual void refresh(unsigned long ts=0){uls(ts);}
virtual double getDoubleValue()=0;
String getName(){return name;}
String getFormat(){return format;}
const String & getFormat() const{return format;}
};
class GwBoatData;
template<class T> class GwBoatItem : public GwBoatItemBase{
@@ -208,6 +208,7 @@ class GwBoatData{
template<class T> T getDataWithDefault(T defaultv, GwBoatItemNameProvider *provider);
bool isValid(String name);
double getDoubleValue(String name,double defaultv);
GwBoatItemBase *getBase(String name);
String toJson() const;
String toString();
};