116 lines
1.9 KiB
C++
116 lines
1.9 KiB
C++
/**
|
|
* @file route.h
|
|
* @author Alexander Klein (alex@kleiax.de)
|
|
* @brief Contains the class Route
|
|
* @version 0.1
|
|
* @date 2022-01-31
|
|
*
|
|
* @copyright Copyright (c) 2022
|
|
*
|
|
*/
|
|
|
|
#ifndef ROUTE_H
|
|
#define ROUTE_H
|
|
|
|
#include <cstdint>
|
|
#include <list>
|
|
|
|
#include "point.h"
|
|
|
|
/**
|
|
* @brief Holds some route information
|
|
*
|
|
*/
|
|
struct RouteInfo
|
|
{
|
|
/**
|
|
* @brief Selected number of Points
|
|
*/
|
|
uint16_t currentPoint;
|
|
|
|
/**
|
|
* @brief Total points stored in route
|
|
*/
|
|
uint16_t totalPoints;
|
|
};
|
|
|
|
/**
|
|
* @brief A class to manage multiple points
|
|
*
|
|
* The list of point presents a route which can be driven
|
|
*/
|
|
class Route
|
|
{
|
|
public:
|
|
/**
|
|
* @brief Adds a point to the list.
|
|
*
|
|
* @param point
|
|
*/
|
|
void addPointToRoute(Point point);
|
|
|
|
/**
|
|
* @brief Delete all points
|
|
*/
|
|
void clear();
|
|
|
|
/**
|
|
* @brief Select the first point as target.
|
|
*
|
|
* @return Point
|
|
*/
|
|
Point startRoute();
|
|
|
|
/**
|
|
* @brief Select the last point as target.
|
|
*
|
|
* @return Point
|
|
*/
|
|
Point endRoute();
|
|
|
|
/**
|
|
* @brief Get the next point and set it as target.
|
|
*
|
|
* @return Point is zero if there are no more Points.
|
|
*/
|
|
Point getNextPoint();
|
|
|
|
/**
|
|
* @brief Get the previous point and set it as target.
|
|
*
|
|
* @return Point
|
|
*/
|
|
Point getPreviousPoint();
|
|
|
|
/**
|
|
* @brief Get the Route Info object
|
|
*
|
|
* @return RouteInfo
|
|
*/
|
|
RouteInfo getRouteInfo();
|
|
|
|
/**
|
|
* @brief Get the Started object
|
|
*
|
|
* The Route will be marked as started when startRoute or
|
|
* endRoute has been called.
|
|
*
|
|
* @return true
|
|
* @return false
|
|
*/
|
|
bool getStarted() const { return this->started; }
|
|
|
|
static Route& getRouteCache();
|
|
|
|
private:
|
|
uint16_t currentPoint = 0;
|
|
bool started = false;
|
|
|
|
std::list<Point> points;
|
|
std::list<Point>::iterator it;
|
|
|
|
static Route routeCache;
|
|
};
|
|
|
|
#endif // ROUTE_H
|