diff --git a/AirLib/include/api/RpcLibAdaptorsBase.hpp b/AirLib/include/api/RpcLibAdaptorsBase.hpp index eda2b882ed..4785d443b6 100644 --- a/AirLib/include/api/RpcLibAdaptorsBase.hpp +++ b/AirLib/include/api/RpcLibAdaptorsBase.hpp @@ -491,22 +491,16 @@ namespace airlib_rpclib } ImageRequest(const msr::airlib::ImageCaptureBase::ImageRequest& s) + : camera_name(s.camera_name) + , image_type(s.image_type) + , pixels_as_float(s.pixels_as_float) + , compress(s.compress) { - camera_name = s.camera_name; - image_type = s.image_type; - pixels_as_float = s.pixels_as_float; - compress = s.compress; } msr::airlib::ImageCaptureBase::ImageRequest to() const { - msr::airlib::ImageCaptureBase::ImageRequest d; - d.camera_name = camera_name; - d.image_type = image_type; - d.pixels_as_float = pixels_as_float; - d.compress = compress; - - return d; + return { camera_name, image_type, pixels_as_float, compress }; } static std::vector from( diff --git a/AirLib/include/common/ClockBase.hpp b/AirLib/include/common/ClockBase.hpp index dbfeaec774..e4a97edcd0 100644 --- a/AirLib/include/common/ClockBase.hpp +++ b/AirLib/include/common/ClockBase.hpp @@ -26,6 +26,8 @@ namespace airlib wall_clock_start_ = Utils::getTimeSinceEpochNanos(); } + virtual ~ClockBase() = default; + TTimeDelta elapsedSince(TTimePoint since) const { return elapsedBetween(nowNanos(), since); diff --git a/AirLib/include/common/ImageCaptureBase.hpp b/AirLib/include/common/ImageCaptureBase.hpp index 04012901e4..3ada547eab 100644 --- a/AirLib/include/common/ImageCaptureBase.hpp +++ b/AirLib/include/common/ImageCaptureBase.hpp @@ -42,12 +42,15 @@ namespace airlib { } - ImageRequest(const std::string& camera_name_val, ImageCaptureBase::ImageType image_type_val, bool pixels_as_float_val = false, bool compress_val = true) + ImageRequest(const std::string& camera_name_val, + ImageCaptureBase::ImageType image_type_val, + bool pixels_as_float_val = false, + bool compress_val = true) + : camera_name(camera_name_val) + , image_type(image_type_val) + , pixels_as_float(pixels_as_float_val) + , compress(compress_val) { - camera_name = camera_name_val; - image_type = image_type_val; - pixels_as_float = pixels_as_float_val; - compress = compress_val; } }; @@ -69,7 +72,8 @@ namespace airlib public: //methods virtual void getImages(const std::vector& requests, std::vector& responses) const = 0; + virtual ~ImageCaptureBase() = default; }; } } //namespace -#endif \ No newline at end of file +#endif diff --git a/AirLib/include/common/common_utils/Utils.hpp b/AirLib/include/common/common_utils/Utils.hpp index 456bde9259..b43780354c 100644 --- a/AirLib/include/common/common_utils/Utils.hpp +++ b/AirLib/include/common/common_utils/Utils.hpp @@ -50,7 +50,7 @@ /* This file is collection of routines that can be included in ANY project just - by dropping in common_utils.hpp. Therefore there should not be any dependency + by dropping in common_utils.hpp. Therefore there should not be any dependency in the code below other than STL. The code should be able to compilable on all major platforms. */ @@ -102,6 +102,8 @@ class Utils else std::cerr << message << std::endl; } + + virtual ~Logger() = default; }; static void enableImmediateConsoleFlush() diff --git a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/CommonStructs.hpp b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/CommonStructs.hpp index 1c81b256c2..0add31cbdd 100644 --- a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/CommonStructs.hpp +++ b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/CommonStructs.hpp @@ -17,6 +17,8 @@ class Axis3 { } + virtual ~Axis3() = default; + //access by index virtual T& operator[](unsigned int index) { @@ -368,4 +370,4 @@ struct PidConfig IntegratorType integrator_type = IntegratorType::Standard; }; -} //namespace \ No newline at end of file +} //namespace diff --git a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardClock.hpp b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardClock.hpp index b873f7d813..d706408260 100644 --- a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardClock.hpp +++ b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardClock.hpp @@ -10,5 +10,7 @@ class IBoardClock public: virtual uint64_t micros() const = 0; virtual uint64_t millis() const = 0; + + virtual ~IBoardClock() = default; }; -} \ No newline at end of file +} diff --git a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardInputPins.hpp b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardInputPins.hpp index 9756d003e6..3ea0e714f0 100644 --- a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardInputPins.hpp +++ b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardInputPins.hpp @@ -11,5 +11,7 @@ class IBoardInputPins virtual float readChannel(uint16_t index) const = 0; //output -1 to 1 virtual bool isRcConnected() const = 0; virtual float getAvgMotorOutput() const = 0; + + virtual ~IBoardInputPins() = default; }; -} \ No newline at end of file +} diff --git a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardOutputPins.hpp b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardOutputPins.hpp index 53e23d37d7..908f9fcefd 100644 --- a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardOutputPins.hpp +++ b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardOutputPins.hpp @@ -10,5 +10,7 @@ class IBoardOutputPins public: virtual void writeOutput(uint16_t index, float val) = 0; //val = -1 to 1 for reversible motors otherwise 0 to 1 virtual void setLed(uint8_t index, int32_t color) = 0; + + virtual ~IBoardOutputPins() = default; }; -} \ No newline at end of file +} diff --git a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardSensors.hpp b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardSensors.hpp index 791cd8591a..d19e65102f 100644 --- a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardSensors.hpp +++ b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IBoardSensors.hpp @@ -8,5 +8,7 @@ class IBoardSensors public: virtual void readAccel(float accel[3]) const = 0; //accel in m/s^2 virtual void readGyro(float gyro[3]) const = 0; //angular velocity vector rad/sec + + virtual ~IBoardSensors() = default; }; -} \ No newline at end of file +} diff --git a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IGoal.hpp b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IGoal.hpp index 61bd22b057..d2227d8614 100644 --- a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IGoal.hpp +++ b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IGoal.hpp @@ -11,6 +11,8 @@ class IGoal public: virtual const Axis4r& getGoalValue() const = 0; virtual const GoalMode& getGoalMode() const = 0; + + virtual ~IGoal() = default; }; -} //namespace \ No newline at end of file +} //namespace diff --git a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IStateEstimator.hpp b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IStateEstimator.hpp index 9b63110aba..0f19ad83ae 100644 --- a/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IStateEstimator.hpp +++ b/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/interfaces/IStateEstimator.hpp @@ -20,5 +20,7 @@ class IStateEstimator virtual GeoPoint getHomeGeoPoint() const = 0; virtual Axis3r transformToBodyFrame(const Axis3r& world_frame_val) const = 0; + + virtual ~IStateEstimator() = default; }; -} \ No newline at end of file +} diff --git a/DroneShell/include/SimpleShell.hpp b/DroneShell/include/SimpleShell.hpp index fbc3d16b68..f964a9fb98 100644 --- a/DroneShell/include/SimpleShell.hpp +++ b/DroneShell/include/SimpleShell.hpp @@ -104,11 +104,13 @@ namespace airlib std::unordered_map switches_; public: - ShellCommand(std::string name, std::string help) + ShellCommand(const std::string& name, const std::string& help) : name_(name), help_(help) { } + virtual ~ShellCommand() = default; + void addSwitch(const ShellCommandSwitch& s) { std::string lower = Utils::toLower(s.name); @@ -142,7 +144,7 @@ namespace airlib virtual bool execute(const ShellCommandParameters&) { return false; }; private: - ShellCommand() {} + // ShellCommand() {} ShellCommand(ShellCommand& other) { unused(other); @@ -443,6 +445,8 @@ namespace airlib linenoise::SetCompletionCallback(std::bind(&SimpleShell::commandCompletitionCallBack, this, std::placeholders::_1, std::placeholders::_2)); } + virtual ~SimpleShell() = default; + // add a reference to a command (this object must remain valid, we do not copy it) void addCommand(ShellCommand& command) { diff --git a/MavLinkCom/MavLinkTest/Commands.h b/MavLinkCom/MavLinkTest/Commands.h index 93b4431fb3..1d209c0235 100644 --- a/MavLinkCom/MavLinkTest/Commands.h +++ b/MavLinkCom/MavLinkTest/Commands.h @@ -53,7 +53,7 @@ class Command { public: Command(); - ~Command(); + virtual ~Command(); std::string Name; diff --git a/MavLinkCom/include/MavLinkDebugLog.hpp b/MavLinkCom/include/MavLinkDebugLog.hpp index 14e2cceb7b..e19bcc084f 100644 --- a/MavLinkCom/include/MavLinkDebugLog.hpp +++ b/MavLinkCom/include/MavLinkDebugLog.hpp @@ -32,7 +32,9 @@ class MavLinkDebugLog return logger_; } + + virtual ~MavLinkDebugLog() = default; }; } -#endif \ No newline at end of file +#endif diff --git a/MavLinkCom/include/MavLinkMessageBase.hpp b/MavLinkCom/include/MavLinkMessageBase.hpp index f17c931e1b..c9471cac0e 100644 --- a/MavLinkCom/include/MavLinkMessageBase.hpp +++ b/MavLinkCom/include/MavLinkMessageBase.hpp @@ -118,6 +118,7 @@ class MavLinkCommand { public: uint16_t command = 0; + virtual ~MavLinkCommand() = default; protected: virtual void pack() = 0; diff --git a/MavLinkCom/src/MavLinkMessageBase.cpp b/MavLinkCom/src/MavLinkMessageBase.cpp index 26c8c0a7ed..effcbce739 100644 --- a/MavLinkCom/src/MavLinkMessageBase.cpp +++ b/MavLinkCom/src/MavLinkMessageBase.cpp @@ -411,4 +411,4 @@ std::string MavLinkMessageBase::float_array_tostring(int len, const float* field } } return line.str(); -} \ No newline at end of file +} diff --git a/MavLinkCom/src/serial_com/Port.h b/MavLinkCom/src/serial_com/Port.h index 8c8bdcb07a..90c8270dfe 100644 --- a/MavLinkCom/src/serial_com/Port.h +++ b/MavLinkCom/src/serial_com/Port.h @@ -21,5 +21,7 @@ class Port virtual bool isClosed() = 0; virtual int getRssi(const char* ifaceName) = 0; + + virtual ~Port() = default; }; #endif // !PORT_H diff --git a/MavLinkCom/src/serial_com/SerialPort.hpp b/MavLinkCom/src/serial_com/SerialPort.hpp index 94d8d0350f..e399d1a402 100644 --- a/MavLinkCom/src/serial_com/SerialPort.hpp +++ b/MavLinkCom/src/serial_com/SerialPort.hpp @@ -38,7 +38,7 @@ class SerialPort : public Port { public: SerialPort(); - virtual ~SerialPort(); + ~SerialPort(); // open the serial port virtual int connect(const char* portName, int baudRate); @@ -67,4 +67,4 @@ class SerialPort : public Port std::unique_ptr impl_; }; -#endif \ No newline at end of file +#endif diff --git a/MavLinkCom/src/serial_com/TcpClientPort.hpp b/MavLinkCom/src/serial_com/TcpClientPort.hpp index 490f970f5a..b462448621 100644 --- a/MavLinkCom/src/serial_com/TcpClientPort.hpp +++ b/MavLinkCom/src/serial_com/TcpClientPort.hpp @@ -10,7 +10,7 @@ class TcpClientPort : public Port { public: TcpClientPort(); - virtual ~TcpClientPort(); + ~TcpClientPort(); // Connect can set you up two different ways. Pass 0 for local port to get any free local // port. localHost allows you to be specific about which local adapter to use in case you diff --git a/MavLinkCom/src/serial_com/UdpClientPort.hpp b/MavLinkCom/src/serial_com/UdpClientPort.hpp index 9b094b9540..faf33b0ae9 100644 --- a/MavLinkCom/src/serial_com/UdpClientPort.hpp +++ b/MavLinkCom/src/serial_com/UdpClientPort.hpp @@ -10,7 +10,7 @@ class UdpClientPort : public Port { public: UdpClientPort(); - virtual ~UdpClientPort(); + ~UdpClientPort(); // Connect can set you up two different ways. Pass 0 for local port to get any free local // port and pass a fixed remotePort if you want to send to a specific remote port. diff --git a/cmake/cmake-modules/CommonSetup.cmake b/cmake/cmake-modules/CommonSetup.cmake index e0bb9e7e44..11d0c9bcb2 100644 --- a/cmake/cmake-modules/CommonSetup.cmake +++ b/cmake/cmake-modules/CommonSetup.cmake @@ -25,7 +25,7 @@ endmacro(SetupConsoleBuild) macro(CommonSetup) find_package(Threads REQUIRED) - find_path(AIRSIM_ROOT NAMES AirSim.sln PATHS ".." "../.." "../../.." "../../../.." "../../../../.." "../../../../../.." REQUIRED) + find_path(AIRSIM_ROOT NAMES AirSim.sln PATHS ".." "../.." "../../.." "../../../.." "../../../../.." "../../../../../.." REQUIRED) #setup output paths set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib) @@ -50,7 +50,8 @@ macro(CommonSetup) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wstrict-aliasing -D__CLANG__") else () set(CMAKE_CXX_FLAGS "\ - -ggdb -Wall -Wextra \ + -Wall -Wextra \ + -Wnon-virtual-dtor -Woverloaded-virtual \ -Wno-variadic-macros -Wno-unused-function -Wno-unused \ -pthread \ ${RPC_LIB_DEFINES} ${CMAKE_CXX_FLAGS}") @@ -97,4 +98,3 @@ macro(CommonSetup) endif() endmacro(CommonSetup) -