YARP
Yet Another Robot Platform
Storable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * Copyright (C) 2006, 2008 Arjan Gijsberts
5  * All rights reserved.
6  *
7  * This software may be modified and distributed under the terms of the
8  * BSD-3-Clause license. See the accompanying LICENSE file for details.
9  */
10 
11 #ifndef YARP_OS_IMPL_STORABLE_H
12 #define YARP_OS_IMPL_STORABLE_H
13 
14 
15 #include <yarp/os/Log.h>
16 #include <yarp/os/LogComponent.h>
17 #include <yarp/os/Value.h>
18 #include <yarp/os/Vocab.h>
19 
20 
21 #define UNIT_MASK \
22  (BOTTLE_TAG_INT8 | \
23  BOTTLE_TAG_INT16 | \
24  BOTTLE_TAG_INT32 | \
25  BOTTLE_TAG_INT64 | \
26  BOTTLE_TAG_FLOAT32 | \
27  BOTTLE_TAG_FLOAT64 | \
28  BOTTLE_TAG_VOCAB | \
29  BOTTLE_TAG_STRING | \
30  BOTTLE_TAG_BLOB)
31 
32 #define GROUP_MASK \
33  (BOTTLE_TAG_LIST | \
34  BOTTLE_TAG_DICT)
35 
37 
38 namespace yarp {
39 namespace os {
40 namespace impl {
41 
47 {
48 public:
52  virtual ~Storable();
53 
57  virtual Storable* createStorable() const = 0;
58 
62  virtual Storable* cloneStorable() const
63  {
64  Storable* item = createStorable();
65  yCAssert(STORABLE, item != nullptr);
66  item->copy(*this);
67  return item;
68  }
69 
73  virtual void copy(const Storable& alt) = 0;
74 
75  bool operator==(const yarp::os::Value& alt) const;
76 
77  yarp::os::Value* create() const override
78  {
79  return createStorable();
80  }
81 
82  yarp::os::Value* clone() const override
83  {
84  return cloneStorable();
85  }
86 
87  static Storable* createByCode(std::int32_t id);
88 
89 
90  bool read(ConnectionReader& connection) override;
91  bool write(ConnectionWriter& connection) const override;
92 
93  virtual bool readRaw(ConnectionReader& connection) = 0;
94  virtual bool writeRaw(ConnectionWriter& connection) const = 0;
95 
96  bool isBool() const override
97  {
98  return false;
99  }
100 
101  bool asBool() const override
102  {
103  return false;
104  }
105 
106  bool isInt8() const override
107  {
108  return false;
109  }
110 
111  std::int8_t asInt8() const override
112  {
113  return 0;
114  }
115 
116  bool isInt16() const override
117  {
118  return false;
119  }
120 
121  std::int16_t asInt16() const override
122  {
123  return 0;
124  }
125 
126  bool isInt32() const override
127  {
128  return false;
129  }
130 
131  std::int32_t asInt32() const override
132  {
133  return 0;
134  }
135 
136  bool isInt64() const override
137  {
138  return false;
139  }
140 
141  std::int64_t asInt64() const override
142  {
143  return 0;
144  }
145 
146  bool isFloat32() const override
147  {
148  return false;
149  }
150 
152  {
153  return 0.0f;
154  }
155 
156  bool isFloat64() const override
157  {
158  return false;
159  }
160 
162  {
163  return 0.0;
164  }
165 
166  bool isString() const override
167  {
168  return false;
169  }
170 
171  std::string asString() const override
172  {
173  return {};
174  }
175 
176  bool isList() const override
177  {
178  return false;
179  }
180 
181  yarp::os::Bottle* asList() const override
182  {
183  return nullptr;
184  }
185 
186  bool isDict() const override
187  {
188  return false;
189  }
190 
191  yarp::os::Property* asDict() const override
192  {
193  return nullptr;
194  }
195 
196  bool isVocab() const override
197  {
198  return false;
199  }
200 
201  std::int32_t asVocab() const override
202  {
203  return 0;
204  }
205 
206  bool isBlob() const override
207  {
208  return false;
209  }
210 
211  const char* asBlob() const override
212  {
213  return static_cast<const char*>(nullptr);
214  }
215 
216  size_t asBlobLength() const override
217  {
218  return 0;
219  }
220 
221  bool isNull() const override
222  {
223  return false;
224  }
225 
226 
227  Searchable* asSearchable() const override
228  {
229  if (isDict()) {
230  return asDict();
231  }
232  return asList();
233  }
235  bool check(const std::string& key) const override;
236 
237  yarp::os::Value& find(const std::string& key) const override;
238  yarp::os::Bottle& findGroup(const std::string& key) const override;
239 
240 
246  virtual void fromString(const std::string& src) = 0;
247 
253  virtual void fromStringNested(const std::string& src)
254  {
255  fromString(src);
256  }
257 
258  std::string toString() const override = 0;
259 
264  virtual std::string toStringNested() const
265  {
266  return toString();
267  }
268 
272  virtual std::int32_t subCode() const
273  {
274  return 0;
275  }
276 
277  bool isLeaf() const override
278  {
279  return true;
280  }
281 };
282 
283 
288  public Storable
289 {
290 public:
291  StoreNull() = default;
292 
293  Storable* createStorable() const override
294  {
295  return new StoreNull();
296  }
297 
298  void copy(const Storable& alt) override
299  {
300  YARP_UNUSED(alt);
301  }
302 
303  std::string toString() const override
304  {
305  return {};
306  }
307 
308  void fromString(const std::string& src) override
309  {
310  YARP_UNUSED(src);
311  }
312 
313  std::int32_t getCode() const override
314  {
315  return -1;
316  }
317 
318  bool readRaw(ConnectionReader& connection) override
319  {
320  YARP_UNUSED(connection);
321  return false;
322  }
323 
324  bool writeRaw(ConnectionWriter& connection) const override
325  {
326  YARP_UNUSED(connection);
327  return false;
328  }
329 
330  bool isNull() const override
331  {
332  return true;
333  }
334 };
335 
336 
341  public Storable
342 {
343 private:
344  std::int8_t x{0};
345 
346 public:
347  StoreInt8() = default;
348 
349  StoreInt8(std::int8_t x) :
350  x(x)
351  {
352  }
353 
354  Storable* createStorable() const override
355  {
356  return new StoreInt8();
357  }
358 
359  void copy(const Storable& alt) override
360  {
361  x = alt.asInt8();
362  }
363 
364  std::string toString() const override;
365  void fromString(const std::string& src) override;
366 
367  static const std::int32_t code;
368  std::int32_t getCode() const override
369  {
370  return code;
371  }
372 
373  bool readRaw(ConnectionReader& reader) override;
374  bool writeRaw(ConnectionWriter& writer) const override;
375 
376  bool isInt8() const override
377  {
378  return true;
379  }
380 
381  bool asBool() const override
382  {
383  return x != 0;
384  }
385 
386  std::int8_t asInt8() const override
387  {
388  return x;
389  }
390 
391  std::int16_t asInt16() const override
392  {
393  return x;
394  }
395 
396  std::int32_t asInt32() const override
397  {
398  return x;
399  }
400 
401  std::int64_t asInt64() const override
402  {
403  return x;
404  }
405 
407  {
408  return x;
409  }
410 
412  {
413  return x;
414  }
415 
416  std::int32_t asVocab() const override
417  {
418  return x;
419  }
420 };
421 
422 
427  public Storable
428 {
429 private:
430  std::int16_t x{0};
431 
432 public:
433  StoreInt16() = default;
434 
435  StoreInt16(std::int16_t x) :
436  x(x)
437  {
438  }
439 
440  Storable* createStorable() const override
441  {
442  return new StoreInt16();
443  }
444 
445  void copy(const Storable& alt) override
446  {
447  x = alt.asInt16();
448  }
449 
450  std::string toString() const override;
451  void fromString(const std::string& src) override;
452 
453  static const std::int32_t code;
454  std::int32_t getCode() const override
455  {
456  return code;
457  }
458 
459  bool readRaw(ConnectionReader& reader) override;
460  bool writeRaw(ConnectionWriter& writer) const override;
461 
462  bool isInt16() const override
463  {
464  return true;
465  }
466 
467  bool asBool() const override
468  {
469  return x != 0;
470  }
471 
472  std::int8_t asInt8() const override
473  {
474  return static_cast<std::int8_t>(x);
475  }
476 
477  std::int16_t asInt16() const override
478  {
479  return x;
480  }
481 
482  std::int32_t asInt32() const override
483  {
484  return x;
485  }
486 
487  std::int64_t asInt64() const override
488  {
489  return x;
490  }
491 
493  {
494  return x;
495  }
496 
498  {
499  return x;
500  }
501 
502  std::int32_t asVocab() const override
503  {
504  return x;
505  }
506 };
507 
508 
513  public Storable
514 {
515 private:
516  std::int32_t x{0};
517 
518 public:
519  StoreInt32() = default;
520 
521  StoreInt32(std::int32_t x) :
522  x(x)
523  {
524  }
525 
526  Storable* createStorable() const override
527  {
528  return new StoreInt32();
529  }
530 
531  void copy(const Storable& alt) override
532  {
533  x = alt.asInt32();
534  }
535 
536  std::string toString() const override;
537  void fromString(const std::string& src) override;
538 
539  static const std::int32_t code;
540  std::int32_t getCode() const override
541  {
542  return code;
543  }
544 
545  bool readRaw(ConnectionReader& reader) override;
546  bool writeRaw(ConnectionWriter& writer) const override;
547 
548  std::int8_t asInt8() const override
549  {
550  return static_cast<std::int8_t>(x);
551  }
552 
553  bool asBool() const override
554  {
555  return x != 0;
556  }
557 
558  std::int16_t asInt16() const override
559  {
560  return static_cast<std::int16_t>(x);
561  }
562 
563  bool isInt32() const override
564  {
565  return true;
566  }
567 
568  std::int32_t asInt32() const override
569  {
570  return x;
571  }
572 
573  std::int64_t asInt64() const override
574  {
575  return x;
576  }
577 
579  {
580  return static_cast<yarp::conf::float32_t>(x);
581  }
582 
584  {
585  return x;
586  }
587 
588  std::int32_t asVocab() const override
589  {
590  return x;
591  }
592 };
593 
598  public Storable
599 {
600 private:
601  std::int64_t x{0};
602 
603 public:
604  StoreInt64() = default;
605 
606  StoreInt64(std::int64_t x) :
607  x(x)
608  {
609  }
610 
611  Storable* createStorable() const override
612  {
613  return new StoreInt64();
614  }
615 
616  void copy(const Storable& alt) override
617  {
618  x = alt.asInt64();
619  }
620 
621  std::string toString() const override;
622  void fromString(const std::string& src) override;
623 
624  static const std::int32_t code;
625  std::int32_t getCode() const override
626  {
627  return code;
628  }
629 
630  bool readRaw(ConnectionReader& reader) override;
631  bool writeRaw(ConnectionWriter& writer) const override;
632 
633  bool isInt64() const override
634  {
635  return true;
636  }
637 
638  bool asBool() const override
639  {
640  return x != 0;
641  }
642 
643  std::int8_t asInt8() const override
644  {
645  return static_cast<std::int8_t>(x);
646  }
647 
648  std::int16_t asInt16() const override
649  {
650  return static_cast<std::int16_t>(x);
651  }
652 
653  std::int32_t asInt32() const override
654  {
655  return static_cast<std::int32_t>(x);
656  }
657 
658  std::int64_t asInt64() const override
659  {
660  return x;
661  }
662 
664  {
665  return static_cast<yarp::conf::float32_t>(x);
666  }
667 
669  {
670  return static_cast<yarp::conf::float64_t>(x);
671  }
672 
673  std::int32_t asVocab() const override
674  {
675  return (std::int32_t)x;
676  }
677 };
678 
683  public Storable
684 {
685 private:
686  yarp::conf::float32_t x{0.0f};
687 
688 public:
689  StoreFloat32() = default;
690 
692  x(x)
693  {
694  }
695 
696  Storable* createStorable() const override
697  {
698  return new StoreFloat32();
699  }
700 
701  void copy(const Storable& alt) override
702  {
703  x = alt.asFloat32();
704  }
705 
706  std::string toString() const override;
707  void fromString(const std::string& src) override;
708 
709  static const std::int32_t code;
710  std::int32_t getCode() const override
711  {
712  return code;
713  }
714 
715  bool readRaw(ConnectionReader& reader) override;
716  bool writeRaw(ConnectionWriter& writer) const override;
717 
718  bool isFloat32() const override
719  {
720  return true;
721  }
722 
723  std::int8_t asInt8() const override
724  {
725  return static_cast<std::int8_t>(x);
726  }
727 
728  std::int16_t asInt16() const override
729  {
730  return static_cast<std::int16_t>(x);
731  }
732 
733  std::int32_t asInt32() const override
734  {
735  return static_cast<std::int32_t>(x);
736  }
737 
738  std::int64_t asInt64() const override
739  {
740  return static_cast<std::int64_t>(x);
741  }
742 
744  {
745  return x;
746  }
747 
749  {
750  return x;
751  }
752 };
753 
758  public Storable
759 {
760 private:
761  yarp::conf::float64_t x{0.0};
762 
763 public:
764  StoreFloat64() = default;
765 
767  x(x)
768  {
769  }
770 
771  Storable* createStorable() const override
772  {
773  return new StoreFloat64();
774  }
775 
776  void copy(const Storable& alt) override
777  {
778  x = alt.asFloat64();
779  }
780 
781  std::string toString() const override;
782  void fromString(const std::string& src) override;
783 
784  static const std::int32_t code;
785  std::int32_t getCode() const override
786  {
787  return code;
788  }
789 
790  bool readRaw(ConnectionReader& reader) override;
791  bool writeRaw(ConnectionWriter& writer) const override;
792 
793  bool isFloat64() const override
794  {
795  return true;
796  }
797 
798  std::int8_t asInt8() const override
799  {
800  return static_cast<std::int8_t>(x);
801  }
802 
803  std::int16_t asInt16() const override
804  {
805  return static_cast<std::int16_t>(x);
806  }
807 
808  std::int32_t asInt32() const override
809  {
810  return static_cast<std::int32_t>(x);
811  }
812 
813  std::int64_t asInt64() const override
814  {
815  return static_cast<std::int64_t>(x);
816  }
817 
819  {
820  return static_cast<yarp::conf::float32_t>(x);
821  }
822 
824  {
825  return x;
826  }
827 };
828 
833  public Storable
834 {
835  std::int32_t x{0};
836 
837 public:
838  StoreVocab() = default;
839 
840  StoreVocab(std::int32_t x) :
841  x(x)
842  {
843  }
844 
845  Storable* createStorable() const override
846  {
847  return new StoreVocab();
848  }
849 
850  void copy(const Storable& alt) override
851  {
852  x = alt.asVocab();
853  }
854 
855  std::string toString() const override;
856  void fromString(const std::string& src) override;
857  std::string toStringNested() const override;
858  void fromStringNested(const std::string& src) override;
859 
860  static const std::int32_t code;
861  std::int32_t getCode() const override
862  {
863  return code;
864  }
865 
866  bool readRaw(ConnectionReader& reader) override;
867  bool writeRaw(ConnectionWriter& writer) const override;
868 
869  bool isBool() const override
870  {
871  return (x == 0 || x == '1');
872  }
873 
874  bool asBool() const override
875  {
876  return x != 0;
877  }
878 
879  std::int32_t asInt32() const override
880  {
881  return x;
882  }
883 
884  std::int64_t asInt64() const override
885  {
886  return x;
887  }
888 
890  {
891  return static_cast<yarp::conf::float32_t>(x);
892  }
893 
895  {
896  return x;
897  }
898 
899  bool isVocab() const override
900  {
901  return true;
902  }
903 
904  std::int32_t asVocab() const override
905  {
906  return x;
907  }
908 
909  std::string asString() const override
910  {
911  return toString();
912  }
913 };
914 
919  public Storable
920 {
921 private:
923 
924 public:
925  StoreString() = default;
926 
927  StoreString(const std::string& x)
928  {
929  this->x = x;
930  }
931 
932  Storable* createStorable() const override
933  {
934  return new StoreString();
935  }
936 
937  void copy(const Storable& alt) override
938  {
939  x = alt.asString();
940  }
941 
942  std::string toString() const override;
943  void fromString(const std::string& src) override;
944  std::string toStringNested() const override;
945  void fromStringNested(const std::string& src) override;
946 
947  static const std::int32_t code;
948  std::int32_t getCode() const override
949  {
950  return code;
951  }
952 
953  bool readRaw(ConnectionReader& reader) override;
954  bool writeRaw(ConnectionWriter& writer) const override;
955 
956  bool isString() const override
957  {
958  return true;
959  }
960 
961  std::string asString() const override
962  {
963  return x;
964  }
965 
966  std::int32_t asVocab() const override
967  {
968  return yarp::os::Vocab::encode(x.c_str());
969  }
970 
971  // Quote and escape a string for printing it nested
972  static std::string quotedString(const std::string& x);
973 };
974 
979  public Storable
980 {
981 private:
983 
984 public:
985  StoreBlob() = default;
986 
987  StoreBlob(const std::string& x)
988  {
989  this->x = x;
990  }
991 
992  Storable* createStorable() const override
993  {
994  return new StoreBlob();
995  }
996 
997  void copy(const Storable& alt) override
998  {
999  if (alt.isBlob()) {
1000  std::string tmp((char*)alt.asBlob(), alt.asBlobLength());
1001  x = tmp;
1002  } else {
1003  x = std::string();
1004  }
1005  }
1006 
1007  std::string toString() const override;
1008  void fromString(const std::string& src) override;
1009  std::string toStringNested() const override;
1010  void fromStringNested(const std::string& src) override;
1011 
1012  static const std::int32_t code;
1013  std::int32_t getCode() const override
1014  {
1015  return code;
1016  }
1017 
1018  bool readRaw(ConnectionReader& reader) override;
1019  bool writeRaw(ConnectionWriter& writer) const override;
1020 
1021  bool isBlob() const override
1022  {
1023  return true;
1024  }
1025 
1026  const char* asBlob() const override
1027  {
1028  return x.c_str();
1029  }
1030 
1031  size_t asBlobLength() const override
1032  {
1033  return x.length();
1034  }
1035 };
1036 
1037 
1042  public Storable
1043 {
1044 private:
1045  yarp::os::Bottle content{};
1046 
1047 public:
1048  StoreList() = default;
1049 
1050  Storable* createStorable() const override
1051  {
1052  return new StoreList();
1053  }
1054 
1055  void copy(const Storable& alt) override
1056  {
1057  content = *(alt.asList());
1058  }
1059 
1060  yarp::os::Bottle& internal()
1061  {
1062  return content;
1063  }
1064 
1065  std::string toString() const override;
1066  void fromString(const std::string& src) override;
1067  std::string toStringNested() const override;
1068  void fromStringNested(const std::string& src) override;
1069 
1070  static const std::int32_t code;
1071  std::int32_t getCode() const override
1072  {
1073  return code + subCode();
1074  }
1075 
1076  bool readRaw(ConnectionReader& reader) override;
1077  bool writeRaw(ConnectionWriter& writer) const override;
1078 
1079  bool isList() const override
1080  {
1081  return true;
1082  }
1083 
1084  yarp::os::Bottle* asList() const override
1085  {
1086  return (yarp::os::Bottle*)(&content);
1087  }
1088 
1089  std::int32_t subCode() const override;
1090 
1091  yarp::os::Value& find(const std::string& key) const override
1092  {
1093  return content.find(key);
1094  }
1095 
1096  yarp::os::Bottle& findGroup(const std::string& key) const override
1097  {
1098  return content.findGroup(key);
1099  }
1100 };
1101 
1102 
1107  public Storable
1108 {
1109 private:
1110  yarp::os::Property content{};
1111 
1112 public:
1113  StoreDict() = default;
1114 
1115  Storable* createStorable() const override
1116  {
1117  return new StoreDict();
1118  }
1119 
1120  void copy(const Storable& alt) override
1121  {
1122  content = *(alt.asDict());
1123  }
1124 
1126  {
1127  return content;
1128  }
1129 
1130  std::string toString() const override;
1131  void fromString(const std::string& src) override;
1132  std::string toStringNested() const override;
1133  void fromStringNested(const std::string& src) override;
1134 
1135  static const std::int32_t code;
1136  std::int32_t getCode() const override
1137  {
1138  return code;
1139  }
1140 
1141  bool readRaw(ConnectionReader& reader) override;
1142  bool writeRaw(ConnectionWriter& writer) const override;
1143 
1144  bool isDict() const override
1145  {
1146  return true;
1147  }
1148 
1149  yarp::os::Property* asDict() const override
1150  {
1151  return const_cast<yarp::os::Property*>(&content);
1152  }
1153 
1154  yarp::os::Value& find(const std::string& key) const override
1155  {
1156  return content.find(key);
1157  }
1158 
1159  yarp::os::Bottle& findGroup(const std::string& key) const override
1160  {
1161  return content.findGroup(key);
1162  }
1163 };
1164 
1165 
1166 template <typename T>
1167 inline std::int32_t subCoder(T& content)
1168 {
1169  std::int32_t c = -1;
1170  bool ok = false;
1171  for (unsigned int i = 0; i < content.size(); ++i) {
1172  std::int32_t sc = content.get(i).getCode();
1173  if (c == -1) {
1174  c = sc;
1175  ok = true;
1176  }
1177  if (sc != c) {
1178  ok = false;
1179  }
1180  }
1181  // just optimize primitive types
1182  if ((c & GROUP_MASK) != 0) {
1183  ok = false;
1184  }
1185  c = ok ? c : 0;
1186  content.specialize(c);
1187  return c;
1188 }
1189 
1190 } // namespace impl
1191 } // namespace os
1192 } // namespace yarp
1193 
1194 #endif // YARP_OS_IMPL_STORABLE_H
yarp::os::impl::StoreInt64::asVocab
std::int32_t asVocab() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:673
yarp::os::impl::StoreString::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:948
yarp::os::impl::StoreFloat32::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:701
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:72
yarp::os::impl::StoreFloat32::StoreFloat32
StoreFloat32(yarp::conf::float32_t x)
Definition: Storable.h:691
yarp::os::impl::StoreVocab::asFloat32
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:889
yarp::os::Value::find
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Value.cpp:330
yarp::os::impl::Storable::fromStringNested
virtual void fromStringNested(const std::string &src)
Initialize from a string representation.
Definition: Storable.h:253
yarp::os::impl::StoreFloat64::asInt64
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:813
yarp::os::impl::StoreInt32::asFloat64
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:583
yarp::os::impl::StoreFloat64::StoreFloat64
StoreFloat64(yarp::conf::float64_t x)
Definition: Storable.h:766
yarp::os::impl::StoreDict
Key/value pairs.
Definition: Storable.h:1106
yarp::os::impl::Storable::asFloat64
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:161
yarp::os::impl::StoreFloat64::asInt16
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:803
YARP_DECLARE_LOG_COMPONENT
#define YARP_DECLARE_LOG_COMPONENT(name)
Definition: LogComponent.h:77
yarp::os::impl::StoreInt64::asInt32
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:653
yarp::os::impl::StoreVocab::asFloat64
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:894
yarp::os::impl::Storable::subCode
virtual std::int32_t subCode() const
Return a code describing this item, used in serializing bottles.
Definition: Storable.h:272
yarp::os::impl::Storable::cloneStorable
virtual Storable * cloneStorable() const
Typed synonym for clone()
Definition: Storable.h:62
yarp::os::impl::StoreFloat64::isFloat64
bool isFloat64() const override
Checks if value is a 64-bit floating point number.
Definition: Storable.h:793
yarp::os::impl::StoreInt64::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:616
yarp::os::impl::Storable::asDict
yarp::os::Property * asDict() const override
Get dictionary (hash table) value.
Definition: Storable.h:191
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:68
yarp::os::impl::StoreInt16::asFloat32
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:492
yarp::sig::file::read
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:656
yarp::os::impl::StoreInt8::asFloat64
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:411
yarp::os::impl::Storable::toStringNested
virtual std::string toStringNested() const
Create string representation, including any syntax that should wrap it such as braces or parentheses.
Definition: Storable.h:264
yarp::os::impl::Storable::isDict
bool isDict() const override
Checks if value is a dictionary.
Definition: Storable.h:186
yarp::os::impl::StoreInt8::asVocab
std::int32_t asVocab() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:416
yarp::os::impl::Storable::isBool
bool isBool() const override
Checks if value is a boolean.
Definition: Storable.h:96
yarp::os::impl::StoreVocab::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:845
YARP_UNUSED
#define YARP_UNUSED(var)
Definition: api.h:159
yarp::os::impl::StoreString::code
static const std::int32_t code
Definition: Storable.h:947
yarp::os::impl::StoreInt8::asBool
bool asBool() const override
Get boolean value.
Definition: Storable.h:381
yarp::os::impl::StoreInt8::code
static const std::int32_t code
Definition: Storable.h:367
yarp::os::impl::StoreInt64::asInt64
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:658
yarp::os::impl::StoreVocab::code
static const std::int32_t code
Definition: Storable.h:860
yarp::os::impl::Storable::isVocab
bool isVocab() const override
Checks if value is a vocabulary identifier.
Definition: Storable.h:196
yarp::os::impl::StoreInt32::asVocab
std::int32_t asVocab() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:588
YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Definition: system.h:339
yarp::os::impl::StoreList::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:1055
yarp::os::impl::StoreInt8::StoreInt8
StoreInt8(std::int8_t x)
Definition: Storable.h:349
yarp::os::impl::StoreFloat32::asInt8
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:723
yarp::os::impl::StoreInt64::asInt16
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:648
yarp::os::impl::StoreBlob::isBlob
bool isBlob() const override
Checks if value is a binary object.
Definition: Storable.h:1021
yarp::os::impl::StoreInt64::asInt8
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:643
yarp::os::impl::Storable::isInt8
bool isInt8() const override
Checks if value is a 8-bit integer.
Definition: Storable.h:106
yarp::os::impl::StoreInt32::code
static const std::int32_t code
Definition: Storable.h:539
yarp::os::impl::StoreString
A string item.
Definition: Storable.h:918
yarp::os::impl::StoreBlob::code
static const std::int32_t code
Definition: Storable.h:1012
yarp::os::impl::StoreFloat64::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:771
yarp::os::impl::StoreInt64::isInt64
bool isInt64() const override
Checks if value is a 64-bit integer.
Definition: Storable.h:633
yarp::os::impl::StoreFloat32::code
static const std::int32_t code
Definition: Storable.h:709
yarp::os::impl::StoreNull::isNull
bool isNull() const override
Checks if the object is invalid.
Definition: Storable.h:330
yarp::os::impl::StoreFloat64::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:776
yarp::os::impl::Storable::clone
yarp::os::Value * clone() const override
Create a copy of the value.
Definition: Storable.h:82
yarp::os::impl::StoreDict::findGroup
yarp::os::Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Definition: Storable.h:1159
yarp::os::impl::StoreNull::readRaw
bool readRaw(ConnectionReader &connection) override
Definition: Storable.h:318
yarp::os::impl::StoreVocab::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:850
yarp::os::impl::StoreInt8::asInt8
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:386
yarp::os::impl::StoreInt64::StoreInt64
StoreInt64(std::int64_t x)
Definition: Storable.h:606
yarp::os::impl::Storable
A single item in a Bottle.
Definition: Storable.h:46
yarp::os::impl::StoreString::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:937
yarp::os::impl::StoreInt16::asInt8
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:472
yarp::os::impl::StoreInt64::code
static const std::int32_t code
Definition: Storable.h:624
yarp::os::impl::StoreNull::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:313
yarp::os::impl::StoreInt16::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:454
yarp::os::impl::StoreDict::asDict
yarp::os::Property * asDict() const override
Get dictionary (hash table) value.
Definition: Storable.h:1149
yarp::os::impl::StoreInt64::asFloat64
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:668
yarp::os::impl::StoreInt8::isInt8
bool isInt8() const override
Checks if value is a 8-bit integer.
Definition: Storable.h:376
yarp::os::impl::StoreDict::code
static const std::int32_t code
Definition: Storable.h:1135
yarp::os::impl::Storable::asFloat32
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:151
yarp::os::impl::Storable::isBlob
bool isBlob() const override
Checks if value is a binary object.
Definition: Storable.h:206
yarp::os::impl::StoreVocab
A vocabulary item.
Definition: Storable.h:832
yarp::os::impl::StoreInt16::code
static const std::int32_t code
Definition: Storable.h:453
yarp::os::impl::Storable::isNull
bool isNull() const override
Checks if the object is invalid.
Definition: Storable.h:221
yarp::os::impl::StoreFloat32::asInt32
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:733
yarp::os::impl::StoreFloat32::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:710
yarp::os::impl::StoreInt64::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:625
yarp::os::impl::Storable::asInt64
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:141
yarp::os::Bottle::findGroup
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Definition: Bottle.cpp:305
Log.h
yarp::os::impl::StoreInt8::asFloat32
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:406
yarp::os::impl::StoreVocab::isBool
bool isBool() const override
Checks if value is a boolean.
Definition: Storable.h:869
yarp::os::impl::Storable::asSearchable
Searchable * asSearchable() const override
Get dictionary or list value.
Definition: Storable.h:227
yarp::os::impl::StoreVocab::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:861
yarp::os::impl::Storable::asBool
bool asBool() const override
Get boolean value.
Definition: Storable.h:101
yarp::os::impl::StoreBlob::StoreBlob
StoreBlob(const std::string &x)
Definition: Storable.h:987
yarp::os::impl::StoreString::asVocab
std::int32_t asVocab() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:966
yarp::os::impl::StoreInt64::asBool
bool asBool() const override
Get boolean value.
Definition: Storable.h:638
yarp::os::impl::StoreInt16::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:440
yarp::os::impl::StoreString::isString
bool isString() const override
Checks if value is a string.
Definition: Storable.h:956
yarp::os::impl::StoreFloat64::asFloat32
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:818
yarp::os::impl::StoreInt32::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:531
yarp::os::impl::StoreInt16::asInt16
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:477
yarp::os::impl::StoreVocab::isVocab
bool isVocab() const override
Checks if value is a vocabulary identifier.
Definition: Storable.h:899
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:39
yarp::os::impl::StoreNull::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:293
yarp::os::impl::Storable::isFloat64
bool isFloat64() const override
Checks if value is a 64-bit floating point number.
Definition: Storable.h:156
yarp::os::impl::Storable::asBlob
const char * asBlob() const override
Get binary data value.
Definition: Storable.h:211
yarp::os::impl::StoreBlob::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:997
yarp::os::impl::StoreInt32::asInt8
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:548
yarp::os::impl::StoreVocab::asInt64
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:884
yarp::os::impl::StoreList::find
yarp::os::Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Storable.h:1091
yarp::os::impl::StoreList::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:1071
yarp::os::impl::StoreVocab::asBool
bool asBool() const override
Get boolean value.
Definition: Storable.h:874
yarp::os::impl::Storable::isInt32
bool isInt32() const override
Checks if value is a 32-bit integer.
Definition: Storable.h:126
yarp::os::impl::StoreNull::writeRaw
bool writeRaw(ConnectionWriter &connection) const override
Definition: Storable.h:324
yarp::os::impl::StoreInt16::asFloat64
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:497
yarp::os::impl::StoreInt16::asInt64
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:487
yarp::os::impl::StoreVocab::asVocab
std::int32_t asVocab() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:904
yarp::os::impl::StoreBlob::asBlobLength
size_t asBlobLength() const override
Get binary data length.
Definition: Storable.h:1031
yarp::os::impl::StoreString::asString
std::string asString() const override
Get string value.
Definition: Storable.h:961
yarp::os::impl::StoreFloat32::isFloat32
bool isFloat32() const override
Checks if value is a 32-bit floating point number.
Definition: Storable.h:718
yarp::os::impl::Storable::isFloat32
bool isFloat32() const override
Checks if value is a 32-bit floating point number.
Definition: Storable.h:146
yarp::os::impl::StoreList::asList
yarp::os::Bottle * asList() const override
Get list value.
Definition: Storable.h:1084
yarp::os::impl::StoreList
A nested list of items.
Definition: Storable.h:1041
yarp::os::impl::Storable::isInt16
bool isInt16() const override
Checks if value is a 16-bit integer.
Definition: Storable.h:116
yarp::os::impl::StoreInt64::asFloat32
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:663
yarp::os::impl::StoreFloat32
A 32-bit floating point number item.
Definition: Storable.h:682
yarp::os::Searchable::check
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
yarp::os::impl::StoreInt8::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:354
yarp::os::impl::StoreFloat64::code
static const std::int32_t code
Definition: Storable.h:784
GROUP_MASK
#define GROUP_MASK
Definition: Storable.h:32
yarp::os::impl::StoreInt16::asInt32
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:482
yarp::os::impl::StoreString::StoreString
StoreString(const std::string &x)
Definition: Storable.h:927
yarp::os::Vocab::encode
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
Definition: Vocab.cpp:14
yarp::os::impl::StoreNull::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:298
yarp::os::impl::Storable::asList
yarp::os::Bottle * asList() const override
Get list value.
Definition: Storable.h:181
yarp::os::impl::StoreInt16::StoreInt16
StoreInt16(std::int16_t x)
Definition: Storable.h:435
yarp::os::impl::StoreFloat64
A 64-bit floating point number item.
Definition: Storable.h:757
YARP_os_impl_API
#define YARP_os_impl_API
Definition: api.h:45
yarp::os::impl::StoreInt32::asInt32
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:568
yarp::os::impl::StoreList::isList
bool isList() const override
Checks if value is a list.
Definition: Storable.h:1079
yarp::os::impl::StoreInt32::StoreInt32
StoreInt32(std::int32_t x)
Definition: Storable.h:521
yarp::os::impl::StoreInt32::asBool
bool asBool() const override
Get boolean value.
Definition: Storable.h:553
yarp::os::impl::StoreInt8::asInt32
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:396
yarp::os::impl::StoreString::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:932
yarp::os::impl::StoreInt32::asInt16
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:558
yarp::os::impl::StoreList::findGroup
yarp::os::Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Definition: Storable.h:1096
LogComponent.h
yCAssert
#define yCAssert(component, x)
Definition: LogComponent.h:172
yarp::conf::float32_t
float float32_t
Definition: numeric.h:50
yarp::os::impl::Storable::isLeaf
bool isLeaf() const override
Definition: Storable.h:277
yarp::os::impl::StoreInt64
A 64-bit integer item.
Definition: Storable.h:597
yarp::os::impl::StoreList::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:1050
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:39
yarp::os::impl::Storable::copy
virtual void copy(const Storable &alt)=0
Become a copy of the passed item.
yarp::os::impl::StoreFloat64::asInt8
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:798
yarp::os::impl::Storable::asInt8
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:111
yarp::os::impl::StoreFloat32::asInt64
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:738
yarp::os::impl::StoreInt32::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:526
yarp::os::impl::StoreInt8::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:359
yarp::os::impl::StoreInt8::asInt64
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:401
yarp::os::impl::StoreFloat32::asFloat64
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:748
yarp::os::impl::StoreVocab::StoreVocab
StoreVocab(std::int32_t x)
Definition: Storable.h:840
yarp::os::impl::StoreInt64::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:611
yarp::os::impl::StoreInt16::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:445
yarp::os::impl::StoreInt8::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:368
yarp::os::impl::Storable::asBlobLength
size_t asBlobLength() const override
Get binary data length.
Definition: Storable.h:216
yarp::os::impl::Storable::isString
bool isString() const override
Checks if value is a string.
Definition: Storable.h:166
yarp::os::impl::Storable::isInt64
bool isInt64() const override
Checks if value is a 64-bit integer.
Definition: Storable.h:136
yarp::os::impl::StoreInt32::asFloat32
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:578
yarp::os::impl::StoreInt16::asBool
bool asBool() const override
Get boolean value.
Definition: Storable.h:467
yarp::os::impl::StoreFloat64::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:785
toString
std::string toString(const T &value)
convert an arbitrary type to string.
Definition: fakeMotionControl.cpp:121
yarp::os::impl::StoreInt8::asInt16
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:391
yarp
Definition: environment.h:18
yarp::os::impl::StoreDict::isDict
bool isDict() const override
Checks if value is a dictionary.
Definition: Storable.h:1144
yarp::os::impl::StoreNull::fromString
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
Definition: Storable.h:308
yarp::os::impl::Storable::asString
std::string asString() const override
Get string value.
Definition: Storable.h:171
Vocab.h
yarp::os::impl::StoreInt8
A 8-bit integer item.
Definition: Storable.h:340
yarp::os::impl::StoreBlob::asBlob
const char * asBlob() const override
Get binary data value.
Definition: Storable.h:1026
yarp::os::impl::Storable::asInt32
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:131
yarp::os::impl::StoreBlob
A binary blob item.
Definition: Storable.h:978
yarp::os::impl::StoreInt32::isInt32
bool isInt32() const override
Checks if value is a 32-bit integer.
Definition: Storable.h:563
yarp::os::impl::Storable::create
yarp::os::Value * create() const override
Create a new value of the same type.
Definition: Storable.h:77
yarp::conf::float64_t
double float64_t
Definition: numeric.h:51
yarp::os::impl::StoreInt32::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:540
yarp::os::impl::StoreNull::toString
std::string toString() const override
Return a standard text representation of the content of the object.
Definition: Storable.h:303
yarp::os::impl::StoreVocab::asInt32
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:879
yarp::os::impl::StoreInt32
A 32-bit integer item.
Definition: Storable.h:512
yarp::os::impl::StoreFloat32::asFloat32
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:743
yarp::sig::file::write
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:804
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:46
yarp::os::impl::StoreInt32::asInt64
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:573
yarp::os::impl::StoreList::code
static const std::int32_t code
Definition: Storable.h:1070
yarp::os::impl::StoreInt16
A 16-bit integer item.
Definition: Storable.h:426
yarp::os::impl::StoreDict::find
yarp::os::Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Storable.h:1154
STORABLE
const yarp::os::LogComponent & STORABLE()
Definition: Storable.cpp:45
yarp::os::impl::StoreDict::copy
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:1120
yarp::os::impl::StoreVocab::asString
std::string asString() const override
Get string value.
Definition: Storable.h:909
yarp::os::impl::StoreDict::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:1115
yarp::os::impl::subCoder
std::int32_t subCoder(T &content)
Definition: Storable.h:1167
yarp::os::impl::StoreBlob::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:1013
yarp::os::impl::StoreFloat32::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:696
yarp::os::impl::StoreFloat64::asInt32
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:808
yarp::os::impl::Storable::asVocab
std::int32_t asVocab() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:201
Value.h
yarp::os::impl::StoreDict::getCode
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:1136
yarp::os::impl::StoreFloat64::asFloat64
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:823
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:34
yarp::os::impl::StoreNull
An empty item.
Definition: Storable.h:287
yarp::os::impl::Storable::asInt16
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:121
yarp::os::impl::StoreInt16::isInt16
bool isInt16() const override
Checks if value is a 16-bit integer.
Definition: Storable.h:462
yarp::os::impl::Storable::isList
bool isList() const override
Checks if value is a list.
Definition: Storable.h:176
yarp::os::impl::StoreFloat32::asInt16
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:728
yarp::os::impl::StoreInt16::asVocab
std::int32_t asVocab() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:502
yarp::os::impl::StoreBlob::createStorable
Storable * createStorable() const override
Factory method.
Definition: Storable.h:992