Skip to content

Commit c174c2d

Browse files
committed
test
1 parent f03dd5d commit c174c2d

File tree

16 files changed

+72
-124
lines changed

16 files changed

+72
-124
lines changed

src/devices/ServerInertial/ServerInertial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ bool ServerInertial::openAndAttachSubDevice(yarp::os::Property& prop)
237237
p.put("device",subdevice.toString());
238238
IMU_polydriver->open(p);
239239
} else {
240-
IMU_polydriver->open(subdevice);
240+
IMU_polydriver->open(*subdevice.asSearchable());
241241
}
242242

243243
if (!IMU_polydriver->isValid())

src/libYARP_companion/src/yarp/companion/impl/Companion.cmdPlugin.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ int Companion::cmdPlugin(int argc, char *argv[])
152152
for (size_t i=0; i<lst.size(); i++) {
153153
Value& options = lst.get(i);
154154
std::string name = options.asList()->get(0).toString();
155-
std::string path = options.check("path", Value("unknown path")).asString();
156-
std::string type = options.check("type", Value("unknown type")).asString();
155+
std::string path = options.asSearchable()->check("path", Value("unknown path")).asString();
156+
std::string type = options.asSearchable()->check("type", Value("unknown type")).asString();
157157
if (type == "shared") {
158158
yCInfo(COMPANION, " %15s:\t%s", name.c_str(), path.c_str());
159159
}
@@ -165,7 +165,7 @@ int Companion::cmdPlugin(int argc, char *argv[])
165165
Bottle lst = selector.getSelectedPlugins();
166166
for (size_t i=0; i<lst.size(); i++) {
167167
Value& options = lst.get(i);
168-
std::string name = options.check("name", Value("untitled")).asString();
168+
std::string name = options.asSearchable()->check("name", Value("untitled")).asString();
169169
yCInfo(COMPANION, "%s", name.c_str());
170170
}
171171
return 0;
@@ -180,11 +180,11 @@ int Companion::cmdPlugin(int argc, char *argv[])
180180
bool ok = true;
181181
for (size_t i=0; i<lst.size(); i++) {
182182
Value& options = lst.get(i);
183-
std::string name = options.check("name", Value("untitled")).asString();
184-
std::string type = options.check("type", Value("unknown type")).asString();
183+
std::string name = options.asSearchable()->check("name", Value("untitled")).asString();
184+
std::string type = options.asSearchable()->check("type", Value("unknown type")).asString();
185185
yCInfo(COMPANION);
186186
yCInfo(COMPANION, "%s %s", type.c_str(), name.c_str());
187-
yCInfo(COMPANION, " * ini file: %s", options.find("inifile").toString().c_str());
187+
yCInfo(COMPANION, " * ini file: %s", options.asSearchable()->find("inifile").toString().c_str());
188188
options.asList()->pop();
189189
yCInfo(COMPANION, " * config: %s", options.toString().c_str());
190190
YarpPluginSettings settings;
@@ -195,7 +195,7 @@ YARP_DISABLE_DEPRECATED_WARNING
195195
YARP_WARNING_POP
196196
#endif // YARP_NO_DEPRECATED
197197
settings.setSelector(selector);
198-
settings.readFromSearchable(options, name);
198+
settings.readFromSearchable(*options.asSearchable(), name);
199199
ok &= plugin_test(settings);
200200
}
201201
return ok ? 0 : 1;

src/libYARP_dev/src/yarp/dev/Drivers.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ class Drivers::Private : public YarpPluginSelector {
8383
Bottle lst = getSelectedPlugins();
8484
for (size_t i=0; i<lst.size(); i++) {
8585
Value& prop = lst.get(i);
86-
std::string name = prop.check("name",Value("untitled")).asString();
86+
std::string name = prop.asSearchable()->check("name",Value("untitled")).asString();
8787
if (done.check(name)) {
8888
continue;
8989
}
9090

9191
SharedLibraryFactory lib;
9292
YarpPluginSettings settings;
9393
settings.setSelector(*this);
94-
settings.readFromSearchable(prop,name);
94+
settings.readFromSearchable(*prop.asSearchable(),name);
9595
settings.open(lib);
9696
std::string location = lib.getName();
9797
if (location.empty()) {
@@ -100,8 +100,8 @@ class Drivers::Private : public YarpPluginSelector {
100100
continue;
101101
}
102102

103-
std::string cxx = prop.check("cxx",Value("unknown")).asString();
104-
std::string wrapper = prop.check("wrapper",Value("unknown")).asString();
103+
std::string cxx = prop.asSearchable()->check("cxx",Value("unknown")).asString();
104+
std::string wrapper = prop.asSearchable()->check("wrapper",Value("unknown")).asString();
105105
s += "Device \"";
106106
s += name;
107107
s += "\"";

src/libYARP_manager/src/yarp/manager/xmlapploader.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,8 @@ Application* XmlAppLoader::parsXml(const char* szFile)
567567
for(size_t i=1; i<pos.size(); i++)
568568
{
569569
GyPoint pt;
570-
pt.x = pos.get(i).find("x").asFloat64();
571-
pt.y = pos.get(i).find("y").asFloat64();
570+
pt.x = pos.get(i).asSearchable()->find("x").asFloat64();
571+
pt.y = pos.get(i).asSearchable()->find("y").asFloat64();
572572
model.points.push_back(pt);
573573
}
574574
arbitrator.setModelBase(model);
@@ -682,8 +682,8 @@ Application* XmlAppLoader::parsXml(const char* szFile)
682682
for(size_t i=1; i<pos.size(); i++)
683683
{
684684
GyPoint pt;
685-
pt.x = pos.get(i).find("x").asFloat64();
686-
pt.y = pos.get(i).find("y").asFloat64();
685+
pt.x = pos.get(i).asSearchable()->find("x").asFloat64();
686+
pt.y = pos.get(i).asSearchable()->find("y").asFloat64();
687687
model.points.push_back(pt);
688688
}
689689
connection.setModelBase(model);

src/libYARP_manager/src/yarp/manager/yarpbroker.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -703,14 +703,14 @@ bool YarpBroker::getAllProcesses(const char* server,
703703
{
704704
Process proc;
705705
std::string sprc;
706-
if (response.get(i).check("pid")) {
707-
proc.pid = response.get(i).find("pid").asInt32();
706+
if (response.get(i).asSearchable()->check("pid")) {
707+
proc.pid = response.get(i).asSearchable()->find("pid").asInt32();
708708
}
709-
if (response.get(i).check("cmd")) {
710-
sprc = response.get(i).find("cmd").asString();
709+
if (response.get(i).asSearchable()->check("cmd")) {
710+
sprc = response.get(i).asSearchable()->find("cmd").asString();
711711
}
712-
if (response.get(i).check("env") && response.get(i).find("env").asString().length()) {
713-
sprc.append("; ").append(response.get(i).find("env").asString());
712+
if (response.get(i).asSearchable()->check("env") && response.get(i).asSearchable()->find("env").asString().length()) {
713+
sprc.append("; ").append(response.get(i).asSearchable()->find("env").asString());
714714
}
715715
proc.command = sprc;
716716
processes.push_back(proc);

src/libYARP_os/src/yarp/os/Carriers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ bool Carriers::Private::scanForCarrier(const Bytes& header)
186186
selector.scan();
187187
Bottle lst = selector.getSelectedPlugins();
188188
for (size_t i = 0; i < lst.size(); i++) {
189-
if (checkForCarrier(header, lst.get(i))) {
189+
if (checkForCarrier(header, *lst.get(i).asSearchable())) {
190190
return true;
191191
}
192192
}
@@ -333,15 +333,15 @@ Bottle Carriers::listCarriers()
333333
Bottle plugins = instance.mPriv->getSelectedPlugins();
334334
for (size_t i = 0; i < plugins.size(); i++) {
335335
Value& options = plugins.get(i);
336-
std::string name = options.check("name", Value("untitled")).asString();
336+
std::string name = options.asSearchable()->check("name", Value("untitled")).asString();
337337
if (done.check(name)) {
338338
continue;
339339
}
340340

341341
SharedLibraryFactory lib;
342342
YarpPluginSettings settings;
343343
settings.setSelector(*instance.mPriv);
344-
settings.readFromSearchable(options, name);
344+
settings.readFromSearchable(*options.asSearchable(), name);
345345
settings.open(lib);
346346
if (lib.getName().empty()) {
347347
continue;

src/libYARP_os/src/yarp/os/NullConnectionReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,5 @@ void yarp::os::NullConnectionReader::requestDrop()
115115

116116
const yarp::os::Searchable& yarp::os::NullConnectionReader::getConnectionModifiers() const
117117
{
118-
return blank;
118+
return *blank.asSearchable();
119119
}

src/libYARP_os/src/yarp/os/Value.cpp

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ using namespace yarp::os::impl;
1717

1818
Value::Value() :
1919
Portable(),
20-
Searchable(),
2120
proxy(nullptr)
2221
{
2322
}
2423

2524
Value::Value(std::int32_t x, bool isVocab32) :
2625
Portable(),
27-
Searchable(),
2826
proxy(nullptr)
2927
{
3028
if (!isVocab32) {
@@ -36,15 +34,13 @@ Value::Value(std::int32_t x, bool isVocab32) :
3634

3735
Value::Value(yarp::conf::float64_t x) :
3836
Portable(),
39-
Searchable(),
4037
proxy(nullptr)
4138
{
4239
setProxy(static_cast<Storable*>(makeFloat64(x)));
4340
}
4441

4542
Value::Value(const std::string& str, bool isVocab32) :
4643
Portable(),
47-
Searchable(),
4844
proxy(nullptr)
4945
{
5046
if (!isVocab32) {
@@ -56,15 +52,13 @@ Value::Value(const std::string& str, bool isVocab32) :
5652

5753
Value::Value(void* data, int length) :
5854
Portable(),
59-
Searchable(),
6055
proxy(nullptr)
6156
{
6257
setProxy(static_cast<Storable*>(makeBlob(data, length)));
6358
}
6459

6560
Value::Value(const Value& alt) :
6661
Portable(),
67-
Searchable(alt),
6862
proxy(nullptr)
6963
{
7064
setProxy(static_cast<Storable*>(alt.clone()));
@@ -251,11 +245,21 @@ Property* Value::asDict() const
251245

252246
Searchable* Value::asSearchable() const
253247
{
254-
ok();
248+
/*
249+
ok();
255250
if (proxy->isDict()) {
256251
return proxy->asDict();
257252
}
258253
return proxy->asList();
254+
*/
255+
ok();
256+
if (proxy->isDict()) {
257+
return proxy->asDict();
258+
}
259+
if (proxy->isList()) {
260+
return proxy->asList();
261+
}
262+
return nullptr;
259263
}
260264

261265
const char* Value::asBlob() const
@@ -318,24 +322,6 @@ bool Value::write(ConnectionWriter& connection) const
318322
return proxy->write(connection);
319323
}
320324

321-
bool Value::check(const std::string& key) const
322-
{
323-
ok();
324-
return proxy->check(key);
325-
}
326-
327-
Value& Value::find(const std::string& key) const
328-
{
329-
ok();
330-
return proxy->find(key);
331-
}
332-
333-
Bottle& Value::findGroup(const std::string& key) const
334-
{
335-
ok();
336-
return proxy->findGroup(key);
337-
}
338-
339325
bool Value::operator==(const Value& alt) const
340326
{
341327
ok();

src/libYARP_os/src/yarp/os/Value.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,23 @@ class Storable;
2929

3030
namespace yarp::os {
3131

32+
class stringConvertible
33+
{
34+
public:
35+
virtual std::string toString() const = 0;
36+
};
3237
/**
3338
* A single value (typically within a Bottle). Values can be integers, strings,
3439
* doubles (floating-point numbers), lists, vocabulary, or blobs
3540
* (unformatted binary data). This set is carefully chosen to have
3641
* good text and binary representations both for network transmission
3742
* and human viewing/generation. Lists are represented as a nested
38-
* Bottle object. Value objects are Searchable - but you won't
39-
* find anything in them unless they are actually a list.
43+
* Bottle object.
4044
*
4145
*/
42-
class YARP_os_API Value : public Portable, public Searchable
46+
class YARP_os_API Value : public Portable, stringConvertible
4347
{
4448
public:
45-
using Searchable::check;
46-
using Searchable::findGroup;
4749

4850
/**
4951
* Construct a list Value
@@ -178,6 +180,12 @@ class YARP_os_API Value : public Portable, public Searchable
178180
*/
179181
virtual bool isBlob() const;
180182

183+
/**
184+
* Checks if value is null.
185+
* @return true iff value is null.
186+
*/
187+
virtual bool isNull() const;
188+
181189
/**
182190
* Get boolean value.
183191
* @return boolean value if value is indeed a boolean.
@@ -306,15 +314,6 @@ class YARP_os_API Value : public Portable, public Searchable
306314
// documented in Portable
307315
bool write(ConnectionWriter& connection) const override;
308316

309-
// documented in Searchable
310-
bool check(const std::string& key) const override;
311-
312-
// documented in Searchable
313-
Value& find(const std::string& key) const override;
314-
315-
// documented in Searchable
316-
Bottle& findGroup(const std::string& key) const override;
317-
318317
/**
319318
* Equality test.
320319
* @param alt the value to compare against
@@ -357,8 +356,6 @@ class YARP_os_API Value : public Portable, public Searchable
357356
*/
358357
virtual std::int32_t getCode() const;
359358

360-
bool isNull() const override;
361-
362359
virtual bool isLeaf() const;
363360

364361
/**

src/libYARP_os/src/yarp/os/YarpNameSpace.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ class YARP_os_API YarpNameSpace : public NameSpace
123123
ContactStyle style;
124124
ok = NetworkBase::writeToNameServer(cmd, reply, style);
125125
}
126+
////
127+
std::string ss= reply.toString();
128+
fprintf(stderr, ss.c_str());
129+
////
126130
bool fail = (reply.get(0).toString() == "fail") || !ok;
127131
if (fail) {
128132
if (!style.quiet) {

0 commit comments

Comments
 (0)