Skip to content

Commit

Permalink
Move changes to templates
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasVautherin authored and julianoes committed Oct 14, 2020
1 parent 91262a0 commit 98e2f48
Show file tree
Hide file tree
Showing 76 changed files with 525 additions and 101 deletions.
3 changes: 1 addition & 2 deletions src/plugins/action/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace mavsdk {

Action::Action(System& system) : PluginBase(), _impl{new ActionImpl(system)} {}

Action::Action(std::shared_ptr<System> system_ptr) : PluginBase(), _impl{new ActionImpl(system_ptr)}
{}
Action::Action(std::shared_ptr<System> system) : PluginBase(), _impl{new ActionImpl(system)} {}

Action::~Action() {}

Expand Down
21 changes: 16 additions & 5 deletions src/plugins/action/include/plugins/action/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,25 @@ class Action : public PluginBase {
* The plugin is typically created as shown below:
*
* ```cpp
* auto action = std::make_shared<Action>(system);
* auto action = Action(system);
* ```
*
* @param system The specific system associated with this plugin.
*/
explicit Action(System& system);
explicit Action(System& system); // deprecated

explicit Action(std::shared_ptr<System> system);
/**
* @brief Constructor. Creates the plugin for a specific System.
*
* The plugin is typically created as shown below:
*
* ```cpp
* auto action = Action(system);
* ```
*
* @param system The specific system associated with this plugin.
*/
explicit Action(std::shared_ptr<System> system); // new

/**
* @brief Destructor (internal use only).
Expand Down Expand Up @@ -479,9 +490,9 @@ class Action : public PluginBase {
Result set_return_to_launch_altitude(float relative_altitude_m) const;

/**
* @brief Copy constructor (object is not copyable).
* @brief Copy constructor.
*/
Action(const Action&) = delete;
Action(const Action& other);

/**
* @brief Equality operator (object is not copyable).
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/calibration/calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ using ProgressData = Calibration::ProgressData;

Calibration::Calibration(System& system) : PluginBase(), _impl{new CalibrationImpl(system)} {}

Calibration::Calibration(std::shared_ptr<System> system) :
PluginBase(),
_impl{new CalibrationImpl(system)}
{}

Calibration::~Calibration() {}

void Calibration::calibrate_gyro_async(CalibrateGyroCallback callback)
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/calibration/calibration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ CalibrationImpl::CalibrationImpl(System& system) : PluginImplBase(system)
_parent->register_plugin(this);
}

CalibrationImpl::CalibrationImpl(std::shared_ptr<System> system) : PluginImplBase(system)
{
_parent->register_plugin(this);
}

CalibrationImpl::~CalibrationImpl()
{
_parent->unregister_plugin(this);
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/calibration/calibration_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace mavsdk {

class CalibrationImpl : public PluginImplBase {
public:
CalibrationImpl(System& system);
explicit CalibrationImpl(System& system);
explicit CalibrationImpl(std::shared_ptr<System> system);
~CalibrationImpl();

void init() override;
Expand Down
21 changes: 17 additions & 4 deletions src/plugins/calibration/include/plugins/calibration/calibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,25 @@ class Calibration : public PluginBase {
* The plugin is typically created as shown below:
*
* ```cpp
* auto calibration = std::make_shared<Calibration>(system);
* auto calibration = Calibration(system);
* ```
*
* @param system The specific system associated with this plugin.
*/
explicit Calibration(System& system);
explicit Calibration(System& system); // deprecated

/**
* @brief Constructor. Creates the plugin for a specific System.
*
* The plugin is typically created as shown below:
*
* ```cpp
* auto calibration = Calibration(system);
* ```
*
* @param system The specific system associated with this plugin.
*/
explicit Calibration(std::shared_ptr<System> system); // new

/**
* @brief Destructor (internal use only).
Expand Down Expand Up @@ -169,9 +182,9 @@ class Calibration : public PluginBase {
void cancel() const;

/**
* @brief Copy constructor (object is not copyable).
* @brief Copy constructor.
*/
Calibration(const Calibration&) = delete;
Calibration(const Calibration& other);

/**
* @brief Equality operator (object is not copyable).
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ using Information = Camera::Information;

Camera::Camera(System& system) : PluginBase(), _impl{new CameraImpl(system)} {}

Camera::Camera(std::shared_ptr<System> system) : PluginBase(), _impl{new CameraImpl(system)} {}

Camera::~Camera() {}

void Camera::take_photo_async(const ResultCallback callback)
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/camera/camera_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ CameraImpl::CameraImpl(System& system) : PluginImplBase(system)
_parent->register_plugin(this);
}

CameraImpl::CameraImpl(std::shared_ptr<System> system) : PluginImplBase(system)
{
_parent->register_plugin(this);
}

CameraImpl::~CameraImpl()
{
_parent->unregister_plugin(this);
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/camera/camera_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace mavsdk {

class CameraImpl : public PluginImplBase {
public:
CameraImpl(System& system);
explicit CameraImpl(System& system);
explicit CameraImpl(std::shared_ptr<System> system);
~CameraImpl();

void init() override;
Expand Down
21 changes: 17 additions & 4 deletions src/plugins/camera/include/plugins/camera/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,25 @@ class Camera : public PluginBase {
* The plugin is typically created as shown below:
*
* ```cpp
* auto camera = std::make_shared<Camera>(system);
* auto camera = Camera(system);
* ```
*
* @param system The specific system associated with this plugin.
*/
explicit Camera(System& system);
explicit Camera(System& system); // deprecated

/**
* @brief Constructor. Creates the plugin for a specific System.
*
* The plugin is typically created as shown below:
*
* ```cpp
* auto camera = Camera(system);
* ```
*
* @param system The specific system associated with this plugin.
*/
explicit Camera(std::shared_ptr<System> system); // new

/**
* @brief Destructor (internal use only).
Expand Down Expand Up @@ -707,9 +720,9 @@ class Camera : public PluginBase {
Result format_storage() const;

/**
* @brief Copy constructor (object is not copyable).
* @brief Copy constructor.
*/
Camera(const Camera&) = delete;
Camera(const Camera& other);

/**
* @brief Equality operator (object is not copyable).
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/failure/failure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace mavsdk {

Failure::Failure(System& system) : PluginBase(), _impl{new FailureImpl(system)} {}

Failure::Failure(std::shared_ptr<System> system) : PluginBase(), _impl{new FailureImpl(system)} {}

Failure::~Failure() {}

Failure::Result
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/failure/failure_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ FailureImpl::FailureImpl(System& system) : PluginImplBase(system)
_parent->register_plugin(this);
}

FailureImpl::FailureImpl(std::shared_ptr<System> system) : PluginImplBase(system)
{
_parent->register_plugin(this);
}

FailureImpl::~FailureImpl()
{
_parent->unregister_plugin(this);
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/failure/failure_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace mavsdk {

class FailureImpl : public PluginImplBase {
public:
FailureImpl(System& system);
explicit FailureImpl(System& system);
explicit FailureImpl(std::shared_ptr<System> system);
~FailureImpl();

void init() override;
Expand Down
21 changes: 17 additions & 4 deletions src/plugins/failure/include/plugins/failure/failure.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,25 @@ class Failure : public PluginBase {
* The plugin is typically created as shown below:
*
* ```cpp
* auto failure = std::make_shared<Failure>(system);
* auto failure = Failure(system);
* ```
*
* @param system The specific system associated with this plugin.
*/
explicit Failure(System& system);
explicit Failure(System& system); // deprecated

/**
* @brief Constructor. Creates the plugin for a specific System.
*
* The plugin is typically created as shown below:
*
* ```cpp
* auto failure = Failure(system);
* ```
*
* @param system The specific system associated with this plugin.
*/
explicit Failure(std::shared_ptr<System> system); // new

/**
* @brief Destructor (internal use only).
Expand Down Expand Up @@ -128,9 +141,9 @@ class Failure : public PluginBase {
Result inject(FailureUnit failure_unit, FailureType failure_type, int32_t instance) const;

/**
* @brief Copy constructor (object is not copyable).
* @brief Copy constructor.
*/
Failure(const Failure&) = delete;
Failure(const Failure& other);

/**
* @brief Equality operator (object is not copyable).
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/follow_me/follow_me.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ using TargetLocation = FollowMe::TargetLocation;

FollowMe::FollowMe(System& system) : PluginBase(), _impl{new FollowMeImpl(system)} {}

FollowMe::FollowMe(std::shared_ptr<System> system) : PluginBase(), _impl{new FollowMeImpl(system)}
{}

FollowMe::~FollowMe() {}

FollowMe::Config FollowMe::get_config() const
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/follow_me/follow_me_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ FollowMeImpl::FollowMeImpl(System& system) : PluginImplBase(system)
_parent->register_plugin(this);
}

FollowMeImpl::FollowMeImpl(std::shared_ptr<System> system) : PluginImplBase(system)
{
// (Lat, Lon, Alt) => double, (vx, vy, vz) => float
_last_location = _target_location = FollowMe::TargetLocation{};
_parent->register_plugin(this);
}

FollowMeImpl::~FollowMeImpl()
{
if (_target_location_cookie) {
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/follow_me/follow_me_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ namespace mavsdk {

class FollowMeImpl : public PluginImplBase {
public:
FollowMeImpl(System& system);
explicit FollowMeImpl(System& system);
explicit FollowMeImpl(std::shared_ptr<System> system);
~FollowMeImpl();

void init() override;
Expand Down
21 changes: 17 additions & 4 deletions src/plugins/follow_me/include/plugins/follow_me/follow_me.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,25 @@ class FollowMe : public PluginBase {
* The plugin is typically created as shown below:
*
* ```cpp
* auto follow_me = std::make_shared<FollowMe>(system);
* auto follow_me = FollowMe(system);
* ```
*
* @param system The specific system associated with this plugin.
*/
explicit FollowMe(System& system);
explicit FollowMe(System& system); // deprecated

/**
* @brief Constructor. Creates the plugin for a specific System.
*
* The plugin is typically created as shown below:
*
* ```cpp
* auto follow_me = FollowMe(system);
* ```
*
* @param system The specific system associated with this plugin.
*/
explicit FollowMe(std::shared_ptr<System> system); // new

/**
* @brief Destructor (internal use only).
Expand Down Expand Up @@ -212,9 +225,9 @@ class FollowMe : public PluginBase {
Result stop() const;

/**
* @brief Copy constructor (object is not copyable).
* @brief Copy constructor.
*/
FollowMe(const FollowMe&) = delete;
FollowMe(const FollowMe& other);

/**
* @brief Equality operator (object is not copyable).
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/ftp/ftp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ using ProgressData = Ftp::ProgressData;

Ftp::Ftp(System& system) : PluginBase(), _impl{new FtpImpl(system)} {}

Ftp::Ftp(std::shared_ptr<System> system) : PluginBase(), _impl{new FtpImpl(system)} {}

Ftp::~Ftp() {}

void Ftp::reset_async(const ResultCallback callback)
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/ftp/ftp_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ FtpImpl::FtpImpl(System& system) : PluginImplBase(system)
_parent->register_plugin(this);
}

FtpImpl::FtpImpl(std::shared_ptr<System> system) : PluginImplBase(system)
{
_parent->register_plugin(this);
}

FtpImpl::~FtpImpl()
{
_parent->unregister_plugin(this);
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/ftp/ftp_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ namespace mavsdk {

class FtpImpl : public PluginImplBase {
public:
FtpImpl(System& system);
explicit FtpImpl(System& system);
explicit FtpImpl(std::shared_ptr<System> system);
FtpImpl(const FtpImpl&) = delete;
const FtpImpl& operator=(const FtpImpl&) = delete;

Expand Down
Loading

0 comments on commit 98e2f48

Please sign in to comment.