Skip to content

Commit

Permalink
templates: support for server plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
julianoes committed Apr 11, 2022
1 parent 942de76 commit c9c2197
Show file tree
Hide file tree
Showing 20 changed files with 117 additions and 178 deletions.
4 changes: 2 additions & 2 deletions src/mavsdk/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ add_subdirectory(manual_control)
add_subdirectory(mavlink_passthrough)
add_subdirectory(mission)
add_subdirectory(mission_raw)
add_subdirectory(mission_raw_server)
#add_subdirectory(mission_raw_server)
add_subdirectory(mocap)
add_subdirectory(offboard)
add_subdirectory(param)
add_subdirectory(param_server)
#add_subdirectory(param_server)
add_subdirectory(server_utility)
add_subdirectory(shell)
add_subdirectory(telemetry)
Expand Down
11 changes: 3 additions & 8 deletions src/mavsdk/plugins/action_server/action_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ namespace mavsdk {
using AllowableFlightModes = ActionServer::AllowableFlightModes;
using ArmDisarm = ActionServer::ArmDisarm;

ActionServer::ActionServer(System& system) :
PluginBase(),
_impl{std::make_unique<ActionServerImpl>(system)}
{}

ActionServer::ActionServer(std::shared_ptr<System> system) :
PluginBase(),
_impl{std::make_unique<ActionServerImpl>(system)}
ActionServer::ActionServer(Mavsdk& mavsdk) :
ServerPluginBase(),
_impl{std::make_unique<ActionServerImpl>(mavsdk)}
{}

ActionServer::~ActionServer() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,30 @@
#include <utility>
#include <vector>

#include "mavsdk/plugin_base.h"
#include "mavsdk/server_plugin_base.h"

namespace mavsdk {

class System;
class Mavsdk;
class ActionServerImpl;

/**
* @brief Provide vehicle actions (as a server) such as arming, taking off, and landing.
*/
class ActionServer : public PluginBase {
class ActionServer : public ServerPluginBase {
public:
/**
* @brief Constructor. Creates the plugin for a specific System.
* @brief Constructor. Creates the plugin for a Mavsdk instance.
*
* The plugin is typically created as shown below:
*
* ```cpp
* auto action_server = ActionServer(system);
* auto action_server = ActionServer(mavsdk);
* ```
*
* @param system The specific system associated with this plugin.
* @param system The Mavsdk instance associated with this server plugin.
*/
explicit ActionServer(System& system); // deprecated

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

/**
* @brief Destructor (internal use only).
Expand Down
2 changes: 1 addition & 1 deletion src/mavsdk/plugins/camera_server/camera_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@ std::ostream& operator<<(std::ostream& str, CameraServer::TakePhotoResult const&
}
}

} // namespace mavsdk
} // namespace mavsdk
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class CameraServerImpl;
class CameraServer : public ServerPluginBase {
public:
/**
* @brief Constructor. Creates a server plugin.
* @brief Constructor. Creates the plugin for a Mavsdk instance.
*
* The plugin is typically created as shown below:
*
* ```cpp
* auto camera_server = CameraServer(mavsdk);
* ```
*
* @param mavsdk The MAVSDK instance associated with this server plugin.
* @param system The Mavsdk instance associated with this server plugin.
*/
explicit CameraServer(Mavsdk& mavsdk);

Expand All @@ -43,6 +43,9 @@ class CameraServer : public ServerPluginBase {
*/
~CameraServer();

/**
* @brief
*/
enum class TakePhotoResult {
Unknown, /**< @brief. */
Ok, /**< @brief. */
Expand Down Expand Up @@ -248,9 +251,9 @@ class CameraServer : public ServerPluginBase {
Result respond_take_photo(TakePhotoResult take_photo_result, CaptureInfo capture_info) const;

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

/**
* @brief Equality operator (object is not copyable).
Expand All @@ -262,4 +265,4 @@ class CameraServer : public ServerPluginBase {
std::unique_ptr<CameraServerImpl> _impl;
};

} // namespace mavsdk
} // namespace mavsdk
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ namespace mavsdk {
using FloatParam = ComponentInformationServer::FloatParam;
using FloatParamUpdate = ComponentInformationServer::FloatParamUpdate;

ComponentInformationServer::ComponentInformationServer(System& system) :
PluginBase(),
_impl{std::make_unique<ComponentInformationServerImpl>(system)}
{}

ComponentInformationServer::ComponentInformationServer(std::shared_ptr<System> system) :
PluginBase(),
_impl{std::make_unique<ComponentInformationServerImpl>(system)}
ComponentInformationServer::ComponentInformationServer(Mavsdk& mavsdk) :
ServerPluginBase(),
_impl{std::make_unique<ComponentInformationServerImpl>(mavsdk)}
{}

ComponentInformationServer::~ComponentInformationServer() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,30 @@
#include <utility>
#include <vector>

#include "mavsdk/plugin_base.h"
#include "mavsdk/server_plugin_base.h"

namespace mavsdk {

class System;
class Mavsdk;
class ComponentInformationServerImpl;

/**
* @brief Provide component information such as parameters.
*/
class ComponentInformationServer : public PluginBase {
class ComponentInformationServer : public ServerPluginBase {
public:
/**
* @brief Constructor. Creates the plugin for a specific System.
* @brief Constructor. Creates the plugin for a Mavsdk instance.
*
* The plugin is typically created as shown below:
*
* ```cpp
* auto component_information_server = ComponentInformationServer(system);
* auto component_information_server = ComponentInformationServer(mavsdk);
* ```
*
* @param system The specific system associated with this plugin.
* @param system The Mavsdk instance associated with this server plugin.
*/
explicit ComponentInformationServer(System& system); // deprecated

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

/**
* @brief Destructor (internal use only).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,31 @@
#include <utility>
#include <vector>

#include "mavsdk/plugin_base.h"
#include "mavsdk/server_plugin_base.h"

namespace mavsdk {

class System;
class Mavsdk;
class MissionRawServerImpl;

/**
* @brief Acts as a vehicle and receives incoming missions from GCS (in raw MAVLINK format).
* Provides current mission item state, so the server can progress through missions.
*/
class MissionRawServer : public PluginBase {
class MissionRawServer : public ServerPluginBase {
public:
/**
* @brief Constructor. Creates the plugin for a specific System.
* @brief Constructor. Creates the plugin for a Mavsdk instance.
*
* The plugin is typically created as shown below:
*
* ```cpp
* auto mission_raw_server = MissionRawServer(system);
* auto mission_raw_server = MissionRawServer(mavsdk);
* ```
*
* @param system The specific system associated with this plugin.
* @param system The Mavsdk instance associated with this server plugin.
*/
explicit MissionRawServer(System& system); // deprecated

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

/**
* @brief Destructor (internal use only).
Expand Down
11 changes: 3 additions & 8 deletions src/mavsdk/plugins/mission_raw_server/mission_raw_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ using MissionItem = MissionRawServer::MissionItem;
using MissionPlan = MissionRawServer::MissionPlan;
using MissionProgress = MissionRawServer::MissionProgress;

MissionRawServer::MissionRawServer(System& system) :
PluginBase(),
_impl{std::make_unique<MissionRawServerImpl>(system)}
{}

MissionRawServer::MissionRawServer(std::shared_ptr<System> system) :
PluginBase(),
_impl{std::make_unique<MissionRawServerImpl>(system)}
MissionRawServer::MissionRawServer(Mavsdk& mavsdk) :
ServerPluginBase(),
_impl{std::make_unique<MissionRawServerImpl>(mavsdk)}
{}

MissionRawServer::~MissionRawServer() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,30 @@
#include <utility>
#include <vector>

#include "mavsdk/plugin_base.h"
#include "mavsdk/server_plugin_base.h"

namespace mavsdk {

class System;
class Mavsdk;
class ParamServerImpl;

/**
* @brief Provide raw access to retrieve and provide server parameters.
*/
class ParamServer : public PluginBase {
class ParamServer : public ServerPluginBase {
public:
/**
* @brief Constructor. Creates the plugin for a specific System.
* @brief Constructor. Creates the plugin for a Mavsdk instance.
*
* The plugin is typically created as shown below:
*
* ```cpp
* auto param_server = ParamServer(system);
* auto param_server = ParamServer(mavsdk);
* ```
*
* @param system The specific system associated with this plugin.
* @param system The Mavsdk instance associated with this server plugin.
*/
explicit ParamServer(System& system); // deprecated

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

/**
* @brief Destructor (internal use only).
Expand Down
11 changes: 3 additions & 8 deletions src/mavsdk/plugins/param_server/param_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ using IntParam = ParamServer::IntParam;
using FloatParam = ParamServer::FloatParam;
using AllParams = ParamServer::AllParams;

ParamServer::ParamServer(System& system) :
PluginBase(),
_impl{std::make_unique<ParamServerImpl>(system)}
{}

ParamServer::ParamServer(std::shared_ptr<System> system) :
PluginBase(),
_impl{std::make_unique<ParamServerImpl>(system)}
ParamServer::ParamServer(Mavsdk& mavsdk) :
ServerPluginBase(),
_impl{std::make_unique<ParamServerImpl>(mavsdk)}
{}

ParamServer::~ParamServer() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,31 @@
#include <utility>
#include <vector>

#include "mavsdk/plugin_base.h"
#include "mavsdk/server_plugin_base.h"

namespace mavsdk {

class System;
class Mavsdk;
class TelemetryServerImpl;

/**
* @brief Allow users to provide vehicle telemetry and state information
* (e.g. battery, GPS, RC connection, flight mode etc.) and set telemetry update rates.
*/
class TelemetryServer : public PluginBase {
class TelemetryServer : public ServerPluginBase {
public:
/**
* @brief Constructor. Creates the plugin for a specific System.
* @brief Constructor. Creates the plugin for a Mavsdk instance.
*
* The plugin is typically created as shown below:
*
* ```cpp
* auto telemetry_server = TelemetryServer(system);
* auto telemetry_server = TelemetryServer(mavsdk);
* ```
*
* @param system The specific system associated with this plugin.
* @param system The Mavsdk instance associated with this server plugin.
*/
explicit TelemetryServer(System& system); // deprecated

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

/**
* @brief Destructor (internal use only).
Expand Down
Loading

0 comments on commit c9c2197

Please sign in to comment.