Skip to content

Commit

Permalink
Add non-virtual destructor warning, fix lots of them
Browse files Browse the repository at this point in the history
Plus some cleanup for constructors
  • Loading branch information
rajat2004 committed Dec 10, 2021
1 parent 00fe201 commit 45c7e6d
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 36 deletions.
16 changes: 5 additions & 11 deletions AirLib/include/api/RpcLibAdaptorsBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImageRequest> from(
Expand Down
2 changes: 2 additions & 0 deletions AirLib/include/common/ClockBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace airlib
wall_clock_start_ = Utils::getTimeSinceEpochNanos();
}

virtual ~ClockBase() = default;

TTimeDelta elapsedSince(TTimePoint since) const
{
return elapsedBetween(nowNanos(), since);
Expand Down
16 changes: 10 additions & 6 deletions AirLib/include/common/ImageCaptureBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};

Expand All @@ -69,7 +72,8 @@ namespace airlib

public: //methods
virtual void getImages(const std::vector<ImageRequest>& requests, std::vector<ImageResponse>& responses) const = 0;
virtual ~ImageCaptureBase() = default;
};
}
} //namespace
#endif
#endif
4 changes: 3 additions & 1 deletion AirLib/include/common/common_utils/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -102,6 +102,8 @@ class Utils
else
std::cerr << message << std::endl;
}

virtual ~Logger() = default;
};

static void enableImmediateConsoleFlush()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class Axis3
{
}

virtual ~Axis3() = default;

//access by index
virtual T& operator[](unsigned int index)
{
Expand Down Expand Up @@ -368,4 +370,4 @@ struct PidConfig
IntegratorType integrator_type = IntegratorType::Standard;
};

} //namespace
} //namespace
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ class IBoardClock
public:
virtual uint64_t micros() const = 0;
virtual uint64_t millis() const = 0;

virtual ~IBoardClock() = default;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class IGoal
public:
virtual const Axis4r& getGoalValue() const = 0;
virtual const GoalMode& getGoalMode() const = 0;

virtual ~IGoal() = default;
};

} //namespace
} //namespace
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ class IStateEstimator
virtual GeoPoint getHomeGeoPoint() const = 0;

virtual Axis3r transformToBodyFrame(const Axis3r& world_frame_val) const = 0;

virtual ~IStateEstimator() = default;
};
}
}
6 changes: 5 additions & 1 deletion DroneShell/include/SimpleShell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,13 @@ namespace airlib
std::unordered_map<std::string, ShellCommandSwitch> 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);
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion MavLinkCom/MavLinkTest/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Command
{
public:
Command();
~Command();
virtual ~Command();

std::string Name;

Expand Down
4 changes: 3 additions & 1 deletion MavLinkCom/include/MavLinkDebugLog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class MavLinkDebugLog

return logger_;
}

virtual ~MavLinkDebugLog() = default;
};
}

#endif
#endif
1 change: 1 addition & 0 deletions MavLinkCom/include/MavLinkMessageBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class MavLinkCommand
{
public:
uint16_t command = 0;
virtual ~MavLinkCommand() = default;

protected:
virtual void pack() = 0;
Expand Down
2 changes: 1 addition & 1 deletion MavLinkCom/src/MavLinkMessageBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,4 @@ std::string MavLinkMessageBase::float_array_tostring(int len, const float* field
}
}
return line.str();
}
}
2 changes: 2 additions & 0 deletions MavLinkCom/src/serial_com/Port.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ class Port
virtual bool isClosed() = 0;

virtual int getRssi(const char* ifaceName) = 0;

virtual ~Port() = default;
};
#endif // !PORT_H
4 changes: 2 additions & 2 deletions MavLinkCom/src/serial_com/SerialPort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -67,4 +67,4 @@ class SerialPort : public Port
std::unique_ptr<serialport_impl> impl_;
};

#endif
#endif
2 changes: 1 addition & 1 deletion MavLinkCom/src/serial_com/TcpClientPort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion MavLinkCom/src/serial_com/UdpClientPort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions cmake/cmake-modules/CommonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}")
Expand Down Expand Up @@ -97,4 +98,3 @@ macro(CommonSetup)
endif()

endmacro(CommonSetup)

0 comments on commit 45c7e6d

Please sign in to comment.