Skip to content

Commit

Permalink
modern renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangzp committed Mar 16, 2022
1 parent 9bfc157 commit 3245c2a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion plugin-forwarder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ADD_LIBRARY(PDK-UDPForwarder SHARED UDPBasedPacketForwarder.cpp)
ADD_LIBRARY(PDK-UDPForwarder SHARED UDPForwarderPlugin.cxx)
TARGET_LINK_LIBRARIES(PDK-UDPForwarder Utilities ${Boost_LIBRARIES})
install(TARGETS PDK-UDPForwarder DESTINATION ${INSTALL_PLUGIN_DIR})
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
// Created by Zhiping Jiang on 10/20/17.
//

#include "UDPBasedPacketForwarder.h"
#include "UDPForwarderPlugin.hxx"
#include "boost/algorithm/string.hpp"

std::string UDPBasedPacketForwarder::getPluginName() {
std::string UDPForwarderPlugin::getPluginName() {
return "Forwarder";
}

std::string UDPBasedPacketForwarder::getPluginDescription() {
std::string UDPForwarderPlugin::getPluginDescription() {
return "forward all received packets to the specified destination.";
}

std::shared_ptr<boost::program_options::options_description> UDPBasedPacketForwarder::pluginOptionsDescription() {
std::shared_ptr<boost::program_options::options_description> UDPForwarderPlugin::pluginOptionsDescription() {
static auto options = std::make_shared<po::options_description>("Options for plugin " + this->getPluginName());
static std::once_flag onceFlag;
std::call_once(onceFlag, [&] {
Expand All @@ -23,12 +23,11 @@ std::shared_ptr<boost::program_options::options_description> UDPBasedPacketForwa
return options;
}

std::string UDPBasedPacketForwarder::pluginStatus() {
std::string UDPForwarderPlugin::pluginStatus() {
return "Destination IP/Port: " + destinationIP + ":" + std::to_string(destinationPort);
}


void UDPBasedPacketForwarder::parseAndExecuteCommands(const std::string &commandString) {
void UDPForwarderPlugin::parseAndExecuteCommands(const std::string &commandString) {
po::variables_map vm;
po::store(po::command_line_parser(po::split_unix(commandString)).options(*pluginOptionsDescription().get()).allow_unregistered().run(), vm);
po::notify(vm);
Expand All @@ -46,7 +45,7 @@ void UDPBasedPacketForwarder::parseAndExecuteCommands(const std::string &command
}
}

void UDPBasedPacketForwarder::rxHandle(const ModularPicoScenesRxFrame &rxframe) {
void UDPForwarderPlugin::rxHandle(const ModularPicoScenesRxFrame &rxframe) {
auto frameBuffer = rxframe.toBuffer();
UDPService::getInstance("Forwarder" + destinationIP + std::to_string(destinationPort))->sendData(frameBuffer.data(), frameBuffer.size(), destinationIP, destinationPort);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <PicoScenes/UDPService.hxx>


class UDPBasedPacketForwarder : public AbstractPicoScenesPlugin {
class UDPForwarderPlugin : public AbstractPicoScenesPlugin {
public:
std::string getPluginName() override;

Expand All @@ -23,15 +23,15 @@ class UDPBasedPacketForwarder : public AbstractPicoScenesPlugin {

void rxHandle(const ModularPicoScenesRxFrame &rxframe) override;

static boost::shared_ptr<UDPBasedPacketForwarder> create() {
return boost::make_shared<UDPBasedPacketForwarder>();
static boost::shared_ptr<UDPForwarderPlugin> create() {
return boost::make_shared<UDPForwarderPlugin>();
}

private:
std::string destinationIP = "127.0.0.1";
uint16_t destinationPort = 50000;
std::string destinationIP{};
uint16_t destinationPort{0};
};

BOOST_DLL_ALIAS(UDPBasedPacketForwarder::create, initPicoScenesPlugin)
BOOST_DLL_ALIAS(UDPForwarderPlugin::create, initPicoScenesPlugin)

#endif //PICOSCENES_RXSBROADCASTPLUGIN_H

0 comments on commit 3245c2a

Please sign in to comment.