From d92132031040a1f90e474977ff528334d8f28b21 Mon Sep 17 00:00:00 2001 From: Marco Randazzo Date: Thu, 7 Dec 2023 17:24:42 +0100 Subject: [PATCH 1/8] Removed classes: -SearchReport -*SearchMonitor --- .../frameGrabberCropper.cpp | 1 - .../JoypadControlServer.cpp | 1 - .../RgbdSensor_nws_yarp.cpp | 1 - .../ControlBoard_nws_yarp.cpp | 2 - .../FrameGrabber_nws_yarp.cpp | 1 - .../MultipleAnalogSensorsServer.cpp | 1 - src/libYARP_dev/src/yarp/dev/PolyDriver.cpp | 49 +----------- src/libYARP_os/src/yarp/os/Bottle.cpp | 27 ------- src/libYARP_os/src/yarp/os/Property.cpp | 36 --------- src/libYARP_os/src/yarp/os/Searchable.cpp | 80 +------------------ src/libYARP_os/src/yarp/os/Searchable.h | 36 --------- .../src/yarp/os/impl/BottleImpl.cpp | 16 ---- 12 files changed, 3 insertions(+), 248 deletions(-) diff --git a/src/devices/frameGrabberCropper/frameGrabberCropper.cpp b/src/devices/frameGrabberCropper/frameGrabberCropper.cpp index f107e389cc3..c9873034568 100644 --- a/src/devices/frameGrabberCropper/frameGrabberCropper.cpp +++ b/src/devices/frameGrabberCropper/frameGrabberCropper.cpp @@ -63,7 +63,6 @@ bool FrameGrabberCropper::open(yarp::os::Searchable& config) yarp::os::Property p; subdevice = new yarp::dev::PolyDriver; p.fromString(config.toString()); - p.setMonitor(config.getMonitor(), "subdevice"); // pass on any monitoring p.unput("device"); p.put("device", config.find("subdevice").asString()); // subdevice was already checked before diff --git a/src/devices/networkWrappers/JoypadControlServer/JoypadControlServer.cpp b/src/devices/networkWrappers/JoypadControlServer/JoypadControlServer.cpp index 40292bba73c..48455531008 100644 --- a/src/devices/networkWrappers/JoypadControlServer/JoypadControlServer.cpp +++ b/src/devices/networkWrappers/JoypadControlServer/JoypadControlServer.cpp @@ -328,7 +328,6 @@ bool JoypadControlServer::openAndAttachSubDevice(Searchable& prop) m_subDeviceOwned = new PolyDriver; p.fromString(prop.toString()); - p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring p.unput("device"); p.put("device",prop.find("subdevice").asString()); // subdevice was already checked before diff --git a/src/devices/networkWrappers/RGBDSensor_nws_yarp/RgbdSensor_nws_yarp.cpp b/src/devices/networkWrappers/RGBDSensor_nws_yarp/RgbdSensor_nws_yarp.cpp index 7091fe668e7..8530cc5182a 100644 --- a/src/devices/networkWrappers/RGBDSensor_nws_yarp/RgbdSensor_nws_yarp.cpp +++ b/src/devices/networkWrappers/RGBDSensor_nws_yarp/RgbdSensor_nws_yarp.cpp @@ -277,7 +277,6 @@ bool RgbdSensor_nws_yarp::openAndAttachSubDevice(Searchable& prop) subDeviceOwned = new PolyDriver; p.fromString(prop.toString()); - p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring p.unput("device"); p.put("device",prop.find("subdevice").asString()); // subdevice was already checked before diff --git a/src/devices/networkWrappers/controlBoard_nws_yarp/ControlBoard_nws_yarp.cpp b/src/devices/networkWrappers/controlBoard_nws_yarp/ControlBoard_nws_yarp.cpp index dc5cad19f97..d98440dcf11 100644 --- a/src/devices/networkWrappers/controlBoard_nws_yarp/ControlBoard_nws_yarp.cpp +++ b/src/devices/networkWrappers/controlBoard_nws_yarp/ControlBoard_nws_yarp.cpp @@ -114,7 +114,6 @@ bool ControlBoard_nws_yarp::open(Searchable& config) // Check if we need to create subdevice or if they are // passed later on through attachAll() if (prop.check("subdevice")) { - prop.setMonitor(config.getMonitor()); if (!openAndAttachSubDevice(prop)) { yCError(CONTROLBOARD, "Error while opening subdevice"); return false; @@ -184,7 +183,6 @@ bool ControlBoard_nws_yarp::openAndAttachSubDevice(Property& prop) p.fromString(prop.toString()); std::string subdevice = prop.find("subdevice").asString(); - p.setMonitor(prop.getMonitor(), subdevice.c_str()); // pass on any monitoring p.unput("device"); p.put("device", subdevice); // subdevice was already checked before diff --git a/src/devices/networkWrappers/frameGrabber_nws_yarp/FrameGrabber_nws_yarp.cpp b/src/devices/networkWrappers/frameGrabber_nws_yarp/FrameGrabber_nws_yarp.cpp index 2a89bafbb24..21ad0b124b6 100644 --- a/src/devices/networkWrappers/frameGrabber_nws_yarp/FrameGrabber_nws_yarp.cpp +++ b/src/devices/networkWrappers/frameGrabber_nws_yarp/FrameGrabber_nws_yarp.cpp @@ -131,7 +131,6 @@ bool FrameGrabber_nws_yarp::open(yarp::os::Searchable& config) p.put("pixelType", VOCAB_PIXEL_MONO); } - p.setMonitor(config.getMonitor(), "subdevice"); // pass on any monitoring p.unput("device"); p.put("device", config.find("subdevice").asString()); // subdevice was already checked before diff --git a/src/devices/networkWrappers/multipleanalogsensorsserver/MultipleAnalogSensorsServer.cpp b/src/devices/networkWrappers/multipleanalogsensorsserver/MultipleAnalogSensorsServer.cpp index f430257a25c..8c31feff95d 100644 --- a/src/devices/networkWrappers/multipleanalogsensorsserver/MultipleAnalogSensorsServer.cpp +++ b/src/devices/networkWrappers/multipleanalogsensorsserver/MultipleAnalogSensorsServer.cpp @@ -158,7 +158,6 @@ bool MultipleAnalogSensorsServer::open(yarp::os::Searchable& config) yarp::os::Property driverConfig; driverConfig.fromString(config.toString()); - driverConfig.setMonitor(config.getMonitor(), subdeviceName.c_str()); // pass on any monitoring driverConfig.put("device", subdeviceName); if (!m_subdevice.open(driverConfig)) diff --git a/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp b/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp index b571f0f2d45..f1686d45902 100644 --- a/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp +++ b/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp @@ -17,8 +17,7 @@ namespace { YARP_LOG_COMPONENT(POLYDRIVER, "yarp.dev.PolyDriver") } -class PolyDriver::Private : - public SearchMonitor +class PolyDriver::Private { private: Property comment; @@ -31,41 +30,6 @@ class PolyDriver::Private : public: Property info; - void report(const SearchReport& report, const char *context) override - { - std::string ctx = context; - std::string key = report.key; - std::string prefix; - - prefix = ctx; - prefix += "."; - - key = prefix + key; - if (key.substr(0,1)==".") { - key = key.substr(1,key.length()); - } - - if (!present.check(key)) { - present.put(key,"present"); - order.addString(key.c_str()); - } - - if (report.isFound) { - actual.put(key,report.value); - return; - } - - if (report.isComment==true) { - comment.put(key,report.value); - return; - } - - if (report.isDefault==true) { - fallback.put(key,report.value); - return; - } - } - Bottle getOptions() { return order; @@ -155,17 +119,10 @@ bool PolyDriver::open(yarp::os::Searchable& config) mPriv = new PolyDriver::Private; } yCAssert(POLYDRIVER, mPriv != nullptr); - bool removeMonitorAfterwards = false; - if (config.getMonitor()==nullptr) { - config.setMonitor(mPriv); - removeMonitorAfterwards = true; - } coreOpen(config); mPriv->info.fromString(config.toString()); - if (removeMonitorAfterwards) { - config.setMonitor(nullptr); - } + return isValid(); } @@ -282,8 +239,6 @@ bool PolyDriver::coreOpen(yarp::os::Searchable& prop) if (wrapCreator!=creator) { p.put("subdevice", str); p.put("device", wrapper); - p.setMonitor(prop.getMonitor(), - wrapper.c_str()); // pass on any monitoring driver = wrapCreator->create(); creator = wrapCreator; } else { diff --git a/src/libYARP_os/src/yarp/os/Bottle.cpp b/src/libYARP_os/src/yarp/os/Bottle.cpp index 10e0b932e66..33cacc39156 100644 --- a/src/libYARP_os/src/yarp/os/Bottle.cpp +++ b/src/libYARP_os/src/yarp/os/Bottle.cpp @@ -287,15 +287,6 @@ bool Bottle::check(const std::string& key) const Value& Bottle::find(const std::string& key) const { Value& val = implementation->findBit(key); - - if (getMonitor() != nullptr) { - SearchReport report; - report.key = key; - report.isFound = !val.isNull(); - report.value = val.toString(); - reportToMonitor(report); - } - return val; } @@ -303,24 +294,6 @@ Bottle& Bottle::findGroup(const std::string& key) const { Value& bb = implementation->findGroupBit(key); - if (getMonitor() != nullptr) { - SearchReport report; - report.key = key; - report.isGroup = true; - if (bb.isList()) { - report.isFound = true; - report.value = bb.toString(); - } - reportToMonitor(report); - if (bb.isList()) { - std::string context = getMonitorContext(); - context += "."; - context += key; - bb.asList()->setMonitor(getMonitor(), - context.c_str()); // pass on any monitoring - } - } - if (bb.isList()) { return *(bb.asList()); } diff --git a/src/libYARP_os/src/yarp/os/Property.cpp b/src/libYARP_os/src/yarp/os/Property.cpp index 4a93af3e578..cbcc5462c2c 100644 --- a/src/libYARP_os/src/yarp/os/Property.cpp +++ b/src/libYARP_os/src/yarp/os/Property.cpp @@ -175,12 +175,6 @@ class Property::Private bool check(const std::string& key) const { PropertyItem* p = getPropNoCreate(key); - if (owner->getMonitor() != nullptr) { - SearchReport report; - report.key = key; - report.isFound = (p != nullptr); - owner->reportToMonitor(report); - } return p != nullptr; } @@ -189,20 +183,8 @@ class Property::Private PropertyItem* p = getPropNoCreate(key); if (p != nullptr) { p->flush(); - if (owner->getMonitor() != nullptr) { - SearchReport report; - report.key = key; - report.isFound = true; - report.value = p->bot.get(1).toString(); - owner->reportToMonitor(report); - } return p->bot.get(1); } - if (owner->getMonitor() != nullptr) { - SearchReport report; - report.key = key; - owner->reportToMonitor(report); - } return Value::getNullValue(); } @@ -1132,24 +1114,6 @@ bool Property::write(ConnectionWriter& writer) const Bottle& Property::findGroup(const std::string& key) const { Bottle* result = mPriv->getBottle(key); - if (getMonitor() != nullptr) { - SearchReport report; - report.key = key; - report.isGroup = true; - if (result != nullptr) { - report.isFound = true; - report.value = result->toString(); - } - reportToMonitor(report); - if (result != nullptr) { - std::string context = getMonitorContext(); - context += "."; - context += key; - result->setMonitor(getMonitor(), - context.c_str()); // pass on any monitoring - } - } - if (result != nullptr) { return *result; } diff --git a/src/libYARP_os/src/yarp/os/Searchable.cpp b/src/libYARP_os/src/yarp/os/Searchable.cpp index e994260f341..fe2a9df8fac 100644 --- a/src/libYARP_os/src/yarp/os/Searchable.cpp +++ b/src/libYARP_os/src/yarp/os/Searchable.cpp @@ -11,23 +11,7 @@ using namespace yarp::os; -#ifndef DOXYGEN_SHOULD_SKIP_THIS -yarp::os::SearchReport::SearchReport() : - key("?"), - value(""), - isFound(false), - isGroup(false), - isComment(false), - isDefault(false) -{ -} - -yarp::os::SearchMonitor::~SearchMonitor() = default; -#endif /* DOXYGEN_SHOULD_SKIP_THIS */ - - -yarp::os::Searchable::Searchable() : - monitor(nullptr) +yarp::os::Searchable::Searchable() { } @@ -37,13 +21,6 @@ bool yarp::os::Searchable::check(const std::string& key, yarp::os::Value*& result, const std::string& comment) const { - if (getMonitor() != nullptr && !comment.empty()) { - SearchReport report; - report.key = key; - report.value = comment; - report.isComment = true; - reportToMonitor(report); - } yarp::os::Value& bit = find(key); bool ok = !(bit.isNull()); if (ok) { @@ -56,20 +33,6 @@ yarp::os::Value yarp::os::Searchable::check(const std::string& key, const yarp::os::Value& fallback, const std::string& comment) const { - if (getMonitor() != nullptr && !comment.empty()) { - yarp::os::SearchReport report; - report.key = key; - report.value = comment; - report.isComment = true; - reportToMonitor(report); - } - if (getMonitor() != nullptr) { - yarp::os::SearchReport report; - report.key = key; - report.value = fallback.toString(); - report.isDefault = true; - reportToMonitor(report); - } yarp::os::Value& bit = find(key); bool ok = !(bit.isNull()); if (ok) { @@ -81,26 +44,12 @@ yarp::os::Value yarp::os::Searchable::check(const std::string& key, bool yarp::os::Searchable::check(const std::string& key, const std::string& comment) const { - if (getMonitor() != nullptr && !comment.empty()) { - yarp::os::SearchReport report; - report.key = key; - report.value = comment; - report.isComment = true; - reportToMonitor(report); - } return check(key); } yarp::os::Bottle& yarp::os::Searchable::findGroup(const std::string& key, const std::string& comment) const { - if (getMonitor() != nullptr && !comment.empty()) { - yarp::os::SearchReport report; - report.key = key; - report.value = comment; - report.isComment = true; - reportToMonitor(report); - } return findGroup(key); } @@ -108,30 +57,3 @@ bool yarp::os::Searchable::isNull() const { return false; } - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - -void yarp::os::Searchable::setMonitor(yarp::os::SearchMonitor* monitor, const char* context) -{ - this->monitor = monitor; - this->monitorContext = context; -} - -yarp::os::SearchMonitor* yarp::os::Searchable::getMonitor() const -{ - return monitor; -} - -std::string yarp::os::Searchable::getMonitorContext() const -{ - return monitorContext; -} - -void yarp::os::Searchable::reportToMonitor(const yarp::os::SearchReport& report) const -{ - if (monitor != nullptr) { - monitor->report(report, monitorContext.c_str()); - } -} - -#endif /* DOXYGEN_SHOULD_SKIP_THIS */ diff --git a/src/libYARP_os/src/yarp/os/Searchable.h b/src/libYARP_os/src/yarp/os/Searchable.h index e7e135b0b60..cad2c9e66f5 100644 --- a/src/libYARP_os/src/yarp/os/Searchable.h +++ b/src/libYARP_os/src/yarp/os/Searchable.h @@ -19,31 +19,6 @@ class Bottle; namespace yarp::os { -#ifndef DOXYGEN_SHOULD_SKIP_THIS - -class YARP_os_API SearchReport -{ -public: - YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) key; - YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) value; - bool isFound; - bool isGroup; - bool isComment; - bool isDefault; - - explicit SearchReport(); -}; - -class YARP_os_API SearchMonitor -{ -public: - virtual ~SearchMonitor(); - virtual void report(const SearchReport& report, const char* context) = 0; -}; - -#endif /* DOXYGEN_SHOULD_SKIP_THIS */ - - /** * A base class for nested structures that can be searched. * A Searchable object promises that you can look inside it @@ -54,10 +29,6 @@ class YARP_os_API SearchMonitor */ class YARP_os_API Searchable { -private: - SearchMonitor* monitor; - YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) monitorContext; - public: /** * Default constructor. @@ -200,13 +171,6 @@ class YARP_os_API Searchable * object. */ virtual std::string toString() const = 0; - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - virtual void setMonitor(SearchMonitor* monitor, const char* context = ""); - virtual SearchMonitor* getMonitor() const; - virtual std::string getMonitorContext() const; - virtual void reportToMonitor(const SearchReport& report) const; -#endif /* DOXYGEN_SHOULD_SKIP_THIS */ }; } // namespace yarp::os diff --git a/src/libYARP_os/src/yarp/os/impl/BottleImpl.cpp b/src/libYARP_os/src/yarp/os/impl/BottleImpl.cpp index 036f86aafc2..789a59a7c22 100644 --- a/src/libYARP_os/src/yarp/os/impl/BottleImpl.cpp +++ b/src/libYARP_os/src/yarp/os/impl/BottleImpl.cpp @@ -720,25 +720,9 @@ Value& BottleImpl::findBit(const std::string& key) const if (nested) { return org->asList()->get(1); } - if ((parent != nullptr) && (parent->getMonitor() != nullptr)) { - SearchReport report; - report.key = key; - report.isFound = true; - if (size() == 2) { - report.value = get(static_cast(i + 1)).toString(); - } - if (parent != nullptr) { - parent->reportToMonitor(report); - } - } return get(static_cast(i + 1)); } } // return invalid object - if ((parent != nullptr) && (parent->getMonitor() != nullptr)) { - SearchReport report; - report.key = key; - parent->reportToMonitor(report); - } return get(-1); } From 2cc537f383c27caa4df3f3bafff54fa6fdeab90f Mon Sep 17 00:00:00 2001 From: Marco Randazzo Date: Fri, 8 Dec 2023 13:27:13 +0100 Subject: [PATCH 2/8] Further refactor. This commit intentionally breaks some internals of: - harness_devices - RobotDescriptionServer - yarpdev terminator port name (now /yarpdev) - yarpdev toDox method --- .../RobotDescriptionServer.cpp | 10 +-- src/libYARP_dev/src/yarp/dev/Drivers.cpp | 73 ++++--------------- src/libYARP_dev/src/yarp/dev/PolyDriver.cpp | 34 --------- src/libYARP_dev/src/yarp/dev/PolyDriver.h | 32 -------- src/libYARP_dev/tests/PolyDriverTest.cpp | 13 ---- tests/devices/harness_devices.cpp | 6 +- 6 files changed, 21 insertions(+), 147 deletions(-) diff --git a/src/devices/networkWrappers/RobotDescriptionServer/RobotDescriptionServer.cpp b/src/devices/networkWrappers/RobotDescriptionServer/RobotDescriptionServer.cpp index fc104233433..40bbe3cb860 100644 --- a/src/devices/networkWrappers/RobotDescriptionServer/RobotDescriptionServer.cpp +++ b/src/devices/networkWrappers/RobotDescriptionServer/RobotDescriptionServer.cpp @@ -51,12 +51,12 @@ bool RobotDescriptionServer::attachAll(const PolyDriverList &p) std::lock_guard guard(m_external_mutex); for (int i = 0; i < p.size(); i++) { - yCTrace(ROBOTDESCRIPTIONSERVER) << p[i]->poly->getOptions().toString(); - yCTrace(ROBOTDESCRIPTIONSERVER) << p[i]->poly->getValue("device").toString(); - yCTrace(ROBOTDESCRIPTIONSERVER) << p[i]->poly->getValue("name").toString(); DeviceDescription dev; - dev.device_name = p[i]->poly->getValue("name").toString(); - dev.device_type = p[i]->poly->getValue("device").toString(); + + //BROKEN HERE. TO BE REIMPLEMENTED + //dev.device_name = p[i]->poly->getValue("name").toString(); + //dev.device_type = p[i]->poly->getValue("device").toString(); + if (this->add_device(dev) == false) { yCError(ROBOTDESCRIPTIONSERVER) << "attachAll(): Something strange happened here"; diff --git a/src/libYARP_dev/src/yarp/dev/Drivers.cpp b/src/libYARP_dev/src/yarp/dev/Drivers.cpp index 51f7a89317e..35f1213c23a 100644 --- a/src/libYARP_dev/src/yarp/dev/Drivers.cpp +++ b/src/libYARP_dev/src/yarp/dev/Drivers.cpp @@ -329,44 +329,6 @@ static void toDox(PolyDriver& dd) { yCIDebug(DRIVERS, dd.id(), "==============================================================="); yCIDebug(DRIVERS, dd.id(), "== Options checked by device:"); yCIDebug(DRIVERS, dd.id(), "=="); - Bottle order = dd.getOptions(); - for (size_t i=0; itoString(); - } else if (options.check("device", v)) { - if (v->isString()) { - auto device_name = v->toString(); - name = dd.getDefaultValue((device_name + ".name").c_str()).toString(); - if (name.empty()) { - auto options = dd.getOptions(); - for (size_t i = 0; i < options.size(); ++i) { - auto opt = options.get(i).toString(); - if (opt.length() > 5 && opt.compare(opt.length() - 5, 5, ".name") == 0) { // C++20 opt.ends_with(".name") - yCIWarning(DRIVERS, id, "%s", opt.c_str()); - name = dd.getDefaultValue(opt.c_str()).toString(); - break; - } - } - } - if (name.empty()) { - name = v->toString(); - } - } - } else { + } + if (name.empty() && options.check("device", v)) + { + //get the name of the device from the polydriver + //TO BE IMPLEMENTED. FOR REFERENCE ONLY: + //name = dd.getDefaultValue((device_name + ".name").c_str()).toString(); + } + if (name.empty()) + { name = "/yarpdev"; } std::string s = name + "/quit"; diff --git a/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp b/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp index f1686d45902..f85c14d2158 100644 --- a/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp +++ b/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp @@ -178,40 +178,6 @@ bool PolyDriver::link(PolyDriver& alt) return true; } -Bottle PolyDriver::getOptions() -{ - if (mPriv==nullptr) { - return Bottle::getNullBottle(); - } - return mPriv->getOptions(); -} - -std::string PolyDriver::getComment(const char *option) -{ - if (mPriv==nullptr) { - return {}; - } - return mPriv->getComment(option); -} - -Value PolyDriver::getDefaultValue(const char *option) -{ - if (mPriv==nullptr) { - return Value::getNullValue(); - } - return mPriv->getDefaultValue(option); -} - -Value PolyDriver::getValue(const char *option) -{ - if (mPriv==nullptr) { - return Value::getNullValue(); - } - return mPriv->getValue(option); -} - - - bool PolyDriver::coreOpen(yarp::os::Searchable& prop) { setId(prop.check("id", prop.check("device", Value("")), "Id assigned to this device").toString()); diff --git a/src/libYARP_dev/src/yarp/dev/PolyDriver.h b/src/libYARP_dev/src/yarp/dev/PolyDriver.h index ba535c5f2d4..d2acaaaffa4 100644 --- a/src/libYARP_dev/src/yarp/dev/PolyDriver.h +++ b/src/libYARP_dev/src/yarp/dev/PolyDriver.h @@ -105,38 +105,6 @@ class YARP_dev_API PolyDriver : */ bool isValid() const; - /** - * After a call to PolyDriver::open, you can - * get a list of all the options checked by the - * device. - * @return a list of options checked by the device - */ - yarp::os::Bottle getOptions(); - - /** - * After a call to PolyDriver::open, you can - * check if the device has documentation on a given option. - * @param option the name of the option to check - * @return the human-readable description of the option, if found - */ - std::string getComment(const char *option); - - /** - * After a call to PolyDriver::open, you can - * check if a given option has a particular default value. - * @param option the name of the option to check - * @return the default value of the option, if any. - */ - yarp::os::Value getDefaultValue(const char *option); - - /** - * After a call to PolyDriver::open, you can - * check what value was found for a particular option, if any. - * @param option the name of the option to check - * @return the value found for the option, if any. - */ - yarp::os::Value getValue(const char *option); - DeviceDriver *getImplementation() override; private: diff --git a/src/libYARP_dev/tests/PolyDriverTest.cpp b/src/libYARP_dev/tests/PolyDriverTest.cpp index d80b159a511..bc3f46e3879 100644 --- a/src/libYARP_dev/tests/PolyDriverTest.cpp +++ b/src/libYARP_dev/tests/PolyDriverTest.cpp @@ -106,19 +106,6 @@ TEST_CASE("dev::PolyDriverTest", "[yarp::dev]") CHECK(result); // close reported successful } - SECTION("test monitoring") - { - Property p; - p.put("device","devicedrivertest"); - p.put("verbose",1); - p.put("wrapped",1); - PolyDriver dd(p); - Bottle opts = dd.getOptions(); - CHECK(opts.size() > 0); // some options reported - //printf("Opts: %s\n", opts.toString().c_str()); - dd.close(); - } - SECTION("test Property bug") { Property p; diff --git a/tests/devices/harness_devices.cpp b/tests/devices/harness_devices.cpp index fd133f2e431..5bcd6976f73 100644 --- a/tests/devices/harness_devices.cpp +++ b/tests/devices/harness_devices.cpp @@ -48,14 +48,14 @@ static void toDox(PolyDriver& dd, FILE *os) { fprintf(os, "\n"); fprintf(os, "\n"); - Bottle order = dd.getOptions(); + Bottle order; for (size_t i=0; i Date: Fri, 8 Dec 2023 20:40:30 +0100 Subject: [PATCH 3/8] Removed harness_devices target --- tests/CMakeLists.txt | 2 - tests/devices/CMakeLists.txt | 67 ------- tests/devices/harness_devices.cpp | 287 ------------------------------ 3 files changed, 356 deletions(-) delete mode 100644 tests/devices/CMakeLists.txt delete mode 100644 tests/devices/harness_devices.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 09c90792a15..68cf539922d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -111,7 +111,5 @@ add_subdirectory(misc) add_subdirectory(yarpidl_thrift) -add_subdirectory(devices) - add_subdirectory(integration) add_subdirectory(harness_tests) diff --git a/tests/devices/CMakeLists.txt b/tests/devices/CMakeLists.txt deleted file mode 100644 index d79aae5e23d..00000000000 --- a/tests/devices/CMakeLists.txt +++ /dev/null @@ -1,67 +0,0 @@ -# SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) -# SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium -# SPDX-License-Identifier: BSD-3-Clause - -add_executable(harness_devices) -target_sources(harness_devices - PRIVATE - harness_devices.cpp -) -target_link_libraries(harness_devices - PRIVATE - YARP::YARP_os - YARP::YARP_init - YARP::YARP_dev -) -target_include_directories(harness_devices - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/.. -) - -set_property(TARGET harness_devices PROPERTY FOLDER "Test") - -set(_inis - AudioPlayerWrapper_fakeSpeaker.ini - AudioPlayerWrapper_portaudio.ini - AudioPlayerWrapper_portaudioPlayer.ini - AudioRecorderWrapper_fakeMicrophone.ini - AudioRecorderWrapper_portaudio.ini - AudioRecorderWrapper_portaudioRecorder.ini - controlboard_nws_yarp_basic.ini - ffmpeg_grabber_basic.ini - ffmpeg_grabber_video4linux.ini - ffmpeg_writer_basic.ini - grabber_basic.ini - grabber_audio.ini - group_basic.ini - opencv_grabber_basic.ini - portaudio_basic.ini - fakeFrameGrabber_basic.ini - fakeMotionControl_basic.ini - usbCamera.ini -) - -if(YARP_ENABLE_BROKEN_TESTS) - # Randomly fails with a segmentation fault - list(APPEND _inis grabber_audiovisual.ini) -endif() - -foreach(_ini_file ${_inis}) - get_filename_component(_test ${_ini_file} NAME_WE) - get_filename_component(_ini_file ${_ini_file} ABSOLUTE) - - # need to cache examples for reference (2022 change - removed doc stuff) - # set(_out_dox "${CMAKE_SOURCE_DIR}/doc/device_invocation/${_test}.dox") - # set(_cmd ${YARP_TEST_LAUNCHER} $ --file "${_ini_file}" --doc "${_out_dox}" --verbose) - set(_cmd ${YARP_TEST_LAUNCHER} $ --file "${_ini_file}" --verbose) - - # Add normal test - add_test( - NAME "device::${_test}" - COMMAND ${_cmd} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) - set_property(TEST "device::${_test}" PROPERTY SKIP_RETURN_CODE 254) - set_property(TEST "device::${_test}" PROPERTY TIMEOUT ${YARP_TEST_TIMEOUT}) -endforeach() diff --git a/tests/devices/harness_devices.cpp b/tests/devices/harness_devices.cpp deleted file mode 100644 index 5bcd6976f73..00000000000 --- a/tests/devices/harness_devices.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) - * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "YarpBuildLocation.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -using namespace yarp::os::impl; -using namespace yarp::os; -using namespace yarp::dev; - - -namespace { - -static yarp::os::Network* net = nullptr; -static bool verbose = false; - -static std::string getFile(const char *fname) -{ - char buf[25600]; - FILE *fin = fopen(fname, "r"); - if (fin == nullptr) { - return ""; - } - std::string result = ""; - while(fgets(buf, sizeof(buf)-1, fin) != nullptr) { - result += buf; - } - fclose(fin); - fin = nullptr; - return result; -} - - -static void toDox(PolyDriver& dd, FILE *os) -{ - fprintf(os, "
PROPERTYDESCRIPTIONDEFAULT
\n"); - fprintf(os, "\n"); - Bottle order; - for (size_t i=0; i\n"); -} - -void usage(const char* name) -{ - fprintf(stderr, "Usage:\n"); - fprintf(stderr, "\n"); - fprintf(stderr, " %s [--doc ] --file \n", name); - fprintf(stderr, " %s [--doc ] --device [device options]\n", name); - fprintf(stderr, "\n"); -} - -static void init_Network() -{ - net = new yarp::os::Network; -#ifndef YARP_NO_DEPRECATED // Since YARP 3.4 -YARP_WARNING_PUSH -YARP_DISABLE_DEPRECATED_WARNING - if (verbose) { - yarp::os::NetworkBase::setVerbosity(1); - } -YARP_WARNING_POP -#endif -} - -static void fini_Network() -{ - delete net; - net = nullptr; -} - -static void setup_Environment() -{ - // To make sure that the dev test are able to find all and only the devices - // compiled by YARP, including the ones compiled as dynamic plugins, - // YARP_DATA_DIRS is set to the build directory + the TEST_DATA_DIR - // and YARP_DATA_HOME is set to a non existent directory - std::string yarp_data_dirs = - CMAKE_BINARY_DIR + - std::string{yarp::conf::filesystem::preferred_separator} + - "share" + - std::string{yarp::conf::filesystem::preferred_separator} + - "yarp" + - std::string{yarp::conf::environment::path_separator} + - TEST_DATA_DIR; - yarp::conf::environment::set_string("YARP_DATA_DIRS", yarp_data_dirs); - - std::string yarp_data_home = - CMAKE_BINARY_DIR + - std::string{yarp::conf::filesystem::preferred_separator} + - "home" + - std::string{yarp::conf::filesystem::preferred_separator} + - "user" + - std::string{yarp::conf::filesystem::preferred_separator} + - ".local" + - std::string{yarp::conf::filesystem::preferred_separator} + - "yarp"; - yarp::conf::environment::set_string("YARP_DATA_HOME", yarp_data_home); - - // To ensure that this will behave in the same way if YARP is configured on - // the user's system and on the build machines, YARP_CONFIG_DIRS and - // YARP_CONFIG_HOME are set to a non existent directory - std::string yarp_config_dirs = CMAKE_BINARY_DIR + - std::string{yarp::conf::filesystem::preferred_separator} + - "etc" + - std::string{yarp::conf::filesystem::preferred_separator} + - "yarp"; - yarp::conf::environment::set_string("YARP_CONFIG_DIRS", yarp_config_dirs); - - std::string yarp_config_home = CMAKE_BINARY_DIR + - std::string{yarp::conf::filesystem::preferred_separator} + - "home" + - std::string{yarp::conf::filesystem::preferred_separator} + - "user" + - std::string{yarp::conf::filesystem::preferred_separator} + - ".config" + - std::string{yarp::conf::filesystem::preferred_separator} + - "yarp"; - yarp::conf::environment::set_string("YARP_CONFIG_HOME", yarp_config_home); - - if (verbose) { - printf("YARP_DATA_DIRS=\"%s\"\n", yarp::conf::environment::get_string("YARP_DATA_DIRS").c_str()); - printf("YARP_DATA_HOME=\"%s\"\n", yarp::conf::environment::get_string("YARP_DATA_HOME").c_str()); - printf("YARP_CONFIG_DIRS=\"%s\"\n", yarp::conf::environment::get_string("YARP_CONFIG_DIRS").c_str()); - printf("YARP_CONFIG_HOME=\"%s\"\n", yarp::conf::environment::get_string("YARP_CONFIG_HOME").c_str()); - } -} - -} // namespace - -//generate doxygen documentation -static void generate_dox(PolyDriver& dd, std::string& deviceName, std::string& fileName, std::string& dest_dox) -{ - auto start = fileName.rfind('/'); - if (start == std::string::npos) { - start = fileName.rfind('\\'); - } - if (start == std::string::npos) { - start = 0; - } - else { - ++start; - } - auto len = fileName.find('.', start); - if (len != std::string::npos) { - len -= start; - } - - std::string wrapperName = ""; - std::string codeName = ""; - - DriverCreator* creator = Drivers::factory().find(deviceName.c_str()); - if (creator != nullptr) { - wrapperName = creator->getWrapper(); - codeName = creator->getCode(); - } - yDebug("wrapperName = %s, codeName = %s", wrapperName.c_str(), codeName.c_str()); - - const std::string exampleName = fileName.substr(start, len); - const std::string shortFileName = fileName.substr(start); - - FILE* fout = fopen(dest_dox.c_str(), "w"); - if (fout == nullptr) { - yError("Problem writing to %s", dest_dox.c_str()); - std::exit(1); - } - - fprintf(fout, "/**\n"); - fprintf(fout, " * \\ingroup dev_examples\n"); - fprintf(fout, " *\n"); - fprintf(fout, " * \\defgroup %s Example for %s (%s)\n\n", - exampleName.c_str(), - deviceName.c_str(), - exampleName.c_str()); - fprintf(fout, "Instantiates \\ref cmd_device_%s \"%s\" device implemented by %s.\n", - deviceName.c_str(), deviceName.c_str(), codeName.c_str()); - fprintf(fout, "\\verbatim\n%s\\endverbatim\n", - getFile(fileName.c_str()).c_str()); - fprintf(fout, "If this text is saved in a file called %s then the device can be created by doing:\n", - shortFileName.c_str()); - fprintf(fout, "\\verbatim\nyarpdev --file %s\n\\endverbatim\n", - shortFileName.c_str()); - fprintf(fout, "Of course, the configuration could be passed just as command line options, or as a yarp::os::Property object in a program:\n"); - fprintf(fout, "\\code\n"); - fprintf(fout, "Property p;\n"); - fprintf(fout, "p.fromConfigFile(\"%s\");\n", - shortFileName.c_str()); - fprintf(fout, "// of course you could construct the Property object on-the-fly\n"); - fprintf(fout, "PolyDriver dev;\n"); - fprintf(fout, "dev.open(p);\n"); - fprintf(fout, "if (dev.isValid()) { /* use the device via view method */ }\n"); - fprintf(fout, "\\endcode\n"); - fprintf(fout, "Here is a list of properties checked when starting up a device based on this configuration file.\n"); - fprintf(fout, "Note that which properties are checked can depend on whether other properties are present.\n"); - fprintf(fout, "In some cases properties can also vary between operating systems.\n"); - fprintf(fout, "So this is just an example\n\n"); - - toDox(dd, fout); - - fprintf(fout, "\n\\sa %s\n\n", - codeName.c_str()); - fprintf(fout, " */\n"); - - fclose(fout); - fout = nullptr; -} - -//main function -int main(int argc, char *argv[]) -{ - Property p; - p.fromCommand(argc,argv); - verbose = p.check("verbose") && p.check("verbose", Value(true)).asBool(); - - // Check where to put description of device - std::string dest_dox = p.check("doc", Value("")).toString(); - - // Check if the "file" option was specified, and eventually read the file - std::string fileName = p.check("file", Value("default.ini")).asString(); - if (p.check("file")) { - p.fromConfigFile(fileName); - } - - // Check the name of the device - std::string deviceName = p.check("device", Value("")).asString(); - if (deviceName == "") { - yError("No device specified"); - usage(argv[0]); - return 1; - } - - setup_Environment(); - init_Network(); - Network::setLocalMode(true); - - PolyDriver dd; - yInfo("Opening PolyDriver for device %s", deviceName.c_str()); - if (!dd.open(p)) { - yError("PolyDriver failed to opened."); - return 254; - } - - yInfo("PolyDriver opened."); - - //generate documentation on request - if (!dest_dox.empty()) - { generate_dox(dd, deviceName, fileName, dest_dox); } - - yInfo("Starting 1 second delay"); - yarp::os::SystemClock::delaySystem(1); - - yInfo("Closing PolyDriver"); - dd.close(); - yInfo("PolyDriver closed."); - - fini_Network(); - - return 0; -} From 42c918c181ba3b40f7a32ea032195685c4a0fe1a Mon Sep 17 00:00:00 2001 From: Marco Randazzo Date: Sat, 9 Dec 2023 11:03:22 +0100 Subject: [PATCH 4/8] Further cleanup of PolyDriver class --- src/libYARP_dev/src/yarp/dev/PolyDriver.cpp | 27 --------------------- 1 file changed, 27 deletions(-) diff --git a/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp b/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp index f85c14d2158..ea452917ffb 100644 --- a/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp +++ b/src/libYARP_dev/src/yarp/dev/PolyDriver.cpp @@ -20,37 +20,10 @@ YARP_LOG_COMPONENT(POLYDRIVER, "yarp.dev.PolyDriver") class PolyDriver::Private { private: - Property comment; - Property fallback; - Property present; - Property actual; - Bottle order; int count = 1; - public: Property info; - Bottle getOptions() - { - return order; - } - - std::string getComment(const char *option) - { - std::string desc = comment.find(option).toString(); - return desc; - } - - Value getDefaultValue(const char *option) - { - return fallback.find(option); - } - - Value getValue(const char *option) - { - return actual.find(option); - } - void addRef() { count++; From 5caa447799754f17fef4655e9f71cc7830f36081 Mon Sep 17 00:00:00 2001 From: Marco Randazzo Date: Sat, 9 Dec 2023 13:41:19 +0100 Subject: [PATCH 5/8] Cleanup of IConfig interface. Now it is pure virtual. Removed unused method configure() --- src/libYARP_os/src/CMakeLists.txt | 1 - src/libYARP_os/src/yarp/os/IConfig.cpp | 27 -------------------------- src/libYARP_os/src/yarp/os/IConfig.h | 14 ++----------- 3 files changed, 2 insertions(+), 40 deletions(-) delete mode 100644 src/libYARP_os/src/yarp/os/IConfig.cpp diff --git a/src/libYARP_os/src/CMakeLists.txt b/src/libYARP_os/src/CMakeLists.txt index 440c3f186dd..9e3a8a01ad4 100644 --- a/src/libYARP_os/src/CMakeLists.txt +++ b/src/libYARP_os/src/CMakeLists.txt @@ -162,7 +162,6 @@ set(YARP_os_SRCS yarp/os/DummyConnector.cpp yarp/os/Event.cpp yarp/os/Header.cpp - yarp/os/IConfig.cpp yarp/os/InputStream.cpp yarp/os/Log.cpp yarp/os/LogComponent.cpp diff --git a/src/libYARP_os/src/yarp/os/IConfig.cpp b/src/libYARP_os/src/yarp/os/IConfig.cpp deleted file mode 100644 index aad117f1c99..00000000000 --- a/src/libYARP_os/src/yarp/os/IConfig.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) - * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include - - -yarp::os::IConfig::~IConfig() = default; - -bool yarp::os::IConfig::open(yarp::os::Searchable& config) -{ - YARP_UNUSED(config); - return true; -} - -bool yarp::os::IConfig::close() -{ - return true; -} - -bool yarp::os::IConfig::configure(Searchable& config) -{ - YARP_UNUSED(config); - return false; -} diff --git a/src/libYARP_os/src/yarp/os/IConfig.h b/src/libYARP_os/src/yarp/os/IConfig.h index 40786290c4a..081a629ba03 100644 --- a/src/libYARP_os/src/yarp/os/IConfig.h +++ b/src/libYARP_os/src/yarp/os/IConfig.h @@ -33,23 +33,13 @@ class YARP_os_API IConfig * Which parameters are effective for your object can vary. * @return true/false upon success/failure */ - virtual bool open(Searchable& config); + virtual bool open(Searchable& config) = 0; /** * Shut the object down. You should override this. * @return true/false on success/failure. */ - virtual bool close(); - - /** - * Change online parameters. - * The parameters that can be changed online (in other words, - * without closing and reopening) will vary between objects. - * - * @param config A list of parameters for the object. - * @return true/false on success/failure. - */ - virtual bool configure(Searchable& config); + virtual bool close() = 0; }; } // namespace yarp::os From 2152e58f02655fc4ee61ccbba9956b1e530d68d9 Mon Sep 17 00:00:00 2001 From: Marco Randazzo Date: Sat, 9 Dec 2023 13:52:44 +0100 Subject: [PATCH 6/8] IConfig interface renamed IOpenClose --- bindings/yarp.i | 2 +- src/libYARP_dev/src/yarp/dev/DeviceDriver.h | 2 +- src/libYARP_os/src/CMakeLists.txt | 2 +- .../src/yarp/os/{IConfig.h => IOpenClose.h} | 15 ++++++--------- 4 files changed, 9 insertions(+), 12 deletions(-) rename src/libYARP_os/src/yarp/os/{IConfig.h => IOpenClose.h} (65%) diff --git a/bindings/yarp.i b/bindings/yarp.i index 4940fe46046..2aaa0054ec1 100644 --- a/bindings/yarp.i +++ b/bindings/yarp.i @@ -392,7 +392,7 @@ MAKE_COMMS(Bottle) %include %include %include -%include +%include %include %include %include diff --git a/src/libYARP_dev/src/yarp/dev/DeviceDriver.h b/src/libYARP_dev/src/yarp/dev/DeviceDriver.h index 0455d9dbd4d..94183e5c37f 100644 --- a/src/libYARP_dev/src/yarp/dev/DeviceDriver.h +++ b/src/libYARP_dev/src/yarp/dev/DeviceDriver.h @@ -26,7 +26,7 @@ class DeviceResponder; * * Interface implemented by all device drivers. */ -class YARP_dev_API yarp::dev::DeviceDriver : public yarp::os::IConfig +class YARP_dev_API yarp::dev::DeviceDriver : public yarp::os::IOpenClose { public: DeviceDriver(); diff --git a/src/libYARP_os/src/CMakeLists.txt b/src/libYARP_os/src/CMakeLists.txt index 9e3a8a01ad4..51e2caa415c 100644 --- a/src/libYARP_os/src/CMakeLists.txt +++ b/src/libYARP_os/src/CMakeLists.txt @@ -38,7 +38,7 @@ set(YARP_os_HDRS yarp/os/Event.h yarp/os/Face.h yarp/os/Header.h - yarp/os/IConfig.h + yarp/os/IOpenClose.h yarp/os/InputProtocol.h yarp/os/InputStream.h yarp/os/LocalReader.h diff --git a/src/libYARP_os/src/yarp/os/IConfig.h b/src/libYARP_os/src/yarp/os/IOpenClose.h similarity index 65% rename from src/libYARP_os/src/yarp/os/IConfig.h rename to src/libYARP_os/src/yarp/os/IOpenClose.h index 081a629ba03..43d9bb25430 100644 --- a/src/libYARP_os/src/yarp/os/IConfig.h +++ b/src/libYARP_os/src/yarp/os/IOpenClose.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef YARP_OS_ICONFIG_H -#define YARP_OS_ICONFIG_H +#ifndef YARP_OS_IOPENCLOSE_H +#define YARP_OS_IOPENCLOSE_H #include @@ -14,23 +14,20 @@ namespace yarp::os { /** * - * An object that can be configured. When possible, we separate - * out the configuration for modules and devices into external - * files, command line options, or GUIs. + * An object that can be opened/closed. * */ -class YARP_os_API IConfig +class YARP_os_API IOpenClose { public: /** * Destructor. */ - virtual ~IConfig(); + virtual ~IOpenClose() {} /** * Initialize the object. You should override this. * @param config is a list of parameters for the object. - * Which parameters are effective for your object can vary. * @return true/false upon success/failure */ virtual bool open(Searchable& config) = 0; @@ -44,4 +41,4 @@ class YARP_os_API IConfig } // namespace yarp::os -#endif // YARP_OS_ICONFIG_H +#endif // YARP_OS_IOPENCLOSE_H From 60a779cac07ca92f89fcf290ced069ad004fbe60 Mon Sep 17 00:00:00 2001 From: Marco Randazzo Date: Sat, 9 Dec 2023 14:45:18 +0100 Subject: [PATCH 7/8] Completely removed useless IOpenClose.h interface --- src/libYARP_dev/src/yarp/dev/DeviceDriver.h | 9 ++-- src/libYARP_dev/src/yarp/dev/Drivers.cpp | 2 +- src/libYARP_os/src/CMakeLists.txt | 1 - src/libYARP_os/src/yarp/os/IOpenClose.h | 44 ------------------- .../tests/RobotinterfaceTest.cpp | 2 +- 5 files changed, 6 insertions(+), 52 deletions(-) delete mode 100644 src/libYARP_os/src/yarp/os/IOpenClose.h diff --git a/src/libYARP_dev/src/yarp/dev/DeviceDriver.h b/src/libYARP_dev/src/yarp/dev/DeviceDriver.h index 94183e5c37f..8a1576f325b 100644 --- a/src/libYARP_dev/src/yarp/dev/DeviceDriver.h +++ b/src/libYARP_dev/src/yarp/dev/DeviceDriver.h @@ -11,7 +11,6 @@ #include #include #include -#include #include @@ -26,7 +25,7 @@ class DeviceResponder; * * Interface implemented by all device drivers. */ -class YARP_dev_API yarp::dev::DeviceDriver : public yarp::os::IOpenClose +class YARP_dev_API yarp::dev::DeviceDriver { public: DeviceDriver(); @@ -35,7 +34,7 @@ class YARP_dev_API yarp::dev::DeviceDriver : public yarp::os::IOpenClose DeviceDriver& operator=(const DeviceDriver& other) = delete; DeviceDriver& operator=(DeviceDriver&& other) noexcept = delete; - ~DeviceDriver() override; + ~DeviceDriver(); /** * Open the DeviceDriver. @@ -50,13 +49,13 @@ class YARP_dev_API yarp::dev::DeviceDriver : public yarp::os::IOpenClose * yarp developers to add documentation for your device). * @return true/false upon success/failure */ - bool open(yarp::os::Searchable& config) override { YARP_UNUSED(config); return true; } + virtual bool open(yarp::os::Searchable& config) { YARP_UNUSED(config); return true; } /** * Close the DeviceDriver. * @return true/false on success/failure. */ - bool close() override { return true; } + virtual bool close() { return true; } /** diff --git a/src/libYARP_dev/src/yarp/dev/Drivers.cpp b/src/libYARP_dev/src/yarp/dev/Drivers.cpp index 35f1213c23a..cccbce88102 100644 --- a/src/libYARP_dev/src/yarp/dev/Drivers.cpp +++ b/src/libYARP_dev/src/yarp/dev/Drivers.cpp @@ -189,7 +189,7 @@ class StubDriver : public DeviceDriver { init(); } - ~StubDriver() override = default; + ~StubDriver() = default; void init() { if (plugin.open(settings)) { diff --git a/src/libYARP_os/src/CMakeLists.txt b/src/libYARP_os/src/CMakeLists.txt index 51e2caa415c..81541985432 100644 --- a/src/libYARP_os/src/CMakeLists.txt +++ b/src/libYARP_os/src/CMakeLists.txt @@ -38,7 +38,6 @@ set(YARP_os_HDRS yarp/os/Event.h yarp/os/Face.h yarp/os/Header.h - yarp/os/IOpenClose.h yarp/os/InputProtocol.h yarp/os/InputStream.h yarp/os/LocalReader.h diff --git a/src/libYARP_os/src/yarp/os/IOpenClose.h b/src/libYARP_os/src/yarp/os/IOpenClose.h deleted file mode 100644 index 43d9bb25430..00000000000 --- a/src/libYARP_os/src/yarp/os/IOpenClose.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) - * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef YARP_OS_IOPENCLOSE_H -#define YARP_OS_IOPENCLOSE_H - - -#include - -namespace yarp::os { - -/** - * - * An object that can be opened/closed. - * - */ -class YARP_os_API IOpenClose -{ -public: - /** - * Destructor. - */ - virtual ~IOpenClose() {} - - /** - * Initialize the object. You should override this. - * @param config is a list of parameters for the object. - * @return true/false upon success/failure - */ - virtual bool open(Searchable& config) = 0; - - /** - * Shut the object down. You should override this. - * @return true/false on success/failure. - */ - virtual bool close() = 0; -}; - -} // namespace yarp::os - -#endif // YARP_OS_IOPENCLOSE_H diff --git a/src/libYARP_robotinterface/tests/RobotinterfaceTest.cpp b/src/libYARP_robotinterface/tests/RobotinterfaceTest.cpp index c020af35357..7ab09baaa70 100644 --- a/src/libYARP_robotinterface/tests/RobotinterfaceTest.cpp +++ b/src/libYARP_robotinterface/tests/RobotinterfaceTest.cpp @@ -66,7 +66,7 @@ class yarp::dev::RobotInterfaceTestMockDriver : public yarp::dev::DeviceDriver { public: - ~RobotInterfaceTestMockDriver() override; + ~RobotInterfaceTestMockDriver(); //DEVICE DRIVER bool open(yarp::os::Searchable& config) override; From bc2d42474883076098697df1345ff04b57365466 Mon Sep 17 00:00:00 2001 From: Marco Randazzo Date: Sat, 9 Dec 2023 15:09:52 +0100 Subject: [PATCH 8/8] DynamixelAX12 device fix Bindings fix Fixed destructor of DeviceDriver class --- bindings/yarp.i | 1 - src/devices/DynamixelAX12Ftdi/DynamixelAX12FtdiDriver.h | 2 +- src/libYARP_dev/src/yarp/dev/DeviceDriver.h | 2 +- src/libYARP_dev/src/yarp/dev/Drivers.cpp | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bindings/yarp.i b/bindings/yarp.i index 2aaa0054ec1..16573b9237d 100644 --- a/bindings/yarp.i +++ b/bindings/yarp.i @@ -392,7 +392,6 @@ MAKE_COMMS(Bottle) %include %include %include -%include %include %include %include diff --git a/src/devices/DynamixelAX12Ftdi/DynamixelAX12FtdiDriver.h b/src/devices/DynamixelAX12Ftdi/DynamixelAX12FtdiDriver.h index cd362335fd7..bb313d936e0 100644 --- a/src/devices/DynamixelAX12Ftdi/DynamixelAX12FtdiDriver.h +++ b/src/devices/DynamixelAX12Ftdi/DynamixelAX12FtdiDriver.h @@ -189,7 +189,7 @@ class DynamixelAX12FtdiDriver : @param config Config file containing string pairs for parameters @return true on success */ - bool configure(yarp::os::Searchable& config) override; + bool configure(yarp::os::Searchable& config); /** Send instruction to device Send an instruction to a device of given ID. The instruction has to be a byte arry containing diff --git a/src/libYARP_dev/src/yarp/dev/DeviceDriver.h b/src/libYARP_dev/src/yarp/dev/DeviceDriver.h index 8a1576f325b..cbe65e2669c 100644 --- a/src/libYARP_dev/src/yarp/dev/DeviceDriver.h +++ b/src/libYARP_dev/src/yarp/dev/DeviceDriver.h @@ -34,7 +34,7 @@ class YARP_dev_API yarp::dev::DeviceDriver DeviceDriver& operator=(const DeviceDriver& other) = delete; DeviceDriver& operator=(DeviceDriver&& other) noexcept = delete; - ~DeviceDriver(); + virtual ~DeviceDriver(); /** * Open the DeviceDriver. diff --git a/src/libYARP_dev/src/yarp/dev/Drivers.cpp b/src/libYARP_dev/src/yarp/dev/Drivers.cpp index cccbce88102..44e90e392f2 100644 --- a/src/libYARP_dev/src/yarp/dev/Drivers.cpp +++ b/src/libYARP_dev/src/yarp/dev/Drivers.cpp @@ -189,7 +189,7 @@ class StubDriver : public DeviceDriver { init(); } - ~StubDriver() = default; + virtual ~StubDriver() = default; void init() { if (plugin.open(settings)) {
PROPERTYDESCRIPTIONDEFAULT