Skip to content

Commit

Permalink
Removed classes:
Browse files Browse the repository at this point in the history
-SearchReport
-*SearchMonitor
  • Loading branch information
randaz81 committed Dec 7, 2023
1 parent a62aa78 commit d921320
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 248 deletions.
1 change: 0 additions & 1 deletion src/devices/frameGrabberCropper/frameGrabberCropper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
49 changes: 2 additions & 47 deletions src/libYARP_dev/src/yarp/dev/PolyDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ namespace {
YARP_LOG_COMPONENT(POLYDRIVER, "yarp.dev.PolyDriver")
}

class PolyDriver::Private :
public SearchMonitor
class PolyDriver::Private
{
private:
Property comment;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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 {
Expand Down
27 changes: 0 additions & 27 deletions src/libYARP_os/src/yarp/os/Bottle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,40 +287,13 @@ 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;
}

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());
}
Expand Down
36 changes: 0 additions & 36 deletions src/libYARP_os/src/yarp/os/Property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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();
}

Expand Down Expand Up @@ -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;
}
Expand Down
80 changes: 1 addition & 79 deletions src/libYARP_os/src/yarp/os/Searchable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
}

Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -81,57 +44,16 @@ 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);
}

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 */
Loading

0 comments on commit d921320

Please sign in to comment.