feat: add structures for MTR arrival and station information handling
This commit is contained in:
45
main/external/mtr/line_info.h
vendored
Normal file
45
main/external/mtr/line_info.h
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#include "cJSON.h"
|
||||
#include "esp_log.h"
|
||||
#include "external/mtr/station_info.h"
|
||||
#include "external/mtr/mtr.h"
|
||||
#include <string>
|
||||
|
||||
static const char* LINE_INFO_TAG = "LineInfo";
|
||||
|
||||
// Forward declaration
|
||||
class MTRNextTrainHandler;
|
||||
struct StationInfo;
|
||||
|
||||
struct LineInfo {
|
||||
public:
|
||||
|
||||
// caller does not own the returned char pointers
|
||||
const char* code() const {
|
||||
return _code.c_str();
|
||||
}
|
||||
// caller does not own the returned char pointers
|
||||
const char* color() const {
|
||||
return _color.c_str();
|
||||
}
|
||||
size_t station_count() const {
|
||||
return _stations.size();
|
||||
}
|
||||
// caller does not own the returned array or StationInfo pointers
|
||||
const std::vector<StationInfo>* stations() const {
|
||||
return &_stations;
|
||||
}
|
||||
|
||||
friend class MTRNextTrainHandler;
|
||||
|
||||
private:
|
||||
// Caller transfers ownership of stations array and its contents to LineInfo
|
||||
LineInfo(
|
||||
cJSON* line_json
|
||||
);
|
||||
|
||||
std::string _code;
|
||||
std::string _color;
|
||||
std::vector<StationInfo> _stations;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user