diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000000000000000000000000000000000..01af89d67f148faeaa137fa6a2e0df34b03dd673 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,69 @@ +--- +Checks: > + -*, + boost-*, + bugprone-*, + cppcoreguidelines-*, + -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-special-member-functions, + google-*, + -google-build-using-namespace, + -google-default-arguments, + -google-readability-todo, + llvm-*, + misc-*, + -misc-non-private-member-variables-in-classes, + modernize-*, + -modernize-use-trailing-return-type, + performance-*, + readability-*, + -readability-identifier-naming, + -readability-magic-numbers +FormatStyle: file +CheckOptions: + - key: readability-identifier-naming.ClassCase + value: CamelCase + - key: readability-identifier-naming.ClassMemberCase + value: lower_case + - key: readability-identifier-naming.ClassMemberSuffix + value: _ + - key: readability-identifier-naming.ClassMethodCase + value: CamelCase + - key: readability-identifier-naming.ConstantCase + value: CamelCase + - key: readability-identifier-naming.ConstantPrefix + value: k + - key: readability-identifier-naming.ConstexprVariableCase + value: CamelCase + - key: readability-identifier-naming.ConstexprVariablePrefix + value: k + - key: readability-identifier-naming.EnumCase + value: CamelCase + - key: readability-identifier-naming.EnumConstantCase + value: CamelCase + - key: readability-identifier-naming.EnumConstantPrefix + value: k + - key: readability-identifier-naming.FunctionCase + value: CamelCase + - key: readability-identifier-naming.GlobalVariableCase + value: CamelCase + - key: readability-identifier-naming.GlobalVariablePrefix + value: g + - key: readability-identifier-naming.NamespaceCase + value: lower_case + - key: readability-identifier-naming.ParameterCase + value: lower_case + - key: readability-identifier-naming.StaticConstantCase + value: CamelCase + - key: readability-identifier-naming.StaticConstantPrefix + value: k + - key: readability-identifier-naming.StructCase + value: CamelCase + - key: readability-identifier-naming.TemplateParameterCase + value: CamelCase + - key: readability-identifier-naming.VariableCase + value: lower_case + - key: readability-identifier-length.IgnoredVariableNames + value: "^(id|it)$" + - key: readability-identifier-length.IgnoredParameterNames + value: "^(d|id|os)$" diff --git a/include/MantleAPI/Common/bounding_box.h b/include/MantleAPI/Common/bounding_box.h index c7bc0505961c7cf529422349b07783c7a4c477de..1b7d6943b984f971fa00c9cb62d2c0186f1c89b6 100644 --- a/include/MantleAPI/Common/bounding_box.h +++ b/include/MantleAPI/Common/bounding_box.h @@ -12,8 +12,8 @@ /** @file bounding_box.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_COMMON_BOUNDINGBOX_H -#define MANTLEAPI_COMMON_BOUNDINGBOX_H +#ifndef MANTLEAPI_COMMON_BOUNDING_BOX_H +#define MANTLEAPI_COMMON_BOUNDING_BOX_H #include <MantleAPI/Common/dimension.h> #include <MantleAPI/Common/vector.h> @@ -38,4 +38,4 @@ inline bool operator==(const BoundingBox& lhs, const BoundingBox& rhs) noexcept } // namespace mantle_api -#endif // MANTLEAPI_COMMON_BOUNDINGBOX_H +#endif // MANTLEAPI_COMMON_BOUNDING_BOX_H diff --git a/include/MantleAPI/Common/i_geometry_helper.h b/include/MantleAPI/Common/i_geometry_helper.h index 32c35dd019b0523eb35219736c9dfaa386736342..61a334d2238fc84238a8561d2a1bd7c7f82bfe8f 100644 --- a/include/MantleAPI/Common/i_geometry_helper.h +++ b/include/MantleAPI/Common/i_geometry_helper.h @@ -12,8 +12,8 @@ /** @file i_geometry_helper.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_COMMON_IGEOMETRYHELPER_H -#define MANTLEAPI_COMMON_IGEOMETRYHELPER_H +#ifndef MANTLEAPI_COMMON_I_GEOMETRY_HELPER_H +#define MANTLEAPI_COMMON_I_GEOMETRY_HELPER_H #include <MantleAPI/Common/pose.h> @@ -34,7 +34,7 @@ public: /// the global coordinate system /// @param local_translation desired translation in local coordinates /// @return translated position in global coordinates - virtual Vec3<units::length::meter_t> TranslateGlobalPositionLocally( + [[nodiscard]] virtual Vec3<units::length::meter_t> TranslateGlobalPositionLocally( const Vec3<units::length::meter_t>& global_position, const Orientation3<units::angle::radian_t>& local_orientation, const Vec3<units::length::meter_t>& local_translation) const = 0; @@ -44,7 +44,7 @@ public: /// @param local_origin local coordinate system origin /// @param local_orientation local system orientation /// @return converted polyline points - virtual std::vector<Vec3<units::length::meter_t>> TransformPolylinePointsFromWorldToLocal( + [[nodiscard]] virtual std::vector<Vec3<units::length::meter_t>> TransformPolylinePointsFromWorldToLocal( const std::vector<Vec3<units::length::meter_t>>& polyline_points, const Vec3<units::length::meter_t>& local_origin, const Orientation3<units::angle::radian_t>& local_orientation) const = 0; @@ -54,7 +54,7 @@ public: /// @param local_origin local coordinate system origin /// @param local_orientation local system orientation /// @return transformed point - virtual Vec3<units::length::meter_t> TransformPositionFromWorldToLocal( + [[nodiscard]] virtual Vec3<units::length::meter_t> TransformPositionFromWorldToLocal( const Vec3<units::length::meter_t>& world_position, const Vec3<units::length::meter_t>& local_origin, const Orientation3<units::angle::radian_t>& local_orientation) const = 0; @@ -62,4 +62,4 @@ public: } // namespace mantle_api -#endif // MANTLEAPI_COMMON_IGEOMETRYHELPER_H +#endif // MANTLEAPI_COMMON_I_GEOMETRY_HELPER_H diff --git a/include/MantleAPI/Common/i_identifiable.h b/include/MantleAPI/Common/i_identifiable.h index cb256f747739ed08a80f52ac6d315497b7758aa5..78a40d51d0a937f123ac06978e11a68ea0deafd3 100644 --- a/include/MantleAPI/Common/i_identifiable.h +++ b/include/MantleAPI/Common/i_identifiable.h @@ -12,12 +12,12 @@ /** @file i_identifiable.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_COMMON_IIDENTIFIABLE_H -#define MANTLEAPI_COMMON_IIDENTIFIABLE_H +#ifndef MANTLEAPI_COMMON_I_IDENTIFIABLE_H +#define MANTLEAPI_COMMON_I_IDENTIFIABLE_H #include <cstdint> -#include <string> #include <limits> +#include <string> namespace mantle_api { @@ -31,14 +31,14 @@ public: virtual ~IIdentifiable() = default; /// The unique id is provided and maintained by the scenario simulator. - virtual UniqueId GetUniqueId() const = 0; + [[nodiscard]] virtual UniqueId GetUniqueId() const = 0; /// Scenario specific name of an object. /// /// The scenario description is responsible for keeping the name unique. virtual void SetName(const std::string& name) = 0; - virtual const std::string& GetName() const = 0; + [[nodiscard]] virtual const std::string& GetName() const = 0; }; } // namespace mantle_api -#endif // MANTLEAPI_COMMON_IIDENTIFIABLE_H +#endif // MANTLEAPI_COMMON_I_IDENTIFIABLE_H diff --git a/include/MantleAPI/Common/orientation.h b/include/MantleAPI/Common/orientation.h index 58331452d2a26bdf82d94b0aeceb49be97e5c891..f634395df7e7314dc9b90f8dce17d0f58a386073 100644 --- a/include/MantleAPI/Common/orientation.h +++ b/include/MantleAPI/Common/orientation.h @@ -28,8 +28,8 @@ UNIT_ADD(angular_acceleration, namespace category { -typedef base_unit<detail::meter_ratio<0>, std::ratio<0>, std::ratio<-2>, std::ratio<1>> angular_acceleration_unit; -} +using angular_acceleration_unit = base_unit<detail::meter_ratio<0>, std::ratio<0>, std::ratio<-2>, std::ratio<1>>; +} // namespace category UNIT_ADD_CATEGORY_TRAIT(angular_acceleration) @@ -41,8 +41,8 @@ UNIT_ADD(angular_jerk, namespace category { -typedef base_unit<detail::meter_ratio<0>, std::ratio<0>, std::ratio<-3>, std::ratio<1>> angular_jerk_unit; -} +using angular_jerk_unit = base_unit<detail::meter_ratio<0>, std::ratio<0>, std::ratio<-3>, std::ratio<1>>; +} // namespace category UNIT_ADD_CATEGORY_TRAIT(angular_jerk) diff --git a/include/MantleAPI/Common/position.h b/include/MantleAPI/Common/position.h index 430b5dbcf1773baf0c08db8c62454d83665268f3..c1acb83eddcc583113200f6ae24aaa847a6cd3da 100644 --- a/include/MantleAPI/Common/position.h +++ b/include/MantleAPI/Common/position.h @@ -12,8 +12,8 @@ /** @file position.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_COMMON_IPOSITION_H -#define MANTLEAPI_COMMON_IPOSITION_H +#ifndef MANTLEAPI_COMMON_POSITION_H +#define MANTLEAPI_COMMON_POSITION_H #include <MantleAPI/Common/floating_point_helper.h> #include <MantleAPI/Common/vector.h> @@ -103,4 +103,4 @@ inline bool operator!=(const LatLonPosition& lhs, const LatLonPosition& rhs) noe } } // namespace mantle_api -#endif // MANTLEAPI_COMMON_IPOSITION_H +#endif // MANTLEAPI_COMMON_POSITION_H diff --git a/include/MantleAPI/Common/spline.h b/include/MantleAPI/Common/spline.h index 4c109eec614de5fb69546fd1a8af751aa0e3035f..76cdf24176ee0f13bdc2ec620f9015df29dbdbba 100644 --- a/include/MantleAPI/Common/spline.h +++ b/include/MantleAPI/Common/spline.h @@ -34,8 +34,8 @@ UNIT_ADD(jerk, namespace category { -typedef base_unit<detail::meter_ratio<1>, std::ratio<0>, std::ratio<-3>> jerk_unit; -} +using jerk_unit = base_unit<detail::meter_ratio<1>, std::ratio<0>, std::ratio<-3>>; +} // namespace category UNIT_ADD_CATEGORY_TRAIT(jerk) @@ -47,8 +47,8 @@ UNIT_ADD(jerk_acceleration, namespace category { -typedef base_unit<detail::meter_ratio<1>, std::ratio<0>, std::ratio<-4>> jerk_acceleration_unit; -} +using jerk_acceleration_unit = base_unit<detail::meter_ratio<1>, std::ratio<0>, std::ratio<-4>>; +} // namespace category UNIT_ADD_CATEGORY_TRAIT(jerk_acceleration) diff --git a/include/MantleAPI/EnvironmentalConditions/road_condition.h b/include/MantleAPI/EnvironmentalConditions/road_condition.h index a9e3c8d394120bd14fc151f1b626ee3ed85a7c97..dbea4b068b93173e2a562015197a11d7f1f77553 100644 --- a/include/MantleAPI/EnvironmentalConditions/road_condition.h +++ b/include/MantleAPI/EnvironmentalConditions/road_condition.h @@ -12,8 +12,8 @@ /** @file road_condition.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_ENVIRONMENTALCONDITIONS_ROADCONDITION_H -#define MANTLEAPI_ENVIRONMENTALCONDITIONS_ROADCONDITION_H +#ifndef MANTLEAPI_ENVIRONMENTALCONDITIONS_ROAD_CONDITION_H +#define MANTLEAPI_ENVIRONMENTALCONDITIONS_ROAD_CONDITION_H #include <MantleAPI/Common/position.h> #include <units.h> @@ -32,4 +32,4 @@ struct FrictionPatch units::concentration::percent_t friction{100.0}; }; } // namespace mantle_api -#endif // MANTLEAPI_ENVIRONMENTALCONDITIONS_ROADCONDITION_H +#endif // MANTLEAPI_ENVIRONMENTALCONDITIONS_ROAD_CONDITION_H diff --git a/include/MantleAPI/Execution/i_environment.h b/include/MantleAPI/Execution/i_environment.h index f3e33a01c48576d4d4ae7769724dba53f73147bc..ee0096507e871fec14890de631aa35c36d382557 100644 --- a/include/MantleAPI/Execution/i_environment.h +++ b/include/MantleAPI/Execution/i_environment.h @@ -12,8 +12,8 @@ /** @file i_environment.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_EXECUTION_IENVIRONMENT_H -#define MANTLEAPI_EXECUTION_IENVIRONMENT_H +#ifndef MANTLEAPI_EXECUTION_I_ENVIRONMENT_H +#define MANTLEAPI_EXECUTION_I_ENVIRONMENT_H #include <MantleAPI/Common/i_geometry_helper.h> #include <MantleAPI/Common/route_definition.h> @@ -48,7 +48,7 @@ public: /// /// @param entity The entity to be manipulated by the specified controller. /// @param controller_id Identifies the controller to manipulate the entity. - virtual void AddEntityToController(IEntity& entity, UniqueId controller_id) = 0; + virtual void AddEntityToController(IEntity& entity, UniqueId controller_id) = 0; // NOLINT (google-runtime-references) virtual void RemoveControllerFromEntity(UniqueId entity_id) = 0; @@ -63,17 +63,17 @@ public: /// /// @param entity_id The entity to check /// @param type The control strategy type - virtual bool HasControlStrategyGoalBeenReached(UniqueId entity_id, mantle_api::ControlStrategyType type) const = 0; + [[nodiscard]] virtual bool HasControlStrategyGoalBeenReached(UniqueId entity_id, mantle_api::ControlStrategyType type) const = 0; - virtual const ILaneLocationQueryService& GetQueryService() const = 0; - virtual const ICoordConverter* GetConverter() const = 0; - virtual const IGeometryHelper* GetGeometryHelper() const = 0; + [[nodiscard]] virtual const ILaneLocationQueryService& GetQueryService() const = 0; + [[nodiscard]] virtual const ICoordConverter* GetConverter() const = 0; + [[nodiscard]] virtual const IGeometryHelper* GetGeometryHelper() const = 0; virtual IEntityRepository& GetEntityRepository() = 0; - virtual const IEntityRepository& GetEntityRepository() const = 0; + [[nodiscard]] virtual const IEntityRepository& GetEntityRepository() const = 0; virtual IControllerRepository& GetControllerRepository() = 0; - virtual const IControllerRepository& GetControllerRepository() const = 0; + [[nodiscard]] virtual const IControllerRepository& GetControllerRepository() const = 0; /// @brief DateTime in UTC (converted from RFC 3339 standard) virtual void SetDateTime(mantle_api::Time time) = 0; @@ -119,4 +119,4 @@ public: }; } // namespace mantle_api -#endif // MANTLEAPI_EXECUTION_IENVIRONMENT_H +#endif // MANTLEAPI_EXECUTION_I_ENVIRONMENT_H diff --git a/include/MantleAPI/Execution/i_scenario_engine.h b/include/MantleAPI/Execution/i_scenario_engine.h index 0c0015603dde70a63413393e064c4d8f5ba18b73..e7bbbde87d04fcb9f65069d7979dab8aa91c375e 100644 --- a/include/MantleAPI/Execution/i_scenario_engine.h +++ b/include/MantleAPI/Execution/i_scenario_engine.h @@ -12,8 +12,8 @@ /** @file i_scenario_engine.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_EXECUTION_ISCENARIOENGINE_H -#define MANTLEAPI_EXECUTION_ISCENARIOENGINE_H +#ifndef MANTLEAPI_EXECUTION_I_SCENARIO_ENGINE_H +#define MANTLEAPI_EXECUTION_I_SCENARIO_ENGINE_H #include <MantleAPI/Execution/scenario_info.h> @@ -30,7 +30,7 @@ public: virtual void Init() = 0; /// Provide information about the scenario loaded in `Init()` - virtual ScenarioInfo GetScenarioInfo() const = 0; + [[nodiscard]] virtual ScenarioInfo GetScenarioInfo() const = 0; /// Calculate the new state of the scenario implementation. /// @@ -40,7 +40,7 @@ public: /// Indicates whether the scenario implementation has finished processing the scenario (end of scenario is reached). /// @return `true` if processing the scenario is complete, `false` otherwise. - virtual bool IsFinished() const = 0; + [[nodiscard]] virtual bool IsFinished() const = 0; virtual void ActivateExternalHostControl() = 0; @@ -51,4 +51,4 @@ public: }; } // namespace mantle_api -#endif // MANTLEAPI_EXECUTION_ISCENARIOENGINE_H +#endif // MANTLEAPI_EXECUTION_I_SCENARIO_ENGINE_H diff --git a/include/MantleAPI/Execution/scenario_info.h b/include/MantleAPI/Execution/scenario_info.h index 43670dbf90961bd71177ea29ed7dff68890e433f..6f5f374f1d312e82de57ba3e56b08bc10a3adbba 100644 --- a/include/MantleAPI/Execution/scenario_info.h +++ b/include/MantleAPI/Execution/scenario_info.h @@ -12,8 +12,8 @@ /** @file scenario_info.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_EXECUTION_SCENARIOINFO_H -#define MANTLEAPI_EXECUTION_SCENARIOINFO_H +#ifndef MANTLEAPI_EXECUTION_SCENARIO_INFO_H +#define MANTLEAPI_EXECUTION_SCENARIO_INFO_H #include <MantleAPI/Common/time_utils.h> @@ -31,4 +31,4 @@ struct ScenarioInfo } // namespace mantle_api -#endif // MANTLEAPI_EXECUTION_SCENARIOINFO_H +#endif // MANTLEAPI_EXECUTION_SCENARIO_INFO_H diff --git a/include/MantleAPI/Map/i_coord_converter.h b/include/MantleAPI/Map/i_coord_converter.h index bdb6fe5b3da0f0a6bd15fbe445054dceae6903e6..d4850f9921c618820462c9b198fa4d2d61a1c426 100644 --- a/include/MantleAPI/Map/i_coord_converter.h +++ b/include/MantleAPI/Map/i_coord_converter.h @@ -12,8 +12,8 @@ /** @file i_coord_converter.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_MAP_ICOORDCONVERTER_H -#define MANTLEAPI_MAP_ICOORDCONVERTER_H +#ifndef MANTLEAPI_MAP_I_COORD_CONVERTER_H +#define MANTLEAPI_MAP_I_COORD_CONVERTER_H #include <MantleAPI/Common/position.h> #include <MantleAPI/Common/vector.h> @@ -28,9 +28,9 @@ class ICoordConverter public: virtual ~ICoordConverter() = default; /// Converts a track position to its corresponding inertial position. - virtual Vec3<units::length::meter_t> Convert(Position position) const = 0; + [[nodiscard]] virtual Vec3<units::length::meter_t> Convert(Position position) const = 0; }; } // namespace mantle_api -#endif // MANTLEAPI_MAP_ICOORDCONVERTER_H +#endif // MANTLEAPI_MAP_I_COORD_CONVERTER_H diff --git a/include/MantleAPI/Map/i_lane_location_query_service.h b/include/MantleAPI/Map/i_lane_location_query_service.h index 505f83f792caca0ba70c649e563874eaa5942403..12434aac031138fdd26dba8b2cb3f11c0e410844 100644 --- a/include/MantleAPI/Map/i_lane_location_query_service.h +++ b/include/MantleAPI/Map/i_lane_location_query_service.h @@ -12,8 +12,8 @@ /** @file i_lane_location_query_service.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_MAP_ILANELOCATIONQUERYSERVICE_H -#define MANTLEAPI_MAP_ILANELOCATIONQUERYSERVICE_H +#ifndef MANTLEAPI_MAP_I_LANE_LOCATION_QUERY_SERVICE_H +#define MANTLEAPI_MAP_I_LANE_LOCATION_QUERY_SERVICE_H #include <MantleAPI/Common/i_identifiable.h> #include <MantleAPI/Common/orientation.h> @@ -52,7 +52,7 @@ public: /// @param position Position that shall be mapped to a lane /// @return Orientation of the lane at this position /// @throw If the position cannot be mapped to a lane - virtual Orientation3<units::angle::radian_t> GetLaneOrientation( + [[nodiscard]] virtual Orientation3<units::angle::radian_t> GetLaneOrientation( const Vec3<units::length::meter_t>& position) const = 0; /// @brief Shifts a position the given amount upwards along the lane normal. This function is used for shifting @@ -65,21 +65,21 @@ public: /// world z-direction is used instead of the lane normal for the shift /// @return Upwards shifted position /// @throw If the position cannot be mapped to a lane and allow_invalid_positions=false. - virtual Vec3<units::length::meter_t> GetUpwardsShiftedLanePosition(const Vec3<units::length::meter_t>& position, - double upwards_shift, - bool allow_invalid_positions = false) const = 0; + [[nodiscard]] virtual Vec3<units::length::meter_t> GetUpwardsShiftedLanePosition(const Vec3<units::length::meter_t>& position, + double upwards_shift, + bool allow_invalid_positions = false) const = 0; /// @brief Checks, if a given position can be mapped to a lane /// /// @param position Position to be checked /// @return true if the position can be mapped to a lane, false otherwise - virtual bool IsPositionOnLane(const Vec3<units::length::meter_t>& position) const = 0; + [[nodiscard]] virtual bool IsPositionOnLane(const Vec3<units::length::meter_t>& position) const = 0; /// @brief Returns a list of IDs representing all lanes enclosing the passed in position within their shape(s). /// /// @param position Position to search for the Lane IDs /// @return List of global lane IDs - virtual std::vector<UniqueId> GetLaneIdsAtPosition(const Vec3<units::length::meter_t>& position) const = 0; + [[nodiscard]] virtual std::vector<UniqueId> GetLaneIdsAtPosition(const Vec3<units::length::meter_t>& position) const = 0; /// @brief Calculate the new pose which is at a certain longitudinal distance from the reference_pose_on_lane /// following a direction. @@ -94,9 +94,9 @@ public: /// orientation is parallel to the lane orientation at the target position. The lateral offset from the lane /// center line stays the same as at reference_pose_on_lane. If the reference_pose_on_lane cannot be mapped to /// a lane or the target position would be beyond the road network limits, no value is returned. - virtual std::optional<Pose> FindLanePoseAtDistanceFrom(const Pose& reference_pose_on_lane, - units::length::meter_t distance, - Direction direction) const = 0; + [[nodiscard]] virtual std::optional<Pose> FindLanePoseAtDistanceFrom(const Pose& reference_pose_on_lane, + units::length::meter_t distance, + Direction direction) const = 0; /// @brief Calculate the longitudinal distance of two given positions on a lane. /// @@ -107,7 +107,7 @@ public: /// service implementation. /// No value returned if the distance is not calculable. - virtual std::optional<units::length::meter_t> GetLongitudinalLaneDistanceBetweenPositions( + [[nodiscard]] virtual std::optional<units::length::meter_t> GetLongitudinalLaneDistanceBetweenPositions( const mantle_api::Vec3<units::length::meter_t>& start_position, const mantle_api::Vec3<units::length::meter_t>& target_position) const = 0; @@ -126,10 +126,10 @@ public: /// parallel to the lane orientation at the target position. No value is returned, if the /// reference_pose_on_lane cannot be mapped to a lane or if the target position would be beyond the road /// network limits in longitudinal or lateral direction. - virtual std::optional<Pose> FindRelativeLanePoseAtDistanceFrom(const Pose& reference_pose_on_lane, - int relative_target_lane, - units::length::meter_t distance, - units::length::meter_t lateral_offset) const = 0; + [[nodiscard]] virtual std::optional<Pose> FindRelativeLanePoseAtDistanceFrom(const Pose& reference_pose_on_lane, + int relative_target_lane, + units::length::meter_t distance, + units::length::meter_t lateral_offset) const = 0; /// @brief Calculate the lane id of the relative target lane from a given position /// @@ -139,10 +139,10 @@ public: /// @return Lane id that is at the given lateral shift (relative_lane_target) from given position /// (reference_pose_on_lane). No value, if reference pose is not on a lane or if the lane doesn't have a /// suitable adjacent lane. - virtual std::optional<mantle_api::LaneId> GetRelativeLaneId(const mantle_api::Pose& reference_pose_on_lane, - int relative_lane_target) const = 0; + [[nodiscard]] virtual std::optional<mantle_api::LaneId> GetRelativeLaneId(const mantle_api::Pose& reference_pose_on_lane, + int relative_lane_target) const = 0; }; } // namespace mantle_api -#endif // MANTLEAPI_MAP_ILANELOCATIONQUERYSERVICE_H +#endif // MANTLEAPI_MAP_I_LANE_LOCATION_QUERY_SERVICE_H diff --git a/include/MantleAPI/Map/i_route.h b/include/MantleAPI/Map/i_route.h index 1b4ebbda339ac0077980d3d26802a362b1f1ec6b..4f32d9c4eab5bedc92355608ba7e0b690a00ff5a 100644 --- a/include/MantleAPI/Map/i_route.h +++ b/include/MantleAPI/Map/i_route.h @@ -12,8 +12,8 @@ /** @file i_route.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_MAP_IROUTE_H -#define MANTLEAPI_MAP_IROUTE_H +#ifndef MANTLEAPI_MAP_I_ROUTE_H +#define MANTLEAPI_MAP_I_ROUTE_H #include <MantleAPI/Common/i_identifiable.h> #include <MantleAPI/Common/vector.h> @@ -28,16 +28,16 @@ class IRoute : public virtual IIdentifiable public: virtual IRoute& AddWaypoint(const Vec3<units::length::meter_t>& inert_pos) = 0; virtual IRoute& AddWaypoint(Vec3<units::length::meter_t>&& inert_pos) = 0; - virtual Vec3<units::length::meter_t> GetInertPos(units::length::meter_t route_pos, - LaneId lane_id, - units::length::meter_t lane_offset = units::length::meter_t{ - 0.0}) const = 0; - virtual units::length::meter_t GetLaneWidth(units::length::meter_t route_pos, LaneId lane_id) const = 0; - virtual LaneId GetLaneId(const Vec3<units::length::meter_t>& inert_pos) const = 0; - virtual units::length::meter_t GetDistanceFromStartTo(const Vec3<units::length::meter_t>& inert_pos) const = 0; - virtual units::length::meter_t GetLength() const = 0; + [[nodiscard]] virtual Vec3<units::length::meter_t> GetInertPos(units::length::meter_t route_pos, + LaneId lane_id, + units::length::meter_t lane_offset = units::length::meter_t{ + 0.0}) const = 0; + [[nodiscard]] virtual units::length::meter_t GetLaneWidth(units::length::meter_t route_pos, LaneId lane_id) const = 0; + [[nodiscard]] virtual LaneId GetLaneId(const Vec3<units::length::meter_t>& inert_pos) const = 0; + [[nodiscard]] virtual units::length::meter_t GetDistanceFromStartTo(const Vec3<units::length::meter_t>& inert_pos) const = 0; + [[nodiscard]] virtual units::length::meter_t GetLength() const = 0; }; } // namespace mantle_api -#endif // MANTLEAPI_MAP_IROUTE_H +#endif // MANTLEAPI_MAP_I_ROUTE_H diff --git a/include/MantleAPI/Map/map_details.h b/include/MantleAPI/Map/map_details.h index 3f62e1b0aedff19d48caed18ae8869ffbb85d42a..64b118bda9e7149e7b5ef184ef64e0dcc4f0d4d9 100644 --- a/include/MantleAPI/Map/map_details.h +++ b/include/MantleAPI/Map/map_details.h @@ -12,8 +12,8 @@ /** @file map_details.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_MAP_MAPDETAILS_H -#define MANTLEAPI_MAP_MAPDETAILS_H +#ifndef MANTLEAPI_MAP_MAP_DETAILS_H +#define MANTLEAPI_MAP_MAP_DETAILS_H #include <MantleAPI/Common/position.h> @@ -29,4 +29,4 @@ struct MapDetails }; } // namespace mantle_api -#endif // MANTLEAPI_MAP_MAPDETAILS_H +#endif // MANTLEAPI_MAP_MAP_DETAILS_H diff --git a/include/MantleAPI/Traffic/control_strategy.h b/include/MantleAPI/Traffic/control_strategy.h index 85f87a5962b01324b1e66bf5564c445237a30796..89e3e25d9c6d5ab98dc56f5f631e84782fe41556 100644 --- a/include/MantleAPI/Traffic/control_strategy.h +++ b/include/MantleAPI/Traffic/control_strategy.h @@ -12,8 +12,8 @@ /** @file control_strategy.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_TRAFFIC_CONTROLSTRATEGY_H -#define MANTLEAPI_TRAFFIC_CONTROLSTRATEGY_H +#ifndef MANTLEAPI_TRAFFIC_CONTROL_STRATEGY_H +#define MANTLEAPI_TRAFFIC_CONTROL_STRATEGY_H #include <MantleAPI/Common/i_identifiable.h> #include <MantleAPI/Common/spline.h> @@ -228,4 +228,4 @@ struct PerformLaneChangeControlStrategy : public ControlStrategy } // namespace mantle_api -#endif // MANTLEAPI_TRAFFIC_CONTROLSTRATEGY_H +#endif // MANTLEAPI_TRAFFIC_CONTROL_STRATEGY_H diff --git a/include/MantleAPI/Traffic/default_routing_behavior.h b/include/MantleAPI/Traffic/default_routing_behavior.h index cb5604c1efc17ac6f1f005e8649fbea02d513dfa..fac92b72539d4c71cedb30d9ad43a9ef2a3ad857 100644 --- a/include/MantleAPI/Traffic/default_routing_behavior.h +++ b/include/MantleAPI/Traffic/default_routing_behavior.h @@ -20,6 +20,6 @@ enum class DefaultRoutingBehavior kRandomRoute ///< Randomly select where to go next }; -} +} // namespace mantle_api -#endif //MANTLEAPI_TRAFFIC_DEFAULT_ROUTING_BEHAVIOR_H \ No newline at end of file +#endif // MANTLEAPI_TRAFFIC_DEFAULT_ROUTING_BEHAVIOR_H \ No newline at end of file diff --git a/include/MantleAPI/Traffic/entity_properties.h b/include/MantleAPI/Traffic/entity_properties.h index 65c3b5e4be8b715c1e12765a27a5154cdfedc7e6..e40094d6a1aa9f5b56742ca1786ff96dce31c018 100644 --- a/include/MantleAPI/Traffic/entity_properties.h +++ b/include/MantleAPI/Traffic/entity_properties.h @@ -12,8 +12,8 @@ /** @file entity_properties.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_TRAFFIC_ENTITYPROPERTIES_H -#define MANTLEAPI_TRAFFIC_ENTITYPROPERTIES_H +#ifndef MANTLEAPI_TRAFFIC_ENTITY_PROPERTIES_H +#define MANTLEAPI_TRAFFIC_ENTITY_PROPERTIES_H #include <MantleAPI/Common/bounding_box.h> #include <MantleAPI/Common/floating_point_helper.h> @@ -185,4 +185,4 @@ struct StaticObjectProperties : public EntityProperties } // namespace mantle_api -#endif // MANTLEAPI_TRAFFIC_ENTITYPROPERTIES_H +#endif // MANTLEAPI_TRAFFIC_ENTITY_PROPERTIES_H diff --git a/include/MantleAPI/Traffic/i_controller.h b/include/MantleAPI/Traffic/i_controller.h index fd4a5eb068a49064c003814768951afe1c2aa4fe..33b6066c0cb793ca9529ebdc84d912f3e515d0da 100644 --- a/include/MantleAPI/Traffic/i_controller.h +++ b/include/MantleAPI/Traffic/i_controller.h @@ -1,3 +1,6 @@ +#ifndef MANTLEAPI_TRAFFIC_I_CONTROLLER_H +#define MANTLEAPI_TRAFFIC_I_CONTROLLER_H + /******************************************************************************** * Copyright (c) 2021 in-tech GmbH * @@ -23,4 +26,5 @@ class IController : public IIdentifiable { }; -} // namespace mantle_api \ No newline at end of file +} // namespace mantle_api +#endif diff --git a/include/MantleAPI/Traffic/i_controller_config.h b/include/MantleAPI/Traffic/i_controller_config.h index 946197252fc3aceee976004e5f31d84d230cd333..a0c2a7a97191b3de7861ba8d2458f4a43d2b4a22 100644 --- a/include/MantleAPI/Traffic/i_controller_config.h +++ b/include/MantleAPI/Traffic/i_controller_config.h @@ -12,8 +12,8 @@ /** @file i_controller_config.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_TRAFFIC_ICONTROLLERCONFIG_H -#define MANTLEAPI_TRAFFIC_ICONTROLLERCONFIG_H +#ifndef MANTLEAPI_TRAFFIC_I_CONTROLLER_CONFIG_H +#define MANTLEAPI_TRAFFIC_I_CONTROLLER_CONFIG_H #include <MantleAPI/Common/route_definition.h> #include <MantleAPI/Common/spline.h> @@ -30,7 +30,7 @@ namespace mantle_api { struct IControllerConfig { - IControllerConfig() {} + IControllerConfig() = default; IControllerConfig(const IControllerConfig& controller_config) : map_query_service(controller_config.map_query_service) { @@ -86,4 +86,4 @@ struct ExternalControllerConfig : public IControllerConfig } // namespace mantle_api -#endif // MANTLEAPI_TRAFFIC_ICONTROLLERCONFIG_H +#endif // MANTLEAPI_TRAFFIC_I_CONTROLLER_CONFIG_H diff --git a/include/MantleAPI/Traffic/i_controller_repository.h b/include/MantleAPI/Traffic/i_controller_repository.h index 1ccec9e256da466ba369669b4dd0a77e9db312c8..864e44d034d729aa857e3ca88df0027bef5d91cd 100644 --- a/include/MantleAPI/Traffic/i_controller_repository.h +++ b/include/MantleAPI/Traffic/i_controller_repository.h @@ -1,3 +1,6 @@ +#ifndef MANTLEAPI_TRAFFIC_I_CONTROLLER_REPOSITORY_H +#define MANTLEAPI_TRAFFIC_I_CONTROLLER_REPOSITORY_H + /******************************************************************************** * Copyright (c) 2021 in-tech GmbH * @@ -27,10 +30,11 @@ public: [[deprecated]] virtual IController& Create(UniqueId id, std::unique_ptr<IControllerConfig> config) = 0; // deprecated virtual std::optional<std::reference_wrapper<IController>> Get(UniqueId id) = 0; - virtual bool Contains(UniqueId id) const = 0; + [[nodiscard]] virtual bool Contains(UniqueId id) const = 0; virtual void Delete(UniqueId id) = 0; }; -} // namespace mantle_api \ No newline at end of file +} // namespace mantle_api +#endif diff --git a/include/MantleAPI/Traffic/i_entity.h b/include/MantleAPI/Traffic/i_entity.h index c13881e205f3d5b04893200e7c799b78830d1772..b8d33bd9a82aa412184e1d21f4bef9c6a9285475 100644 --- a/include/MantleAPI/Traffic/i_entity.h +++ b/include/MantleAPI/Traffic/i_entity.h @@ -12,8 +12,8 @@ /** @file i_entity.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_TRAFFIC_IENTITY_H -#define MANTLEAPI_TRAFFIC_IENTITY_H +#ifndef MANTLEAPI_TRAFFIC_I_ENTITY_H +#define MANTLEAPI_TRAFFIC_I_ENTITY_H #include <MantleAPI/Common/bounding_box.h> #include <MantleAPI/Common/i_identifiable.h> @@ -53,43 +53,43 @@ public: /// The position of the entity is the geometric center of its bounding box. The origin of the entity coordinate system /// can be defined flexibly in relation to the geometric center (see bounding box). virtual void SetPosition(const Vec3<units::length::meter_t>& inert_pos) = 0; - virtual Vec3<units::length::meter_t> GetPosition() const = 0; + [[nodiscard]] virtual Vec3<units::length::meter_t> GetPosition() const = 0; virtual void SetVelocity(const Vec3<units::velocity::meters_per_second_t>& velocity) = 0; - virtual Vec3<units::velocity::meters_per_second_t> GetVelocity() const = 0; + [[nodiscard]] virtual Vec3<units::velocity::meters_per_second_t> GetVelocity() const = 0; virtual void SetAcceleration(const Vec3<units::acceleration::meters_per_second_squared_t>& acceleration) = 0; - virtual Vec3<units::acceleration::meters_per_second_squared_t> GetAcceleration() const = 0; + [[nodiscard]] virtual Vec3<units::acceleration::meters_per_second_squared_t> GetAcceleration() const = 0; virtual void SetOrientation(const Orientation3<units::angle::radian_t>& orientation) = 0; - virtual Orientation3<units::angle::radian_t> GetOrientation() const = 0; + [[nodiscard]] virtual Orientation3<units::angle::radian_t> GetOrientation() const = 0; virtual void SetOrientationRate( const Orientation3<units::angular_velocity::radians_per_second_t>& orientation_rate) = 0; - virtual Orientation3<units::angular_velocity::radians_per_second_t> GetOrientationRate() const = 0; + [[nodiscard]] virtual Orientation3<units::angular_velocity::radians_per_second_t> GetOrientationRate() const = 0; virtual void SetOrientationAcceleration( const Orientation3<units::angular_acceleration::radians_per_second_squared_t>& orientation_acceleration) = 0; - virtual Orientation3<units::angular_acceleration::radians_per_second_squared_t> GetOrientationAcceleration() + [[nodiscard]] virtual Orientation3<units::angular_acceleration::radians_per_second_squared_t> GetOrientationAcceleration() const = 0; virtual void SetProperties(std::unique_ptr<mantle_api::EntityProperties> properties) = 0; - virtual EntityProperties* GetProperties() const = 0; + [[nodiscard]] virtual EntityProperties* GetProperties() const = 0; virtual void SetAssignedLaneIds(const std::vector<std::uint64_t>& assigned_lane_ids) = 0; - virtual std::vector<std::uint64_t> GetAssignedLaneIds() const = 0; + [[nodiscard]] virtual std::vector<std::uint64_t> GetAssignedLaneIds() const = 0; virtual void SetVisibility(const EntityVisibilityConfig& visibility) = 0; - virtual EntityVisibilityConfig GetVisibility() const = 0; + [[nodiscard]] virtual EntityVisibilityConfig GetVisibility() const = 0; }; class IVehicle : public virtual IEntity { public: - virtual VehicleProperties* GetProperties() const = 0; + [[nodiscard]] VehicleProperties* GetProperties() const override = 0; virtual void SetIndicatorState(IndicatorState state) = 0; - virtual IndicatorState GetIndicatorState() const = 0; + [[nodiscard]] virtual IndicatorState GetIndicatorState() const = 0; // virtual bool IsHost() const = 0; // virtual void SetHost() = 0; @@ -98,15 +98,15 @@ public: class IPedestrian : public virtual IEntity { public: - virtual PedestrianProperties* GetProperties() const = 0; + [[nodiscard]] PedestrianProperties* GetProperties() const override = 0; }; class IStaticObject : public virtual IEntity { public: - virtual StaticObjectProperties* GetProperties() const = 0; + [[nodiscard]] StaticObjectProperties* GetProperties() const override = 0; }; } // namespace mantle_api -#endif // MANTLEAPI_TRAFFIC_IENTITY_H +#endif // MANTLEAPI_TRAFFIC_I_ENTITY_H diff --git a/include/MantleAPI/Traffic/i_entity_repository.h b/include/MantleAPI/Traffic/i_entity_repository.h index 7a83b561da31bb7b12afb9e5f1bee232e5107ef5..03cd4f2b93d5da889a06d8bb603559bec4f580b7 100644 --- a/include/MantleAPI/Traffic/i_entity_repository.h +++ b/include/MantleAPI/Traffic/i_entity_repository.h @@ -12,8 +12,8 @@ /** @file i_entity_repository.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_TRAFFIC_IENTITYREPOSITORY_H -#define MANTLEAPI_TRAFFIC_IENTITYREPOSITORY_H +#ifndef MANTLEAPI_TRAFFIC_I_ENTITY_REPOSITORY_H +#define MANTLEAPI_TRAFFIC_I_ENTITY_REPOSITORY_H #include <MantleAPI/Traffic/entity_properties.h> #include <MantleAPI/Traffic/i_entity.h> @@ -38,15 +38,15 @@ public: virtual IVehicle& GetHost() = 0; virtual std::optional<std::reference_wrapper<IEntity>> Get(const std::string& name) = 0; - virtual std::optional<std::reference_wrapper<const IEntity>> Get(const std::string& name) const = 0; + [[nodiscard]] virtual std::optional<std::reference_wrapper<const IEntity>> Get(const std::string& name) const = 0; virtual std::optional<std::reference_wrapper<IEntity>> Get(UniqueId id) = 0; - virtual std::optional<std::reference_wrapper<const IEntity>> Get(UniqueId id) const = 0; - virtual bool Contains(UniqueId id) const = 0; + [[nodiscard]] virtual std::optional<std::reference_wrapper<const IEntity>> Get(UniqueId id) const = 0; + [[nodiscard]] virtual bool Contains(UniqueId id) const = 0; virtual void Delete(const std::string& name) = 0; virtual void Delete(UniqueId id) = 0; - virtual const std::vector<std::unique_ptr<mantle_api::IEntity>>& GetEntities() const = 0; + [[nodiscard]] virtual const std::vector<std::unique_ptr<mantle_api::IEntity>>& GetEntities() const = 0; virtual void RegisterEntityCreatedCallback(const std::function<void(IEntity&)>& callback) = 0; virtual void RegisterEntityDeletedCallback(const std::function<void(const std::string&)>& callback) = 0; @@ -55,4 +55,4 @@ public: } // namespace mantle_api -#endif // MANTLEAPI_TRAFFIC_IENTITYREPOSITORY_H +#endif // MANTLEAPI_TRAFFIC_I_ENTITY_REPOSITORY_H diff --git a/include/MantleAPI/Traffic/traffic_light_properties.h b/include/MantleAPI/Traffic/traffic_light_properties.h index 593a7f3f6c6814cb6441a3b4a7a86d48a8d82e03..a6c13f7a0c945fdd0bbe12e2470b7968e1d134db 100644 --- a/include/MantleAPI/Traffic/traffic_light_properties.h +++ b/include/MantleAPI/Traffic/traffic_light_properties.h @@ -12,8 +12,8 @@ /** @file traffic_light_properties.h */ //----------------------------------------------------------------------------- -#ifndef MANTLEAPI_TRAFFIC_TRAFFICLIGHTPROPERTIES_H -#define MANTLEAPI_TRAFFIC_TRAFFICLIGHTPROPERTIES_H +#ifndef MANTLEAPI_TRAFFIC_TRAFFIC_LIGHT_PROPERTIES_H +#define MANTLEAPI_TRAFFIC_TRAFFIC_LIGHT_PROPERTIES_H #include <MantleAPI/Common/time_utils.h> #include <vector> @@ -56,4 +56,4 @@ struct TrafficLightPhase } // namespace mantle_api -#endif // MANTLEAPI_TRAFFIC_TRAFFICLIGHTPROPERTIES_H +#endif // MANTLEAPI_TRAFFIC_TRAFFIC_LIGHT_PROPERTIES_H