Robot Raconteur Core C++ Library
Loading...
Searching...
No Matches
DataTypes.h
Go to the documentation of this file.
1
23
24#include <string>
25#include <vector>
26
27#include <stdint.h>
28#include <map>
29#include <deque>
30#include <list>
31
32#include <boost/array.hpp>
33#include <boost/tuple/tuple.hpp>
34
37
38#include <stdexcept>
39
41
42#ifdef ROBOTRACONTEUR_USE_SMALL_VECTOR
43#include <boost/container/small_vector.hpp>
44#endif
45
46#include <boost/asio/buffer.hpp>
47
48#include <boost/utility/value_init.hpp>
49#include <boost/container/static_vector.hpp>
50#include <boost/foreach.hpp>
51#include <boost/range/adaptor/map.hpp>
52#include <boost/range/numeric.hpp>
53
54#include <boost/smart_ptr/intrusive_ref_counter.hpp>
55
56#include <boost/numeric/conversion/cast.hpp>
57
58#include <boost/lexical_cast.hpp>
59
60#include <boost/utility/string_ref.hpp>
61
62#include <boost/variant.hpp>
63
64#include <boost/date_time/posix_time/ptime.hpp>
65#include "boost/date_time/posix_time/posix_time_types.hpp"
66
67#pragma once
68
69namespace RobotRaconteur
70{
76struct ROBOTRACONTEUR_CORE_API cdouble
77{
79 double real;
81 double imag;
83 cdouble() : real(0.0), imag(0.0) {}
90 cdouble(double r, double i) : real(r), imag(i) {}
91};
92
98struct ROBOTRACONTEUR_CORE_API cfloat
99{
101 float real;
103 float imag;
105 cfloat() : real(0.0), imag(0.0) {}
112 cfloat(float r, float i) : real(r), imag(i) {}
113};
114
121struct ROBOTRACONTEUR_CORE_API rr_bool
122{
128 uint8_t value;
129
131 rr_bool() : value(0) {}
137 rr_bool(uint8_t b) : value(b) {}
138};
139
140ROBOTRACONTEUR_CORE_API bool operator==(const cdouble& c1, const cdouble& c2);
141ROBOTRACONTEUR_CORE_API bool operator!=(const cdouble& c1, const cdouble& c2);
142ROBOTRACONTEUR_CORE_API bool operator==(const cfloat& c1, const cfloat& c2);
143ROBOTRACONTEUR_CORE_API bool operator!=(const cfloat& c1, const cfloat& c2);
144ROBOTRACONTEUR_CORE_API bool operator==(const rr_bool& c1, const rr_bool& c2);
145ROBOTRACONTEUR_CORE_API bool operator!=(const rr_bool& c1, const rr_bool& c2);
146
147template <typename T, typename U>
148class rr_cast_support
149{
150 public:
151 static RR_SHARED_PTR<T> rr_cast(const RR_SHARED_PTR<U>& objin)
152 {
153 if (!objin)
154 return RR_SHARED_PTR<T>();
155
156 RR_SHARED_PTR<T> c = RR_DYNAMIC_POINTER_CAST<T>(objin);
157 if (!c)
158 {
159 throw DataTypeMismatchException("Data type cast error");
160 }
161
162 return c;
163 }
164
165 static RR_INTRUSIVE_PTR<T> rr_cast(const RR_INTRUSIVE_PTR<U>& objin)
166 {
167 if (!objin)
168 return RR_INTRUSIVE_PTR<T>();
169
170 RR_INTRUSIVE_PTR<T> c = RR_DYNAMIC_POINTER_CAST<T>(objin);
171 if (!c)
172 {
173 throw DataTypeMismatchException("Data type cast error");
174 }
175
176 return c;
177 }
178};
179
180template <typename T>
181class rr_cast_support<T, T>
182{
183 public:
184 static const RR_SHARED_PTR<T>& rr_cast(const RR_SHARED_PTR<T>& objin) { return objin; }
185
186 static const RR_INTRUSIVE_PTR<T>& rr_cast(const RR_INTRUSIVE_PTR<T>& objin) { return objin; }
187};
188
198template <typename T, typename U>
199static RR_SHARED_PTR<T> rr_cast(const RR_SHARED_PTR<U>& objin)
200{
201 return rr_cast_support<T, U>::rr_cast(objin);
202}
203
214template <typename T, typename U>
215static RR_INTRUSIVE_PTR<T> rr_cast(const RR_INTRUSIVE_PTR<U>& objin)
216{
217 return rr_cast_support<T, U>::rr_cast(objin);
218}
219
227class ROBOTRACONTEUR_CORE_API RRObject : boost::noncopyable
228{
229 public:
230 RRObject();
231
232 virtual ~RRObject() {}
233
240 virtual std::string RRType() = 0;
241};
242
251class ROBOTRACONTEUR_CORE_API RRValue : public boost::intrusive_ref_counter<RRValue>, boost::noncopyable
252{
253 public:
254 RRValue();
255
256 virtual ~RRValue() {}
257
258 virtual std::string RRType() = 0;
259};
260
261namespace detail
262{
263class ROBOTRACONTEUR_CORE_API MessageStringData
264{
265 public:
266 std::string str;
267};
268
269class ROBOTRACONTEUR_CORE_API MessageStringData_string_ref
270{
271 public:
272 boost::string_ref ref;
273 MessageStringData_string_ref(const boost::string_ref& r) : ref(r) {}
274};
275class ROBOTRACONTEUR_CORE_API MessageStringData_static_string
276{
277 public:
278 boost::string_ref ref;
279 MessageStringData_static_string(const boost::string_ref& r) : ref(r) {}
280};
281
282} // namespace detail
283
284class ROBOTRACONTEUR_CORE_API MessageStringRef;
285
286class ROBOTRACONTEUR_CORE_API MessageStringPtr
287{
288 private:
289 boost::variant<detail::MessageStringData, detail::MessageStringData_static_string> _str_ptr;
290
291 public:
292 friend class MessageStringRef;
293
294 MessageStringPtr();
295
296 MessageStringPtr(const std::string& str);
297 MessageStringPtr(boost::string_ref str, bool is_static = false);
298 MessageStringPtr(const MessageStringPtr& str_ptr);
299 MessageStringPtr(const MessageStringRef& str_ref);
300#ifndef ROBOTRACONTEUR_NO_CXX11
301 MessageStringPtr(std::string&& str);
302#endif
303 // WARNING: ONLY USE WITH STRING LITERALS OR STATIC STRINGS!
304 template <size_t N>
305 inline MessageStringPtr(const char (&str)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays)
306 {
307 init_literal(str, strlen(str));
308 }
309
310 boost::string_ref str() const;
311 void reset();
312
313 bool operator==(MessageStringRef b) const;
314 bool operator!=(MessageStringRef b) const;
315 bool operator<(MessageStringRef b) const;
316
317 private:
318 void init_literal(const char* str, size_t len);
319};
320
321class ROBOTRACONTEUR_CORE_API MessageStringRef
322{
323 private:
324 boost::variant<const detail::MessageStringData*, detail::MessageStringData_static_string,
325 detail::MessageStringData_string_ref>
326 _str;
327
328 public:
329 friend class MessageStringPtr;
330
331 MessageStringRef(const std::string& str);
332 MessageStringRef(boost::string_ref str, bool is_static = false);
333 MessageStringRef(const MessageStringPtr& str_ptr);
334 MessageStringRef(const MessageStringRef& str_ref);
335
336 // WARNING: ONLY USE WITH STRING LITERALS OR STATIC STRINGS!
337 template <size_t N>
338 inline MessageStringRef(const char (&str)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays)
339 {
340 init_literal(str, strlen(str));
341 }
342
343 bool operator==(MessageStringRef b) const;
344 bool operator!=(MessageStringRef b) const;
345
346 boost::string_ref str() const;
347
348 private:
349 void init_literal(const char* str, size_t len);
350};
351
352std::size_t hash_value(const RobotRaconteur::MessageStringPtr& k);
353
354ROBOTRACONTEUR_CORE_API std::ostream& operator<<(std::ostream& out, const MessageStringPtr& str);
355ROBOTRACONTEUR_CORE_API std::ostream& operator<<(std::ostream& out, const MessageStringRef& str);
356
357// boost::string_ref operations
358inline boost::iterator_range<boost::string_ref::const_iterator> to_range(const boost::string_ref& str)
359{
360 return boost::iterator_range<boost::string_ref::const_iterator>(str.cbegin(), str.cend());
361}
362
363inline std::string operator+(const char* lhs, boost::string_ref rhs) { return lhs + rhs.to_string(); }
364
365inline std::string operator+(const std::string& lhs, boost::string_ref rhs) { return lhs + rhs.to_string(); }
366
367inline std::string operator+(boost::string_ref lhs, const char* rhs) { return lhs.to_string() + rhs; }
368
373class ROBOTRACONTEUR_CORE_API MessageElementData : public RRValue
374{
375 public:
376 virtual MessageStringPtr GetTypeString() = 0;
377 virtual DataTypes GetTypeID() = 0;
378};
379
380template <typename T>
381class RRArray;
382
390template <typename T>
391static RR_INTRUSIVE_PTR<RRArray<T> > ScalarToRRArray(T value);
392
400template <typename T>
401static T RRArrayToScalar(const RR_INTRUSIVE_PTR<RRArray<T> >& value);
402
411ROBOTRACONTEUR_CORE_API RR_INTRUSIVE_PTR<RRArray<char> > stringToRRArray(boost::string_ref str);
412
421ROBOTRACONTEUR_CORE_API std::string RRArrayToString(const RR_INTRUSIVE_PTR<RRArray<char> >& arr);
422
423template <typename T>
424class RRPrimUtil
425{
426 public:
427 static DataTypes GetTypeID() { return DataTypes_void_t; }
428
429 static RR_INTRUSIVE_PTR<T> PrePack(const T& val) { return val; }
430
431 template <typename U>
432 static T PreUnpack(U& val)
433 {
434 return rr_cast<T>(val);
435 }
436
437 virtual ~RRPrimUtil(){};
438
439 typedef RR_INTRUSIVE_PTR<RRValue> BoxedType;
440};
441
442template <typename T>
443class RRPrimUtil<RR_INTRUSIVE_PTR<T> >
444{
445 public:
446 static DataTypes GetTypeID() { return DataTypes_void_t; }
447 static MessageStringPtr GetElementTypeString() { return MessageStringPtr(""); }
448
449 static boost::string_ref GetRRElementTypeString() { return ""; }
450
451 static RR_INTRUSIVE_PTR<RRValue> PrePack(const RR_INTRUSIVE_PTR<T>& val) { return rr_cast<RRValue>(val); }
452
453 template <typename U>
454 static RR_INTRUSIVE_PTR<T> PreUnpack(const U& val)
455 {
456 return rr_cast<T>(val);
457 }
458
459 virtual ~RRPrimUtil(){};
460
461 typedef RR_INTRUSIVE_PTR<T> BoxedType;
462};
463
464template <>
465class RRPrimUtil<std::string>
466{
467 public:
468 static DataTypes GetTypeID() { return DataTypes_string_t; }
469 static MessageStringPtr GetElementTypeString() { return MessageStringPtr(""); }
470 static boost::string_ref GetRRElementTypeString() { return ""; }
471 static RR_INTRUSIVE_PTR<RRValue> PrePack(boost::string_ref val);
472 static std::string PreUnpack(const RR_INTRUSIVE_PTR<RRValue>& val);
473
474 virtual ~RRPrimUtil(){};
475
476 typedef RR_INTRUSIVE_PTR<RRArray<char> > BoxedType;
477};
478
479#define RRPrimUtilNumeric(x, code) \
480 template <> \
481 class RRPrimUtil<x> \
482 { \
483 public: \
484 static DataTypes GetTypeID() { return code; } \
485 static MessageStringPtr GetElementTypeString() { return MessageStringPtr(""); } \
486 static boost::string_ref GetRRElementTypeString() { return ""; } \
487 static RR_INTRUSIVE_PTR<RRArray<x> > PrePack(const x& val); \
488 template <typename U> \
489 static x PreUnpack(const U& val) \
490 { \
491 return RRArrayToScalar(rr_cast<RRArray<x> >(val)); \
492 } \
493 typedef RR_INTRUSIVE_PTR<RRArray<x> > BoxedType; \
494 };
495
496RRPrimUtilNumeric(double, DataTypes_double_t);
497RRPrimUtilNumeric(float, DataTypes_single_t);
498
499RRPrimUtilNumeric(int8_t, DataTypes_int8_t);
500RRPrimUtilNumeric(uint8_t, DataTypes_uint8_t);
501RRPrimUtilNumeric(int16_t, DataTypes_int16_t);
502RRPrimUtilNumeric(uint16_t, DataTypes_uint16_t);
503RRPrimUtilNumeric(int32_t, DataTypes_int32_t);
504RRPrimUtilNumeric(uint32_t, DataTypes_uint32_t);
505RRPrimUtilNumeric(int64_t, DataTypes_int64_t);
506RRPrimUtilNumeric(uint64_t, DataTypes_uint64_t);
507RRPrimUtilNumeric(char, DataTypes_string_t);
508RRPrimUtilNumeric(cdouble, DataTypes_cdouble_t);
509RRPrimUtilNumeric(cfloat, DataTypes_csingle_t);
510RRPrimUtilNumeric(rr_bool, DataTypes_bool_t);
511
512ROBOTRACONTEUR_CORE_API std::string GetRRDataTypeString(DataTypes type);
513ROBOTRACONTEUR_CORE_API bool IsTypeRRArray(DataTypes type);
514ROBOTRACONTEUR_CORE_API bool IsTypeNumeric(DataTypes type);
515
524class ROBOTRACONTEUR_CORE_API RRBaseArray : public MessageElementData
525{
526 public:
527 RR_OVIRTUAL MessageStringPtr GetTypeString() RR_OVERRIDE
528 {
529 std::string type = GetRRDataTypeString(GetTypeID());
530 return type + "[]";
531 }
532
533 RR_OVIRTUAL ~RRBaseArray() RR_OVERRIDE {}
534
540 virtual size_t size() = 0;
541
542 RR_OVIRTUAL std::string RRType() RR_OVERRIDE;
543
549 virtual void* void_ptr() = 0;
550
556 virtual size_t ElementSize() = 0;
557};
558
576template <typename T>
577class RRArray : public RRBaseArray
578{
579 public:
580 RR_OVIRTUAL DataTypes GetTypeID() RR_OVERRIDE { return RRPrimUtil<T>::GetTypeID(); }
581
582 RRArray(T* data, size_t length, bool owned) : data_(data), element_count(length), owned(owned) {}
583
584 RR_OVIRTUAL ~RRArray() RR_OVERRIDE
585 {
586 if (owned)
587 delete[] data_;
588 }
589
590 RR_OVIRTUAL void* void_ptr() RR_OVERRIDE { return data(); }
591
592 T* operator->() const { return data; }
593
594 RR_OVIRTUAL size_t size() RR_OVERRIDE { return element_count; }
595
596 RR_OVIRTUAL size_t ElementSize() RR_OVERRIDE { return sizeof(T); }
597
598 // C++ container support functions based on boost::array
599
600 // type definitions
602 typedef T value_type;
604 typedef T* iterator;
606 typedef const T* const_iterator;
608 typedef T& reference;
610 typedef const T& const_reference;
612 typedef std::size_t size_type;
614 typedef std::ptrdiff_t difference_type;
615
616 // iterator support
617
619 iterator begin() { return data_; }
621 const_iterator begin() const { return data_; }
623 const_iterator cbegin() const { return data_; }
624
626 iterator end() { return data_ + element_count; }
628 const_iterator end() const { return data_ + element_count; }
630 const_iterator cend() const { return data_ + element_count; }
631
633 typedef boost::reverse_iterator<iterator> reverse_iterator;
635 typedef boost::reverse_iterator<const_iterator> const_reverse_iterator;
636
643
650
653 {
654 BOOST_ASSERT_MSG(i < element_count, "out of range");
655 return data_[i];
656 }
657
660 {
661 BOOST_ASSERT_MSG(i < element_count, "out of range");
662 return data_[i];
663 }
664
667 {
668 rangecheck(i);
669 return data_[i];
670 }
671
673 {
674 rangecheck(i);
675 return data_[i];
676 }
677
679 reference front() { return data_[0]; }
680
682 const_reference front() const { return data_[0]; }
683
685 reference back() { return data_[element_count - 1]; }
686
688 const_reference back() const { return data_[element_count - 1]; }
689
691 bool empty() { return false; }
693 size_type max_size() { return element_count; }
694
696 const T* data() const { return data_; }
698 T* data() { return data_; }
699
700 T* c_array() { return data_; }
701
709 template <typename T2>
710 RRArray<T>& operator=(const RRArray<T2>& rhs)
711 {
712 std::copy(rhs.begin(), rhs.end(), begin());
713 return *this;
714 }
715
723 void assign(const T& value) { fill(value); }
729 void fill(const T& value) { std::fill_n(begin(), size(), value); }
730
731 void rangecheck(size_type i)
732 {
733 if (i >= size())
734 {
735 std::out_of_range e("array<>: index out of range");
736 boost::throw_exception(e);
737 }
738 }
739
740 private:
741 T* data_;
742 size_t element_count;
743 bool owned;
744};
745
746// RRPrimUtil members that create or destroy RR_INTRUSIVE_PTR<RRArray<T> > are defined here, after RRArray is
747// complete, so intrusive_ptr_release can be found by ADL when ~intrusive_ptr is instantiated (C++20 constexpr)
748inline RR_INTRUSIVE_PTR<RRValue> RRPrimUtil<std::string>::PrePack(boost::string_ref val)
749{
750 return rr_cast<RRValue>(stringToRRArray(val));
751}
752
753inline std::string RRPrimUtil<std::string>::PreUnpack(const RR_INTRUSIVE_PTR<RRValue>& val)
754{
755 return RRArrayToString(rr_cast<RRArray<char> >(val));
756}
757
758#define RRPrimUtilNumericPrePack(x) \
759 inline RR_INTRUSIVE_PTR<RRArray<x> > RRPrimUtil<x>::PrePack(const x& val) { return ScalarToRRArray(val); }
760
761RRPrimUtilNumericPrePack(double);
762RRPrimUtilNumericPrePack(float);
763RRPrimUtilNumericPrePack(int8_t);
764RRPrimUtilNumericPrePack(uint8_t);
765RRPrimUtilNumericPrePack(int16_t);
766RRPrimUtilNumericPrePack(uint16_t);
767RRPrimUtilNumericPrePack(int32_t);
768RRPrimUtilNumericPrePack(uint32_t);
769RRPrimUtilNumericPrePack(int64_t);
770RRPrimUtilNumericPrePack(uint64_t);
771RRPrimUtilNumericPrePack(char);
772RRPrimUtilNumericPrePack(cdouble);
773RRPrimUtilNumericPrePack(cfloat);
774RRPrimUtilNumericPrePack(rr_bool);
775
776#undef RRPrimUtilNumericPrePack
777
778template <typename T>
779class RRMap_keytype
780{
781 public:
782 static boost::string_ref get()
783 {
784 BOOST_STATIC_ASSERT_MSG(sizeof(T) == 0, "Invalid key type for Robot Raconteur map");
785 throw DataTypeException("Unknown data type");
786 }
787
788 static std::string get_map_rrtype()
789 {
790 BOOST_STATIC_ASSERT_MSG(sizeof(T) == 0, "Invalid key type for Robot Raconteur map");
791 throw DataTypeException("Unknown data type");
792 }
793};
794
795template <>
796class RRMap_keytype<int32_t>
797{
798 public:
799 static boost::string_ref get() { return "int32_t"; }
800
801 static std::string get_map_rrtype() { return "RobotRaconteur.RRMap<int32_t>"; }
802};
803
804template <>
805class RRMap_keytype<std::string>
806{
807 public:
808 static boost::string_ref get() { return "string"; }
809
810 static std::string get_map_rrtype() { return "RobotRaconteur.RRMap<string>"; }
811};
812
823template <typename K, typename T>
824class RRMap : public RRValue
825{
826 protected:
827 std::map<K, RR_INTRUSIVE_PTR<T> > map;
828
829 public:
830 RRMap() {}
831
832 RRMap(const std::map<K, RR_INTRUSIVE_PTR<T> >& mapin) : map(mapin) {}
833
834 RR_OVIRTUAL ~RRMap() RR_OVERRIDE {}
835
836 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return RRMap_keytype<K>::get_map_rrtype(); }
837
838 // C++ container support based on boost::container::map
839
841 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::key_type key_type;
843 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::mapped_type mapped_type;
845 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::value_type value_type;
847 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::pointer pointer;
849 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::const_pointer const_pointer;
851 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::reference reference;
853 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::const_reference const_reference;
855 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::size_type size_type;
857 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::iterator iterator;
859 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::const_iterator const_iterator;
861 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::reverse_iterator reverse_iterator;
863 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::const_reverse_iterator const_reverse_iterator;
864
866 iterator begin() { return map.begin(); }
868 const_iterator cbegin() const { return map.cbegin(); }
870 const_iterator begin() const { return map.begin(); }
872 iterator end() { return map.end(); }
874 const_iterator cend() const { return map.end(); }
876 const_iterator end() const { return map.end(); }
878 reverse_iterator rbegin() { return map.rbegin(); };
880 const_reverse_iterator crbegin() const { return map.crbegin(); };
882 const_reverse_iterator rbegin() const { return map.rbegin(); };
884 reverse_iterator rend() { return map.rend(); }
886 const_reverse_iterator crend() const { return map.rend(); }
888 const_reverse_iterator rend() const { return map.rend(); }
890 bool empty() const { return map.empty(); }
892 size_type size() const { return map.size(); }
894 size_type max_size() const { return map.max_size(); };
896 mapped_type& operator[](const key_type& k) { return map[k]; }
898 mapped_type& at(const key_type& k) { return map.at(k); }
900 const mapped_type& at(const key_type& k) const { return map.at(k); }
902 std::pair<iterator, bool> insert(const value_type& x) { return map.insert(x); }
905 {
906 RR_UNUSED(p);
907 return map.insert(x);
908 }
909
910 template <class InputIterator>
911 void insert(InputIterator first, InputIterator last)
912 {
913 map.insert(first, last);
914 }
915
916 void erase(iterator p) { map.erase(p); }
918 size_type erase(const key_type& x) { return map.erase(x); }
920 void erase(iterator first, iterator last) { map.erase(first, last); }
922 void clear() { map.clear(); }
924 iterator find(const key_type& x) { return map.find(x); }
926 const_iterator find(const key_type& x) const { return map.find(x); }
928 size_type count(const key_type& x) const { return map.count(x); }
929
937 typename std::map<K, RR_INTRUSIVE_PTR<T> >& GetStorageContainer() { return map; }
938};
939
949template <typename T>
950class RRList : public RRValue
951{
952 protected:
953 std::list<RR_INTRUSIVE_PTR<T> > list;
954
955 public:
956 RRList() {}
957
958 RRList(std::list<RR_INTRUSIVE_PTR<T> > listin) { list = listin; }
959
960 RR_OVIRTUAL ~RRList() RR_OVERRIDE {}
961
962 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRList"; }
963
964 // C++ container support based on boost::container::list
965
967 typedef RR_INTRUSIVE_PTR<T> value_type;
969 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::pointer pointer;
971 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::const_pointer const_pointer;
973 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::reference reference;
975 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::const_reference const_reference;
977 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::size_type size_type;
979 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::difference_type difference_type;
981 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::iterator iterator;
983 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::const_iterator const_iterator;
985 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::reverse_iterator reverse_iterator;
987 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::const_reverse_iterator const_reverse_iterator;
988
990 iterator begin() { return list.begin(); }
992 const_iterator begin() const { return list.begin(); }
994 iterator end() { return list.end(); }
996 const_iterator end() const { return list.end(); }
998 reverse_iterator rbegin() { return list.rbegin(); }
1000 const_reverse_iterator rbegin() const { return list.rbegin(); }
1002 reverse_iterator rend() { return list.rend(); }
1004 const_reverse_iterator crend() const { return list.crend(); }
1006 const_reverse_iterator rend() const { return list.rend(); }
1008 const_iterator cbegin() const { return list.cbegin(); }
1010 const_iterator cend() const { return list.cend(); }
1012 const_reverse_iterator const crbegin() { return list.crbegin(); }
1014 const_reverse_iterator const crend() { return list.crend(); }
1016 bool empty() const { return list.empty(); }
1018 virtual size_type size() const { return list.size(); }
1020 size_type max_size() const { return list.max_size(); }
1022 reference front() { return list.front(); }
1024 const_reference front() const { return list.front(); }
1026 reference back() { return list.back(); }
1028 const_reference back() const { return list.back(); }
1030 void push_front(const RR_INTRUSIVE_PTR<T>& x) { list.push_front(x); }
1032 void push_back(const RR_INTRUSIVE_PTR<T>& x) { list.push_back(x); }
1034 void pop_front() { list.pop_front(); }
1036 void pop_back() { list.pop_back(); }
1038 iterator insert(const_iterator p, const RR_INTRUSIVE_PTR<T>& x) { list.insert(p, x); }
1040 iterator erase(const_iterator p) { list.erase(p); }
1042 iterator erase(const_iterator first, const_iterator last) { list.erase(first, last); }
1044 void clear() { list.clear(); }
1046 void remove(const RR_INTRUSIVE_PTR<T>& value) { list.remove(value); }
1047
1055 typename std::list<RR_INTRUSIVE_PTR<T> >& GetStorageContainer() { return list; }
1056};
1057
1066class ROBOTRACONTEUR_CORE_API RRStructure : public RRValue
1067{
1068 public:
1069 RR_OVIRTUAL ~RRStructure() RR_OVERRIDE {}
1070};
1071
1087template <typename T>
1088static RR_INTRUSIVE_PTR<RRArray<T> > AllocateRRArray(size_t length)
1089{
1090 return RR_INTRUSIVE_PTR<RRArray<T> >(new RRArray<T>(new T[length], length, true));
1091}
1092
1111template <typename T>
1112static RR_INTRUSIVE_PTR<RRArray<T> > AttachRRArray(T* data, size_t length, bool owned)
1113{
1114 return RR_INTRUSIVE_PTR<RRArray<T> >(new RRArray<T>(data, length, owned));
1115}
1116
1129template <typename T>
1130static RR_INTRUSIVE_PTR<RRArray<T> > AttachRRArrayCopy(const T* data, const size_t length)
1131{
1132 RR_INTRUSIVE_PTR<RRArray<T> > ret(new RRArray<T>(new T[length], length, true));
1133 memcpy(ret->void_ptr(), data, length * sizeof(T));
1134 return ret;
1135}
1136
1154ROBOTRACONTEUR_CORE_API RR_INTRUSIVE_PTR<RRBaseArray> AllocateRRArrayByType(DataTypes type, size_t length);
1155
1170template <typename T>
1171static RR_INTRUSIVE_PTR<RRArray<T> > AllocateEmptyRRArray(size_t length)
1172{
1173 RR_INTRUSIVE_PTR<RRArray<T> > o = AllocateRRArray<T>(length);
1174 if (length > 0)
1175 {
1176 memset(static_cast<void*>(o->data()), 0, length * sizeof(T));
1177 }
1178 return o;
1179}
1180
1194ROBOTRACONTEUR_CORE_API size_t RRArrayElementSize(DataTypes type);
1195
1203template <typename T>
1204static RR_INTRUSIVE_PTR<RRArray<T> > ScalarToRRArray(T value)
1205{
1206 return AttachRRArrayCopy(&value, 1);
1207}
1208
1216template <typename T>
1217static T RRArrayToScalar(const RR_INTRUSIVE_PTR<RRArray<T> >& value)
1218{
1219 if (!value)
1220 {
1221 throw NullValueException("Null pointer");
1222 }
1223
1224 if (value->size() == 0)
1225 throw OutOfRangeException("Index out of range");
1226
1227 return (*value)[0];
1228}
1229
1243template <typename Y, typename U>
1244static std::vector<Y> RRArrayToVector(const RR_INTRUSIVE_PTR<RRArray<U> >& in)
1245{
1246 if (!in)
1247 throw NullValueException("Unexpected null array");
1248 std::vector<Y> out(in->size());
1249 for (size_t i = 0; i < in->size(); i++)
1250 out[i] = boost::numeric_cast<Y>((*in)[i]);
1251 return out;
1252}
1253
1265template <typename Y, typename U>
1266static RR_INTRUSIVE_PTR<RRArray<Y> > VectorToRRArray(const std::vector<U>& in)
1267{
1268 RR_INTRUSIVE_PTR<RRArray<Y> > out = AllocateRRArray<Y>(in.size());
1269 for (size_t i = 0; i < in.size(); i++)
1270 (*out)[i] = boost::numeric_cast<Y>(in[i]);
1271 return out;
1272}
1273
1286template <typename Y, std::size_t N, typename U>
1287static boost::array<Y, N> RRArrayToArray(const RR_INTRUSIVE_PTR<RRArray<U> >& in)
1288{
1289 if (!in)
1290 throw NullValueException("Unexpected null array");
1291 if (in->size() != N)
1292 throw OutOfRangeException("Array is incorrect size");
1293 boost::array<Y, N> out = {};
1294 for (size_t i = 0; i < N; i++)
1295 out[i] = boost::numeric_cast<Y>((*in)[i]);
1296 return out;
1297}
1298
1310template <typename Y, std::size_t N, typename U>
1311static void RRArrayToArray(boost::array<Y, N>& out, const RR_INTRUSIVE_PTR<RRArray<U> >& in)
1312{
1313 if (!in)
1314 throw NullValueException("Unexpected null array");
1315 if (in->size() != N)
1316 throw OutOfRangeException("Array is incorrect size");
1317 for (size_t i = 0; i < N; i++)
1318 out[i] = boost::numeric_cast<Y>((*in)[i]);
1319}
1320
1333template <typename Y, typename U, std::size_t N>
1334static RR_INTRUSIVE_PTR<RRArray<Y> > ArrayToRRArray(boost::array<U, N> in)
1335{
1336 RR_INTRUSIVE_PTR<RRArray<Y> > out = AllocateRRArray<Y>(N);
1337 for (size_t i = 0; i < N; i++)
1338 (*out)[i] = boost::numeric_cast<Y>(in[i]);
1339 return out;
1340}
1341
1356template <typename Y, std::size_t N, typename U>
1357static boost::container::static_vector<Y, N> RRArrayToStaticVector(const RR_INTRUSIVE_PTR<RRArray<U> >& in)
1358{
1359 if (!in)
1360 throw NullValueException("Unexpected null array");
1361 if (in->size() > N)
1362 throw OutOfRangeException("Array is too large for static vector size");
1363 boost::container::static_vector<Y, N> out(in->size());
1364 for (size_t i = 0; i < in->size(); i++)
1365 out[i] = boost::numeric_cast<Y>((*in)[i]);
1366 return out;
1367}
1368
1383template <typename Y, std::size_t N, typename U>
1384static void RRArrayToStaticVector(boost::container::static_vector<Y, N>& out, const RR_INTRUSIVE_PTR<RRArray<U> >& in)
1385{
1386 if (!in)
1387 throw NullValueException("Unexpected null array");
1388 if (in->size() > N)
1389 throw OutOfRangeException("Array is too large for static vector size");
1390 out.resize(in->size());
1391 for (size_t i = 0; i < in->size(); i++)
1392 out[i] = boost::numeric_cast<Y>((*in)[i]);
1393}
1394
1409template <typename Y, typename U, std::size_t N>
1410static RR_INTRUSIVE_PTR<RRArray<Y> > StaticVectorToRRArray(boost::container::static_vector<U, N> in)
1411{
1412 RR_INTRUSIVE_PTR<RRArray<Y> > out = AllocateRRArray<Y>(in.size());
1413 for (size_t i = 0; i < in.size(); i++)
1414 (*out)[i] = boost::numeric_cast<Y>(in[i]);
1415 return out;
1416}
1417
1426ROBOTRACONTEUR_CORE_API RR_INTRUSIVE_PTR<RRList<RRArray<char> > > stringVectorToRRList(
1427 const std::vector<std::string>& string_vector);
1428
1437ROBOTRACONTEUR_CORE_API std::vector<std::string> RRListToStringVector(
1438 const RR_INTRUSIVE_PTR<RRList<RRArray<char> > >& list);
1439
1451template <typename T>
1452RR_INTRUSIVE_PTR<T>& rr_null_check(RR_INTRUSIVE_PTR<T>& ptr)
1453{
1454 if (!ptr)
1455 {
1456 throw NullValueException("Unexpected null value");
1457 }
1458 return ptr;
1459}
1460
1474template <typename T>
1475RR_INTRUSIVE_PTR<T>& rr_null_check(RR_INTRUSIVE_PTR<T>& ptr, const char* msg)
1476{
1477 if (!ptr)
1478 {
1479 throw NullValueException(msg);
1480 }
1481 return ptr;
1482}
1483
1495template <typename T>
1496const RR_INTRUSIVE_PTR<T>& rr_null_check(const RR_INTRUSIVE_PTR<T>& ptr)
1497{
1498 if (!ptr)
1499 {
1500 throw NullValueException("Unexpected null value");
1501 }
1502 return ptr;
1503}
1504
1518template <typename T>
1519const RR_INTRUSIVE_PTR<T>& rr_null_check(const RR_INTRUSIVE_PTR<T>& ptr, const char* msg)
1520{
1521 if (!ptr)
1522 {
1523 throw NullValueException(msg);
1524 }
1525 return ptr;
1526}
1527
1528#define RR_NULL_CHECK rr_null_check
1529
1530template <typename T>
1531static RR_INTRUSIVE_PTR<RRArray<T> > VerifyRRArrayLength(const RR_INTRUSIVE_PTR<RRArray<T> >& a, size_t len,
1532 bool varlength)
1533{
1534 if (!a)
1535 throw NullValueException("Arrays must not be null");
1536 if (len != 0)
1537 {
1538 if (varlength && (a->size() > len))
1539 {
1540 throw DataTypeException("Array dimension mismatch");
1541 }
1542 if (!varlength && (a->size() != len))
1543 {
1544 throw DataTypeException("Array dimension mismatch");
1545 }
1546 }
1547 return a;
1548}
1549
1550template <typename T>
1551static RR_INTRUSIVE_PTR<RRList<T> > VerifyRRArrayLength(const RR_INTRUSIVE_PTR<RRList<T> >& a, size_t len,
1552 bool varlength)
1553{
1554 if (!a)
1555 return a;
1556 BOOST_FOREACH (RR_INTRUSIVE_PTR<T>& aa, (*a))
1557 {
1558 VerifyRRArrayLength(aa, len, varlength);
1559 }
1560 return a;
1561}
1562
1563template <typename K, typename T>
1564static RR_INTRUSIVE_PTR<RRMap<K, T> > VerifyRRArrayLength(const RR_INTRUSIVE_PTR<RRMap<K, T> >& a, size_t len,
1565 bool varlength)
1566{
1567 if (!a)
1568 return a;
1569 BOOST_FOREACH (const RR_INTRUSIVE_PTR<T>& aa, *a | boost::adaptors::map_values)
1570 {
1571 VerifyRRArrayLength(aa, len, varlength);
1572 }
1573 return a;
1574}
1575
1583class ROBOTRACONTEUR_CORE_API RRMultiDimBaseArray : public RRValue
1584{
1585 public:
1586 RR_OVIRTUAL ~RRMultiDimBaseArray() RR_OVERRIDE {}
1587
1588 virtual DataTypes GetElementTypeID() = 0;
1589};
1590
1591namespace detail
1592{
1593ROBOTRACONTEUR_CORE_API class MultiDimArray_CalculateCopyIndicesIter
1594{
1595 public:
1596 virtual bool Next(uint32_t& indexa, uint32_t& indexb, uint32_t& len) = 0;
1597
1598 virtual ~MultiDimArray_CalculateCopyIndicesIter();
1599};
1600
1601// cSpell: ignore mema, memb
1602ROBOTRACONTEUR_CORE_API RR_SHARED_PTR<MultiDimArray_CalculateCopyIndicesIter>
1603MultiDimArray_CalculateCopyIndicesBeginIter(const std::vector<uint32_t>& mema_dims,
1604 const std::vector<uint32_t>& mema_pos,
1605 const std::vector<uint32_t>& memb_dims,
1606 const std::vector<uint32_t>& memb_pos, const std::vector<uint32_t>& count);
1607} // namespace detail
1608
1629template <typename T>
1630class RRMultiDimArray : public RRMultiDimBaseArray
1631{
1632 public:
1633 RR_INTRUSIVE_PTR<RRArray<uint32_t> > Dims;
1634
1635 RR_INTRUSIVE_PTR<RRArray<T> > Array;
1636
1637 RRMultiDimArray(){};
1638
1639 RRMultiDimArray(const RR_INTRUSIVE_PTR<RRArray<uint32_t> >& Dims, const RR_INTRUSIVE_PTR<RRArray<T> >& Array)
1640 {
1641 this->Dims = Dims;
1642 this->Array = Array;
1643 }
1644
1645 RR_OVIRTUAL ~RRMultiDimArray() RR_OVERRIDE {}
1646
1647 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRMultiDimArray"; }
1648
1649 RR_OVIRTUAL DataTypes GetElementTypeID() RR_OVERRIDE { return RRPrimUtil<T>::GetTypeID(); }
1650
1659 virtual void RetrieveSubArray(const std::vector<uint32_t>& memorypos,
1660 const RR_INTRUSIVE_PTR<RRMultiDimArray<T> >& buffer,
1661 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
1662 {
1663
1664 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
1665 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
1666 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
1667 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
1668
1669 uint32_t len = 0;
1670 uint32_t indexa = 0;
1671 uint32_t indexb = 0;
1672
1673 while (iter->Next(indexa, indexb, len))
1674 {
1675 memcpy((buffer->Array->data() + indexb), (Array->data()) + indexa, len * sizeof(T));
1676 }
1677 }
1678
1687 virtual void AssignSubArray(const std::vector<uint32_t>& memorypos,
1688 const RR_INTRUSIVE_PTR<RRMultiDimArray<T> >& buffer,
1689 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
1690 {
1691
1692 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
1693 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
1694 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
1695 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
1696
1697 uint32_t len = 0;
1698 uint32_t indexa = 0;
1699 uint32_t indexb = 0;
1700
1701 while (iter->Next(indexa, indexb, len))
1702 {
1703 memcpy((Array->data() + indexa), (buffer->Array->data() + indexb), len * sizeof(T));
1704 }
1705 }
1706};
1707
1708template <size_t Ndims, typename T>
1709static RR_INTRUSIVE_PTR<RRMultiDimArray<T> > VerifyRRMultiDimArrayLength(const RR_INTRUSIVE_PTR<RRMultiDimArray<T> >& a,
1710 size_t n_elems,
1711 const boost::array<uint32_t, Ndims>& dims)
1712{
1713 if (!a)
1714 throw NullValueException("Arrays must not be null");
1715
1716 if (a->Dims->size() != Ndims)
1717 {
1718 throw DataTypeException("Array dimension mismatch");
1719 }
1720
1721 if (a->Array->size() != n_elems)
1722 {
1723 throw DataTypeException("Array dimension mismatch");
1724 }
1725
1726 for (size_t i = 0; i < Ndims; i++)
1727 {
1728 if ((*a->Dims)[i] != dims[i])
1729 {
1730 throw DataTypeException("Array dimension mismatch");
1731 }
1732 }
1733
1734 return a;
1735}
1736
1737template <size_t Ndims, typename T>
1738static RR_INTRUSIVE_PTR<RRList<T> > VerifyRRMultiDimArrayLength(const RR_INTRUSIVE_PTR<RRList<T> >& a, size_t n_elems,
1739 const boost::array<uint32_t, Ndims>& dims)
1740{
1741 if (!a)
1742 {
1743 // Containers can be null
1744 return a;
1745 }
1746 else
1747 {
1748 BOOST_FOREACH (const RR_INTRUSIVE_PTR<T>& aa, (*a))
1749 {
1750 VerifyRRMultiDimArrayLength<Ndims>(aa, n_elems, dims);
1751 }
1752 }
1753 return a;
1754}
1755
1756template <size_t Ndims, typename K, typename T>
1757static RR_INTRUSIVE_PTR<RRMap<K, T> > VerifyRRMultiDimArrayLength(const RR_INTRUSIVE_PTR<RRMap<K, T> >& a,
1758 size_t n_elems,
1759 const boost::array<uint32_t, Ndims>& dims)
1760{
1761 if (!a)
1762 {
1763 // Containers can be null
1764 return a;
1765 }
1766 else
1767 {
1768 BOOST_FOREACH (const RR_INTRUSIVE_PTR<T>& aa, *a | boost::adaptors::map_values)
1769 {
1770 VerifyRRMultiDimArrayLength<Ndims>(aa, n_elems, dims);
1771 }
1772 return a;
1773 }
1774}
1775
1786template <typename T>
1787static RR_INTRUSIVE_PTR<RRMultiDimArray<T> > AllocateEmptyRRMultiDimArray(const std::vector<uint32_t>& dims)
1788{
1789 uint32_t n_elems = boost::accumulate(dims, 1, std::multiplies<uint32_t>());
1791}
1792
1799template <typename T>
1800static RR_INTRUSIVE_PTR<RRMultiDimArray<T> > AllocateEmptyRRMultiDimArray()
1801{
1802 std::vector<uint32_t> length;
1803 length.push_back(0);
1805}
1806
1817template <typename T>
1818static RR_INTRUSIVE_PTR<RRMultiDimArray<T> > AllocateRRMultiDimArray(const RR_INTRUSIVE_PTR<RRArray<uint32_t> >& dims,
1819 const RR_INTRUSIVE_PTR<RRArray<T> >& array_)
1820{
1821 return new RRMultiDimArray<T>(dims, array_); // NOLINT(cppcoreguidelines-owning-memory)
1822}
1823
1830template <typename T>
1831RR_INTRUSIVE_PTR<RRList<T> > AllocateEmptyRRList()
1832{
1833 return new RRList<T>(); // NOLINT(cppcoreguidelines-owning-memory)
1834}
1835
1844template <typename T, typename U>
1845RR_INTRUSIVE_PTR<RRList<T> > AllocateRRList(const U& c)
1846{
1847 return new RRList<T>(c); // NOLINT(cppcoreguidelines-owning-memory)
1848}
1849
1857template <typename K, typename T>
1858RR_INTRUSIVE_PTR<RRMap<K, T> > AllocateEmptyRRMap()
1859{
1860 return new RRMap<K, T>(); // NOLINT(cppcoreguidelines-owning-memory)
1861}
1862
1872template <typename K, typename T, typename U>
1873RR_INTRUSIVE_PTR<RRMap<K, T> > AllocateRRMap(const U& c)
1874{
1875 return new RRMap<K, T>(c); // NOLINT(cppcoreguidelines-owning-memory)
1876}
1877
1885class ROBOTRACONTEUR_CORE_API RRPod
1886{
1887 public:
1888};
1889
1896class RRPodBaseArray : public RRValue
1897{
1898 public:
1899 virtual boost::string_ref RRElementTypeString() = 0;
1900};
1901
1916template <typename T>
1917class RRPodArray : public RRPodBaseArray
1918{
1919 protected:
1920 typename std::vector<T> pod_array;
1921
1922 public:
1923 RRPodArray(size_t n) { pod_array.resize(n); }
1924
1925 RRPodArray(typename std::vector<T>& array_in) : pod_array(array_in) {}
1926
1927 RRPodArray(const T& value_in) { pod_array.push_back(value_in); }
1928
1929 RR_OVIRTUAL ~RRPodArray() RR_OVERRIDE {}
1930
1931 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRPodArray"; }
1932
1933 RR_OVIRTUAL boost::string_ref RRElementTypeString() RR_OVERRIDE { return RRPrimUtil<T>::GetRRElementTypeString(); }
1934
1935 // C++ container support based on boost::container::vector
1936
1938 typedef T value_type;
1940 typedef typename std::vector<T>::pointer pointer;
1942 typedef typename std::vector<T>::const_pointer const_pointer;
1944 typedef typename std::vector<T>::reference reference;
1946 typedef typename std::vector<T>::const_reference const_reference;
1948 typedef typename std::vector<T>::size_type size_type;
1950 typedef typename std::vector<T>::iterator iterator;
1952 typedef typename std::vector<T>::const_iterator const_iterator;
1954 typedef typename std::vector<T>::reverse_iterator reverse_iterator;
1956 typedef typename std::vector<T>::const_reverse_iterator const_reverse_iterator;
1957
1959 iterator begin() { return pod_array.begin(); }
1961 const_iterator begin() const { return pod_array.begin(); }
1963 iterator end() { return pod_array.end(); }
1965 const_iterator end() const { return pod_array.end(); }
1967 reverse_iterator rbegin() { return pod_array.rbegin(); }
1969 const_reverse_iterator rbegin() const { return pod_array.rbegin(); }
1971 reverse_iterator rend() { return pod_array.rend(); }
1973 const_reverse_iterator rend() const { return pod_array.rend(); }
1975 const_iterator cbegin() const { return pod_array.cbegin(); }
1977 const_iterator cend() const { return pod_array.cend(); }
1979 const_reverse_iterator const crbegin() { return pod_array.crbegin(); }
1981 const_reverse_iterator const crend() { return pod_array.crend(); }
1983 bool empty() const { return pod_array.empty(); }
1985 virtual size_type size() const { return pod_array.size(); }
1987 size_type max_size() const { return size(); }
1989 reference front() { return pod_array.front(); }
1991 const_reference front() const { return pod_array.front(); }
1993 reference back() { return pod_array.back(); }
1995 const_reference back() const { return pod_array.back(); }
1997 reference operator[](size_type i) { return pod_array[i]; }
1999 const_reference operator[](size_type i) const { return pod_array[i]; }
2001 reference at(size_type i) { return pod_array.at(i); }
2003 const_reference at(size_type i) const { return pod_array.at(i); }
2005 T* data() { return pod_array.data(); }
2007 const T* data() const { return pod_array.data(); }
2008
2016 typename std::vector<T>& GetStorageContainer() { return pod_array; }
2017};
2018
2019#define RRPrimUtilPod(x, type_string) \
2020 template <> \
2021 class RRPrimUtil<x> \
2022 { \
2023 public: \
2024 static DataTypes GetTypeID() { return DataTypes_pod_t; } \
2025 static MessageStringPtr GetElementTypeString() { return MessageStringPtr(type_string); } \
2026 static boost::string_ref GetRRElementTypeString() { return type_string; } \
2027 static RR_INTRUSIVE_PTR<RRPodArray<x> > PrePack(const x& val) { return ScalarToRRPodArray(val); } \
2028 template <typename U> \
2029 static x PreUnpack(const U& val) \
2030 { \
2031 return RRPodArrayToScalar(rr_cast<RRPodArray<x> >(val)); \
2032 } \
2033 typedef RR_INTRUSIVE_PTR<RRPodArray<x> > BoxedType; \
2034 };
2035
2043class RRPodBaseMultiDimArray : public RRValue
2044{
2045 public:
2046 RR_INTRUSIVE_PTR<RRArray<uint32_t> > Dims;
2047 virtual boost::string_ref RRElementTypeString() = 0;
2048};
2049
2069template <typename T>
2070class RRPodMultiDimArray : public RRPodBaseMultiDimArray
2071{
2072 public:
2073 typename RR_INTRUSIVE_PTR<RRPodArray<T> > PodArray;
2074
2075 RRPodMultiDimArray() {}
2076
2077 RRPodMultiDimArray(const RR_INTRUSIVE_PTR<RRArray<uint32_t> >& dims, const RR_INTRUSIVE_PTR<RRPodArray<T> >& a)
2078 {
2079 this->Dims = dims;
2080 this->PodArray = a;
2081 }
2082
2083 RR_OVIRTUAL ~RRPodMultiDimArray() RR_OVERRIDE {}
2084
2085 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRPodMultiDimArray"; }
2086
2087 RR_OVIRTUAL boost::string_ref RRElementTypeString() RR_OVERRIDE { return RRPrimUtil<T>::GetRRElementTypeString(); }
2088
2097 virtual void RetrieveSubArray(const std::vector<uint32_t>& memorypos,
2098 const RR_INTRUSIVE_PTR<RRPodMultiDimArray<T> >& buffer,
2099 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
2100 {
2101
2102 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
2103 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
2104 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
2105 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
2106
2107 uint32_t len = 0;
2108 uint32_t indexa = 0;
2109 uint32_t indexb = 0;
2110
2111 while (iter->Next(indexa, indexb, len))
2112 {
2113 for (size_t i = 0; i < len; i++)
2114 {
2115 buffer->PodArray->at(indexb + i) = PodArray->at(indexa + i);
2116 }
2117 }
2118 }
2119
2128 virtual void AssignSubArray(const std::vector<uint32_t>& memorypos,
2129 const RR_INTRUSIVE_PTR<RRPodMultiDimArray<T> >& buffer,
2130 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
2131 {
2132
2133 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
2134 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
2135 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
2136 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
2137
2138 uint32_t len = 0;
2139 uint32_t indexa = 0;
2140 uint32_t indexb = 0;
2141
2142 while (iter->Next(indexa, indexb, len))
2143 {
2144 for (size_t i = 0; i < len; i++)
2145 {
2146 PodArray->at(indexa + i) = buffer->PodArray->at(indexb + i);
2147 }
2148 }
2149 }
2150};
2151
2159template <typename T>
2160static RR_INTRUSIVE_PTR<RRPodArray<T> > ScalarToRRPodArray(const T& value)
2161{
2162 return new RRPodArray<T>(value); // NOLINT(cppcoreguidelines-owning-memory)
2163}
2164
2172template <typename T>
2173static T RRPodArrayToScalar(const RR_INTRUSIVE_PTR<RRPodArray<T> >& value)
2174{
2175 if (!value)
2176 {
2177 throw NullValueException("Null pointer");
2178 }
2179
2180 if (value->size() == 0)
2181 throw OutOfRangeException("Index out of range");
2182
2183 return value->at(0);
2184}
2185
2199template <typename T>
2200static RR_INTRUSIVE_PTR<RRPodArray<T> > AllocateEmptyRRPodArray(size_t length)
2201{
2202 return new RRPodArray<T>(length); // NOLINT(cppcoreguidelines-owning-memory)
2203}
2204
2218template <typename T>
2219static RR_INTRUSIVE_PTR<RRPodMultiDimArray<T> > AllocateEmptyRRPodMultiDimArray(const std::vector<uint32_t>& dims)
2220{
2221 uint32_t n_elems = boost::accumulate(dims, 1, std::multiplies<uint32_t>());
2223}
2224
2235template <typename T>
2236static RR_INTRUSIVE_PTR<RRPodMultiDimArray<T> > AllocateEmptyRRPodMultiDimArray()
2237{
2238 std::vector<uint32_t> length;
2239 length.push_back(0);
2241}
2242
2243#define RRPrimUtilNamedArray(x, type_string, array_type) \
2244 template <> \
2245 class RRPrimUtil<x> \
2246 { \
2247 public: \
2248 static DataTypes GetTypeID() { return DataTypes_pod_t; } \
2249 static MessageStringPtr GetElementTypeString() { return MessageStringPtr(type_string); } \
2250 static boost::string_ref GetRRElementTypeString() { return type_string; } \
2251 static RR_INTRUSIVE_PTR<RRNamedArray<x> > PrePack(const x& val) { return ScalarToRRNamedArray(val); } \
2252 template <typename U> \
2253 static x PreUnpack(const U& val) \
2254 { \
2255 return RRNamedArrayToScalar(rr_cast<RRNamedArray<x> >(val)); \
2256 } \
2257 typedef RR_INTRUSIVE_PTR<RRNamedArray<x> > BoxedType; \
2258 typedef array_type ElementArrayType; \
2259 static const size_t ElementArrayCount = sizeof(x) / sizeof(array_type); \
2260 static size_t GetElementArrayCount() { return ElementArrayCount; } \
2261 static DataTypes GetElementArrayTypeID() { return RRPrimUtil<array_type>::GetTypeID(); } \
2262 };
2263
2270class ROBOTRACONTEUR_CORE_API RRNamedBaseArray : public RRValue
2271{
2272 public:
2273 virtual DataTypes ElementArrayType() = 0;
2274
2275 virtual size_t ElementSize() = 0;
2276
2277 virtual size_t ElementArrayCount() = 0;
2278
2279 virtual RR_INTRUSIVE_PTR<RRBaseArray> GetNumericBaseArray() = 0;
2280
2281 virtual boost::string_ref RRElementTypeString() = 0;
2282};
2283
2298template <typename T>
2300{
2301 protected:
2302 RR_INTRUSIVE_PTR<RRArray<typename RRPrimUtil<T>::ElementArrayType> > rr_array;
2303
2304 public:
2317 RRNamedArray(const RR_INTRUSIVE_PTR<RRArray<typename RRPrimUtil<T>::ElementArrayType> >& rr_array)
2318 {
2319 if (!rr_array)
2320 throw NullValueException("Numeric array for namedarray must not be null");
2321 this->rr_array = rr_array;
2322 }
2323
2324 virtual DataTypes GetTypeID() { return RRPrimUtil<T>::GetTypeID(); }
2326 virtual size_t size() const { return rr_array->size() / (RRPrimUtil<T>::ElementArrayCount); }
2328 virtual size_t size() { return rr_array->size() / (RRPrimUtil<T>::ElementArrayCount); }
2330 virtual void* void_ptr() { return rr_array->void_ptr(); }
2332 RR_OVIRTUAL size_t ElementSize() RR_OVERRIDE { return sizeof(T); }
2334 RR_OVIRTUAL DataTypes ElementArrayType() RR_OVERRIDE { return RRPrimUtil<T>::GetElementArrayTypeID(); }
2336 RR_OVIRTUAL size_t ElementArrayCount() RR_OVERRIDE { return RRPrimUtil<T>::ElementArrayCount; }
2338 virtual RR_INTRUSIVE_PTR<RRArray<typename RRPrimUtil<T>::ElementArrayType> > GetNumericArray() { return rr_array; }
2340 RR_OVIRTUAL RR_INTRUSIVE_PTR<RRBaseArray> GetNumericBaseArray() RR_OVERRIDE { return rr_array; }
2341
2342 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRNamedArray"; }
2343
2344 RR_OVIRTUAL boost::string_ref RRElementTypeString() RR_OVERRIDE { return RRPrimUtil<T>::GetRRElementTypeString(); }
2345
2346 // C++ container support functions based on boost::array
2347
2348 // type definitions
2350 typedef T value_type;
2352 typedef T* iterator;
2354 typedef const T* const_iterator;
2356 typedef T& reference;
2358 typedef const T& const_reference;
2360 typedef std::size_t size_type;
2362 typedef std::ptrdiff_t difference_type;
2363
2364 // iterator support
2365
2367 iterator begin() { return static_cast<T*>(rr_array->begin()); }
2369 const_iterator begin() const { return static_cast<const T*>(rr_array->begin()); }
2371 const_iterator cbegin() const { return static_cast<const T*>(rr_array->begin()); }
2372
2374 iterator end() { return static_cast<T*>(rr_array->end()); }
2376 const_iterator end() const { return static_cast<T*>(rr_array->end()); }
2378 const_iterator cend() const { return static_cast<T*>(rr_array->end()); }
2379
2381 typedef boost::reverse_iterator<iterator> reverse_iterator;
2383 typedef boost::reverse_iterator<const_iterator> const_reverse_iterator;
2384
2391
2398
2401 {
2402 BOOST_ASSERT_MSG(i < size(), "out of range");
2403 return (static_cast<T*>(rr_array->void_ptr())[i]);
2404 }
2405
2408 {
2409 BOOST_ASSERT_MSG(i < size(), "out of range");
2410 return (static_cast<T*>(rr_array->void_ptr())[i]);
2411 }
2412
2415 {
2416 rangecheck(i);
2417 return (static_cast<T*>(rr_array->void_ptr())[i]);
2418 }
2419
2421 {
2422 rangecheck(i);
2423 (static_cast<T*>(rr_array->void_ptr())[i]);
2424 }
2425
2427 reference front() { return this->at(0); }
2429 const_reference front() const { return this->at(0); }
2430
2432 reference back() { return this->at(size() - 1); }
2434 const_reference back() const { return this->at(size() - 1); }
2435
2437 bool empty() { return rr_array->empty(); }
2439 size_type max_size() { return size(); }
2440
2441 void rangecheck(size_type i)
2442 {
2443 if (i >= size())
2444 {
2445 std::out_of_range e("array<>: index out of range");
2446 boost::throw_exception(e);
2447 }
2448 }
2449};
2450
2458class RRNamedBaseMultiDimArray : public RRValue
2459{
2460 public:
2461 RR_INTRUSIVE_PTR<RRArray<uint32_t> > Dims;
2462 virtual boost::string_ref RRElementTypeString() = 0;
2463};
2464
2484template <typename T>
2485class RRNamedMultiDimArray : public RRNamedBaseMultiDimArray
2486{
2487 public:
2488 typename RR_INTRUSIVE_PTR<RRNamedArray<T> > NamedArray;
2489
2490 RRNamedMultiDimArray() {}
2491
2492 RRNamedMultiDimArray(const RR_INTRUSIVE_PTR<RRArray<uint32_t> >& dims, const RR_INTRUSIVE_PTR<RRNamedArray<T> >& a)
2493 {
2494 this->Dims = dims;
2495 this->NamedArray = a;
2496 }
2497
2498 RR_OVIRTUAL ~RRNamedMultiDimArray() RR_OVERRIDE {}
2499
2500 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRNamedMultiDimArray"; }
2501
2502 RR_OVIRTUAL boost::string_ref RRElementTypeString() RR_OVERRIDE { return RRPrimUtil<T>::GetRRElementTypeString(); }
2503
2512 virtual void RetrieveSubArray(const std::vector<uint32_t>& memorypos,
2513 const RR_INTRUSIVE_PTR<RRNamedMultiDimArray<T> >& buffer,
2514 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
2515 {
2516
2517 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
2518 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
2519 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
2520 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
2521
2522 uint32_t len = 0;
2523 uint32_t indexa = 0;
2524 uint32_t indexb = 0;
2525
2526 while (iter->Next(indexa, indexb, len))
2527 {
2528 for (size_t i = 0; i < len; i++)
2529 {
2530 (*buffer->NamedArray)[(indexb + i)] = (*NamedArray)[(indexa + i)];
2531 }
2532 }
2533 }
2534
2543 virtual void AssignSubArray(const std::vector<uint32_t>& memorypos,
2544 const RR_INTRUSIVE_PTR<RRNamedMultiDimArray<T> >& buffer,
2545 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
2546 {
2547
2548 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
2549 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
2550 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
2551 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
2552
2553 uint32_t len = 0;
2554 uint32_t indexa = 0;
2555 uint32_t indexb = 0;
2556
2557 while (iter->Next(indexa, indexb, len))
2558 {
2559 for (size_t i = 0; i < len; i++)
2560 {
2561 (*NamedArray)[(indexa + i)] = (*buffer->NamedArray)[(indexb + i)];
2562 }
2563 }
2564 }
2565};
2566
2580template <typename T>
2581static RR_INTRUSIVE_PTR<RRNamedArray<T> > AllocateEmptyRRNamedArray(size_t length)
2582{
2583 typedef typename RRPrimUtil<T>::ElementArrayType a_type;
2584 RR_INTRUSIVE_PTR<RRArray<a_type> > a = AllocateEmptyRRArray<a_type>(length * RRPrimUtil<T>::GetElementArrayCount());
2585 return new RRNamedArray<T>(a); // NOLINT(cppcoreguidelines-owning-memory)
2586}
2587
2601template <typename T>
2602static RR_INTRUSIVE_PTR<RRNamedMultiDimArray<T> > AllocateEmptyRRNamedMultiDimArray(const std::vector<uint32_t>& dims)
2603{
2604 uint32_t n_elems = boost::accumulate(dims, 1, std::multiplies<uint32_t>());
2606}
2607
2618template <typename T>
2619static RR_INTRUSIVE_PTR<RRNamedMultiDimArray<T> > AllocateEmptyRRNamedMultiDimArray()
2620{
2621 std::vector<uint32_t> length;
2622 length.push_back(0);
2624}
2625
2636template <typename T>
2637static RR_INTRUSIVE_PTR<RRNamedArray<T> > ScalarToRRNamedArray(const T& value)
2638{
2639 RR_INTRUSIVE_PTR<RRNamedArray<T> > a = AllocateEmptyRRNamedArray<T>(1);
2640 (*a)[0] = value;
2641 return a;
2642}
2643
2654template <typename T>
2655static T RRNamedArrayToScalar(const RR_INTRUSIVE_PTR<RRNamedArray<T> >& value)
2656{
2657 if (!value)
2658 {
2659 throw NullValueException("Null pointer");
2660 }
2661
2662 if (value->size() == 0)
2663 throw OutOfRangeException("Index out of range");
2664
2665 return (*value)[0];
2666}
2667
2668#define RRPrimUtilEnum(x) \
2669 template <> \
2670 class RRPrimUtil<x> \
2671 { \
2672 public: \
2673 static DataTypes GetTypeID() { return DataTypes_enum_t; } \
2674 static MessageStringPtr GetElementTypeString() { return MessageStringPtr(""); } \
2675 static boost::string_ref GetRRElementTypeString() { return ""; } \
2676 static RR_INTRUSIVE_PTR<RRArray<int32_t> > PrePack(const x& val) { return ScalarToRRArray((int32_t)val); } \
2677 template <typename U> \
2678 static x PreUnpack(const U& val) \
2679 { \
2680 return (x)RRArrayToScalar(rr_cast<RRArray<int32_t> >(val)); \
2681 } \
2682 typedef RR_INTRUSIVE_PTR<RRArray<int32_t> > BoxedType; \
2683 };
2684
2685class ROBOTRACONTEUR_CORE_API RobotRaconteurNode;
2686
2696class ROBOTRACONTEUR_CORE_API TimeSpec
2697{
2698 public:
2700 int64_t seconds;
2703
2706
2713 TimeSpec(int64_t seconds, int32_t nanoseconds);
2714
2716 bool operator==(const TimeSpec& t2) const;
2718 bool operator!=(const TimeSpec& t2) const;
2720 TimeSpec operator-(const TimeSpec& t2) const;
2722 TimeSpec operator+(const TimeSpec& t2) const;
2724 bool operator>(const TimeSpec& t2) const;
2726 bool operator>=(const TimeSpec& t2) const;
2728 bool operator<(const TimeSpec& t2) const;
2730 bool operator<=(const TimeSpec& t2) const;
2731
2734};
2735
2742
2743boost::posix_time::ptime ROBOTRACONTEUR_CORE_API TimeSpecToPTime(const TimeSpec& ts);
2750TimeSpec ROBOTRACONTEUR_CORE_API ptimeToTimeSpec(const boost::posix_time::ptime& t);
2751
2752#ifdef ROBOTRACONTEUR_USE_SMALL_VECTOR
2753typedef boost::container::small_vector<boost::asio::const_buffer, 4> const_buffers;
2754typedef boost::container::small_vector<boost::asio::mutable_buffer, 4> mutable_buffers;
2755#else
2756typedef std::vector<boost::asio::const_buffer> const_buffers;
2757typedef std::vector<boost::asio::mutable_buffer> mutable_buffers;
2758#endif
2759
2760template <typename BufferSequence>
2761void buffers_consume(BufferSequence& b, size_t count)
2762{
2763 typename BufferSequence::iterator e = b.begin();
2764 ;
2765 typename BufferSequence::iterator end = b.end();
2766 for (; e != end;)
2767 {
2768 if (count > 0)
2769 {
2770 if (count > boost::asio::buffer_size(*e))
2771 {
2772 count -= boost::asio::buffer_size(*e);
2773 e = b.erase(e);
2774 }
2775 else
2776 {
2777 *e = *e + count;
2778 count = 0;
2779 ++e;
2780 }
2781 }
2782 else
2783 {
2784 break;
2785 }
2786 }
2787}
2788
2789template <typename BufferSequence>
2790BufferSequence buffers_consume_copy(BufferSequence& b, size_t count)
2791{
2792 BufferSequence o;
2793 typename BufferSequence::iterator e = b.begin();
2794 ;
2795 typename BufferSequence::iterator end = b.end();
2796 for (; e != end; e++)
2797 {
2798 if (count > 0)
2799 {
2800 if (count > boost::asio::buffer_size(*e))
2801 {
2802 count -= boost::asio::buffer_size(*e);
2803 }
2804 else
2805 {
2806 o.push_back(*e + count);
2807 count = 0;
2808 }
2809 }
2810 else
2811 {
2812 o.push_back(*e);
2813 }
2814 }
2815
2816 return o;
2817}
2818
2819template <typename BufferSequence>
2820BufferSequence buffers_consume_copy(const BufferSequence& b, size_t count)
2821{
2822 BufferSequence o;
2823 typename BufferSequence::const_iterator e = b.begin();
2824 ;
2825 typename BufferSequence::const_iterator end = b.end();
2826 for (; e != end; e++)
2827 {
2828 if (count > 0)
2829 {
2830 if (count > boost::asio::buffer_size(*e))
2831 {
2832 count -= boost::asio::buffer_size(*e);
2833 }
2834 else
2835 {
2836 o.push_back(*e + count);
2837 count = 0;
2838 }
2839 }
2840 else
2841 {
2842 o.push_back(*e);
2843 }
2844 }
2845
2846 return o;
2847}
2848
2849template <typename BufferSequence>
2850BufferSequence buffers_truncate(BufferSequence& b, size_t count)
2851{
2852 BufferSequence o;
2853 typename BufferSequence::iterator e = b.begin();
2854 ;
2855 typename BufferSequence::iterator end = b.end();
2856 size_t p = 0;
2857 for (; e != end; e++)
2858 {
2859 if (p + boost::asio::buffer_size(*e) <= count)
2860 {
2861 o.push_back(*e);
2862 p += boost::asio::buffer_size(*e);
2863 }
2864 else
2865 {
2866 o.push_back(boost::asio::buffer(*e, count - p));
2867 break;
2868 }
2869 }
2870
2871 return o;
2872}
2873
2874template <typename BufferSequence>
2875BufferSequence buffers_truncate(const BufferSequence& b, size_t count)
2876{
2877 BufferSequence o;
2878 typename BufferSequence::const_iterator e = b.begin();
2879 ;
2880 typename BufferSequence::const_iterator end = b.end();
2881 size_t p = 0;
2882 for (; e != end; e++)
2883 {
2884 if (p + boost::asio::buffer_size(*e) <= count)
2885 {
2886 o.push_back(*e);
2887 p += boost::asio::buffer_size(*e);
2888 }
2889 else
2890 {
2891 o.push_back(boost::asio::buffer(*e, count - p));
2892 break;
2893 }
2894 }
2895
2896 return o;
2897}
2898
2899/***
2900 * @brief Service path segment containing a name and an optional index
2901 */
2902struct ROBOTRACONTEUR_CORE_API ServicePathSegment
2903{
2904
2905 ServicePathSegment();
2906
2907 ServicePathSegment(const std::string& name,
2908 const boost::optional<std::string>& index = boost::optional<std::string>());
2909
2911 std::string name;
2913 boost::optional<std::string> index;
2914};
2915
2916ROBOTRACONTEUR_CORE_API bool operator==(const ServicePathSegment& lhs, const ServicePathSegment& rhs);
2917
2918ROBOTRACONTEUR_CORE_API bool operator!=(const ServicePathSegment& lhs, const ServicePathSegment& rhs);
2919
2926ROBOTRACONTEUR_CORE_API std::string EncodeServicePathIndex(const std::string& index);
2927
2934ROBOTRACONTEUR_CORE_API std::string DecodeServicePathIndex(const std::string& index);
2935
2942ROBOTRACONTEUR_CORE_API std::vector<ServicePathSegment> ParseServicePath(const std::string& path);
2943
2950ROBOTRACONTEUR_CORE_API std::string BuildServicePath(const std::vector<ServicePathSegment>& segments);
2951
2958ROBOTRACONTEUR_CORE_API bool IsStringName(boost::string_ref str);
2965ROBOTRACONTEUR_CORE_API bool IsStringScopedName(boost::string_ref str);
2972ROBOTRACONTEUR_CORE_API bool IsStringUUID(boost::string_ref str);
2979ROBOTRACONTEUR_CORE_API bool IsStringIdentifier(boost::string_ref str);
2980
2981namespace detail
2982{
2983ROBOTRACONTEUR_CORE_API std::string encode_index(boost::string_ref index);
2984
2985ROBOTRACONTEUR_CORE_API std::string decode_index(boost::string_ref index);
2986
2987template <typename T, typename U>
2988bool try_convert_string_to_number(const U& arg, T& result)
2989{
2990 if (boost::conversion::try_lexical_convert(arg, result))
2991 {
2992 return true;
2993 }
2994
2995 if (!boost::is_integral<T>::value)
2996 {
2997 return false;
2998 }
2999
3000 boost::regex hex_regex("^[+\\-]?0x[\\da-fA-F]+$");
3001 if (!boost::regex_match(arg.begin(), arg.end(), hex_regex))
3002 {
3003 return false;
3004 }
3005
3006 std::stringstream ss;
3007 ss << std::hex << arg;
3008 T v;
3009 ss >> v;
3010 if (ss.fail() || !ss.eof())
3011 {
3012 return false;
3013 }
3014
3015 result = v;
3016
3017 return true;
3018}
3019
3020} // namespace detail
3021
3022#ifndef ROBOTRACONTEUR_NO_CXX11_TEMPLATE_ALIASES
3024using RRObjectPtr = RR_SHARED_PTR<RRObject>;
3026using RRObjectConstPtr = RR_SHARED_PTR<const RRObject>;
3028using RRValuePtr = RR_INTRUSIVE_PTR<RRValue>;
3030using RRValueConstPtr = RR_INTRUSIVE_PTR<const RRValue>;
3032using MessageElementDataPtr = RR_INTRUSIVE_PTR<MessageElementData>;
3034using MessageElementDataConstPtr = RR_INTRUSIVE_PTR<const MessageElementData>;
3036using RRBaseArrayPtr = RR_INTRUSIVE_PTR<RRBaseArray>;
3038using RRBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRBaseArray>;
3040template <typename T>
3041using RRArrayPtr = RR_INTRUSIVE_PTR<RRArray<T> >;
3043template <typename T>
3044using RRArrayConstPtr = RR_INTRUSIVE_PTR<const RRArray<T> >;
3046template <typename K, typename T>
3047using RRMapPtr = RR_INTRUSIVE_PTR<RRMap<K, T> >;
3049template <typename K, typename T>
3050using RRMapConstPtr = RR_INTRUSIVE_PTR<const RRMap<K, T> >;
3052template <typename T>
3053using RRListPtr = RR_INTRUSIVE_PTR<RRList<T> >;
3055template <typename T>
3056using RRListConstPtr = RR_INTRUSIVE_PTR<const RRList<T> >;
3058using RRStructurePtr = RR_INTRUSIVE_PTR<RRStructure>;
3060using RRStructureConstPtr = RR_INTRUSIVE_PTR<const RRStructure>;
3062using RRMultiDimBaseArrayPtr = RR_INTRUSIVE_PTR<RRMultiDimBaseArray>;
3064using RRMultiDimBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRMultiDimBaseArray>;
3066template <typename T>
3067using RRMultiDimArrayPtr = RR_INTRUSIVE_PTR<RRMultiDimArray<T> >;
3069template <typename T>
3070using RRMultiDimArrayConstPtr = RR_INTRUSIVE_PTR<const RRMultiDimArray<T> >;
3072using RRPodBaseArrayPtr = RR_INTRUSIVE_PTR<RRPodBaseArray>;
3074using RRPodBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRPodBaseArray>;
3076template <typename T>
3077using RRPodArrayPtr = RR_INTRUSIVE_PTR<RRPodArray<T> >;
3079template <typename T>
3080using RRPodArrayConstPtr = RR_INTRUSIVE_PTR<const RRPodArray<T> >;
3082using RRPodBaseMultiDimArrayPtr = RR_INTRUSIVE_PTR<RRPodBaseMultiDimArray>;
3084using RRPodBaseMultiDimBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRPodBaseMultiDimArray>;
3086template <typename T>
3087using RRPodMultiDimArrayPtr = RR_INTRUSIVE_PTR<RRPodMultiDimArray<T> >;
3089template <typename T>
3090using RRPodMultiDimArrayConstPtr = RR_INTRUSIVE_PTR<const RRPodMultiDimArray<T> >;
3092using RRNamedBaseArrayPtr = RR_INTRUSIVE_PTR<RRNamedBaseArray>;
3094using RRNamedBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRNamedBaseArray>;
3096template <typename T>
3097using RRNamedArrayPtr = RR_INTRUSIVE_PTR<RRNamedArray<T> >;
3099template <typename T>
3100using RRNamedArrayConstPtr = RR_INTRUSIVE_PTR<const RRNamedArray<T> >;
3102using RRNamedBaseMultiDimArrayPtr = RR_INTRUSIVE_PTR<RRNamedBaseMultiDimArray>;
3104using RRNamedBaseMultiDimBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRNamedBaseMultiDimArray>;
3106template <typename T>
3107using RRNamedMultiDimArrayPtr = RR_INTRUSIVE_PTR<RRNamedMultiDimArray<T> >;
3109template <typename T>
3110using RRNamedMultiDimArrayConstPtr = RR_INTRUSIVE_PTR<const RRNamedMultiDimArray<T> >;
3111#endif
3112} // namespace RobotRaconteur
boost::intrusive_ptr< RRMap< K, T > > AllocateEmptyRRMap()
Allocate an empty RRMap.
Definition DataTypes.h:1858
static T RRNamedArrayToScalar(const boost::intrusive_ptr< RRNamedArray< T > > &value)
Convert a namedarray array with one element into a namedarray.
Definition DataTypes.h:2655
boost::intrusive_ptr< RRArray< char > > stringToRRArray(boost::string_ref str)
Convert a string to an array of characters.
static boost::intrusive_ptr< RRPodArray< T > > AllocateEmptyRRPodArray(size_t length)
Allocate a pod array with the specified type and length and initialize to zero.
Definition DataTypes.h:2200
static boost::intrusive_ptr< RRArray< Y > > VectorToRRArray(const std::vector< U > &in)
Convert a std::vector to an RRArray<Y>.
Definition DataTypes.h:1266
boost::shared_ptr< const RRObject > RRObjectConstPtr
Convenience alias for RRObject const shared_ptr.
Definition DataTypes.h:3026
boost::intrusive_ptr< RRList< T > > RRListPtr
Convenience alias for RRList intrusive_ptr.
Definition DataTypes.h:3053
boost::intrusive_ptr< RRPodBaseMultiDimArray > RRPodBaseMultiDimArrayPtr
Convenience alias for RRPodBaseMultiDimArray intrusive_ptr.
Definition DataTypes.h:3082
boost::intrusive_ptr< T > & rr_null_check(boost::intrusive_ptr< T > &ptr)
Checks if a value RR_INTRUSIVE_PTR is null.
Definition DataTypes.h:1452
static boost::intrusive_ptr< RRArray< Y > > ArrayToRRArray(boost::array< U, N > in)
Convert a boost::array to an RRArray.
Definition DataTypes.h:1334
static T RRArrayToScalar(const boost::intrusive_ptr< RRArray< T > > &value)
Convert an array with one element into a scalar.
Definition DataTypes.h:1217
boost::intrusive_ptr< RRMap< K, T > > RRMapPtr
Convenience alias for RRMap intrusive_ptr.
Definition DataTypes.h:3047
static boost::intrusive_ptr< RRArray< T > > AttachRRArrayCopy(const T *data, const size_t length)
Allocates an array object and copies existing numeric.
Definition DataTypes.h:1130
boost::intrusive_ptr< const RRList< T > > RRListConstPtr
Convenience alias for RRList const intrusive_ptr.
Definition DataTypes.h:3056
boost::intrusive_ptr< RRPodBaseArray > RRPodBaseArrayPtr
Convenience alias for RRPodBaseArray intrusive_ptr.
Definition DataTypes.h:3072
static boost::shared_ptr< T > rr_cast(const boost::shared_ptr< U > &objin)
Dynamic cast a RR_SHARED_PTR type. Throws DataTypeMismatchException if cast is invalid instead of ret...
Definition DataTypes.h:199
boost::intrusive_ptr< RRPodArray< T > > RRPodArrayPtr
Convenience alias for RRPodArray intrusive_ptr.
Definition DataTypes.h:3077
size_t RRArrayElementSize(DataTypes type)
Get the number of bytes to store a numeric primitive scalar.
static boost::intrusive_ptr< RRPodMultiDimArray< T > > AllocateEmptyRRPodMultiDimArray(const std::vector< uint32_t > &dims)
Allocate an empty multidimensional pod array with the specified dimensions.
Definition DataTypes.h:2219
static boost::intrusive_ptr< RRArray< T > > ScalarToRRArray(T value)
Convert a scalar number into an array with one element.
Definition DataTypes.h:1204
boost::intrusive_ptr< const MessageElementData > MessageElementDataConstPtr
Convenience alias for MessageElementData const intrusive_ptr.
Definition DataTypes.h:3034
std::vector< ServicePathSegment > ParseServicePath(const std::string &path)
Parse a Robot Raconteur service path into segments.
boost::intrusive_ptr< const RRNamedBaseMultiDimArray > RRNamedBaseMultiDimBaseArrayConstPtr
Convenience alias for RRNamedBaseMultiDimArray const intrusive_ptr.
Definition DataTypes.h:3104
boost::intrusive_ptr< MessageElementData > MessageElementDataPtr
Convenience alias for MessageElementData intrusive_ptr.
Definition DataTypes.h:3032
bool IsStringIdentifier(boost::string_ref str)
Test if a string is a Robot Raconteur identifier.
boost::intrusive_ptr< RRValue > RRValuePtr
Convenience alias for RRValue intrusive_ptr.
Definition DataTypes.h:3028
boost::posix_time::ptime TimeSpecToPTime(const TimeSpec &ts)
Convert a TimeSpec into a boost::posix_time::ptime.
boost::intrusive_ptr< const RRPodMultiDimArray< T > > RRPodMultiDimArrayConstPtr
Convenience alias for RRPodMultiDimArray const intrusive_ptr.
Definition DataTypes.h:3090
static boost::intrusive_ptr< RRPodArray< T > > ScalarToRRPodArray(const T &value)
Convert a scalar pod into a pod array with one element.
Definition DataTypes.h:2160
boost::intrusive_ptr< RRList< T > > AllocateRRList(const U &c)
Allocate RRList with a value.
Definition DataTypes.h:1845
std::string RRArrayToString(const boost::intrusive_ptr< RRArray< char > > &arr)
Convert an array of characters into std::string.
TimeSpec ptimeToTimeSpec(const boost::posix_time::ptime &t)
Convert a boost::posix_time::ptime into a TimeSpec.
static T RRPodArrayToScalar(const boost::intrusive_ptr< RRPodArray< T > > &value)
Convert a pod array with one element into a scalar pod.
Definition DataTypes.h:2173
boost::intrusive_ptr< RRList< RRArray< char > > > stringVectorToRRList(const std::vector< std::string > &string_vector)
Convert a string vector to a RRList.
boost::intrusive_ptr< RRPodMultiDimArray< T > > RRPodMultiDimArrayPtr
Convenience alias for RRPodMultiDimArray intrusive_ptr.
Definition DataTypes.h:3087
boost::intrusive_ptr< const RRPodArray< T > > RRPodArrayConstPtr
Convenience alias for RRPodArray const intrusive_ptr.
Definition DataTypes.h:3080
boost::intrusive_ptr< const RRPodBaseMultiDimArray > RRPodBaseMultiDimBaseArrayConstPtr
Convenience alias for RRPodBaseMultiDimArray const intrusive_ptr.
Definition DataTypes.h:3084
boost::intrusive_ptr< const RRNamedBaseArray > RRNamedBaseArrayConstPtr
Convenience alias for RRNamedBaseArray const intrusive_ptr.
Definition DataTypes.h:3094
static boost::intrusive_ptr< RRArray< T > > AllocateEmptyRRArray(size_t length)
Allocate a numeric primitive or character array with the specified type and length and initialize to ...
Definition DataTypes.h:1171
boost::shared_ptr< RRObject > RRObjectPtr
Convenience alias for RRObject shared_ptr.
Definition DataTypes.h:3024
boost::intrusive_ptr< RRNamedArray< T > > RRNamedArrayPtr
Convenience alias for RRNamedArray intrusive_ptr.
Definition DataTypes.h:3097
boost::intrusive_ptr< const RRMultiDimArray< T > > RRMultiDimArrayConstPtr
Convenience alias for RRMultiDimArray const intrusive_ptr.
Definition DataTypes.h:3070
static boost::intrusive_ptr< RRNamedArray< T > > AllocateEmptyRRNamedArray(size_t length)
Allocate a namedarray array with the specified type and length and initialize to zero.
Definition DataTypes.h:2581
std::vector< std::string > RRListToStringVector(const boost::intrusive_ptr< RRList< RRArray< char > > > &list)
Convert a RRList containing strings to a string vector.
boost::intrusive_ptr< RRMultiDimBaseArray > RRMultiDimBaseArrayPtr
Convenience alias for RRMultiDimBaseArray intrusive_ptr.
Definition DataTypes.h:3062
static boost::intrusive_ptr< RRArray< T > > AllocateRRArray(size_t length)
Allocate a numeric primitive or character array with the specified type and length.
Definition DataTypes.h:1088
boost::intrusive_ptr< RRNamedBaseMultiDimArray > RRNamedBaseMultiDimArrayPtr
Convenience alias for RRNamedBaseMultiDimArray intrusive_ptr.
Definition DataTypes.h:3102
boost::intrusive_ptr< const RRArray< T > > RRArrayConstPtr
Convenience alias for RRArray const intrusive_ptr.
Definition DataTypes.h:3044
boost::intrusive_ptr< RRNamedMultiDimArray< T > > RRNamedMultiDimArrayPtr
Convenience alias for RRNamedMultiDimArray intrusive_ptr.
Definition DataTypes.h:3107
boost::intrusive_ptr< RRBaseArray > AllocateRRArrayByType(DataTypes type, size_t length)
Allocate an RRBaseArray by type code.
boost::intrusive_ptr< const RRMultiDimBaseArray > RRMultiDimBaseArrayConstPtr
Convenience alias for RRMultiDimBaseArray const intrusive_ptr.
Definition DataTypes.h:3064
boost::intrusive_ptr< RRArray< T > > RRArrayPtr
Convenience alias for RRArray intrusive_ptr.
Definition DataTypes.h:3041
boost::intrusive_ptr< RRStructure > RRStructurePtr
Convenience alias for RRStructure intrusive_ptr.
Definition DataTypes.h:3058
bool IsStringUUID(boost::string_ref str)
Test if a string is a UUID.
static boost::intrusive_ptr< RRMultiDimArray< T > > AllocateRRMultiDimArray(const boost::intrusive_ptr< RRArray< uint32_t > > &dims, const boost::intrusive_ptr< RRArray< T > > &array_)
Allocate a multidimensional using existing dimensions and data array.
Definition DataTypes.h:1818
static boost::intrusive_ptr< RRNamedArray< T > > ScalarToRRNamedArray(const T &value)
Convert a scalar namedarray into a namedarray array with one element.
Definition DataTypes.h:2637
bool IsStringName(boost::string_ref str)
Test if a string is a valid Robot Raconteur name.
boost::intrusive_ptr< const RRBaseArray > RRBaseArrayConstPtr
Convenience alias for RRBaseArray const intrusive_ptr.
Definition DataTypes.h:3038
boost::intrusive_ptr< RRBaseArray > RRBaseArrayPtr
Convenience alias for RRBaseArray intrusive_ptr.
Definition DataTypes.h:3036
static boost::intrusive_ptr< RRArray< T > > AttachRRArray(T *data, size_t length, bool owned)
Allocates an array object and attaches to existing numeric primitive or character array pointer.
Definition DataTypes.h:1112
boost::intrusive_ptr< RRMap< K, T > > AllocateRRMap(const U &c)
Allocate RRMap with value.
Definition DataTypes.h:1873
boost::intrusive_ptr< RRMultiDimArray< T > > RRMultiDimArrayPtr
Convenience alias for RRMultiDimArray intrusive_ptr.
Definition DataTypes.h:3067
boost::intrusive_ptr< const RRPodBaseArray > RRPodBaseArrayConstPtr
Convenience alias for RRPodBaseArray const intrusive_ptr.
Definition DataTypes.h:3074
boost::intrusive_ptr< const RRStructure > RRStructureConstPtr
Convenience alias for RRStructure const intrusive_ptr.
Definition DataTypes.h:3060
boost::intrusive_ptr< const RRValue > RRValueConstPtr
Convenience alias for RRValue const intrusive_ptr.
Definition DataTypes.h:3030
boost::intrusive_ptr< const RRMap< K, T > > RRMapConstPtr
Convenience alias for RRMap const intrusive_ptr.
Definition DataTypes.h:3050
boost::intrusive_ptr< const RRNamedMultiDimArray< T > > RRNamedMultiDimArrayConstPtr
Convenience alias for RRNamedMultiDimArray const intrusive_ptr.
Definition DataTypes.h:3110
std::string BuildServicePath(const std::vector< ServicePathSegment > &segments)
Build a Robot Raconteur service path from segments.
bool IsStringScopedName(boost::string_ref str)
Test if a string is a valid Robot Raconteur scoped name.
boost::intrusive_ptr< const RRNamedArray< T > > RRNamedArrayConstPtr
Convenience alias for RRNamedArray const intrusive_ptr.
Definition DataTypes.h:3100
boost::intrusive_ptr< RRList< T > > AllocateEmptyRRList()
Allocate an empty RRList.
Definition DataTypes.h:1831
static boost::container::static_vector< Y, N > RRArrayToStaticVector(const boost::intrusive_ptr< RRArray< U > > &in)
Convert an RRArray to a boost::static_vector.
Definition DataTypes.h:1357
static boost::intrusive_ptr< RRNamedMultiDimArray< T > > AllocateEmptyRRNamedMultiDimArray(const std::vector< uint32_t > &dims)
Allocate an empty multidimensional namedarray array with the specified dimensions.
Definition DataTypes.h:2602
std::string EncodeServicePathIndex(const std::string &index)
Encode a service path index for use in a Robot Raconteur service path.
static std::vector< Y > RRArrayToVector(const boost::intrusive_ptr< RRArray< U > > &in)
Convert an RRArray<U> to a std::vector<Y>.
Definition DataTypes.h:1244
static boost::array< Y, N > RRArrayToArray(const boost::intrusive_ptr< RRArray< U > > &in)
Convert an RRArray to a boost::array.
Definition DataTypes.h:1287
boost::intrusive_ptr< RRNamedBaseArray > RRNamedBaseArrayPtr
Convenience alias for RRNamedBaseArray intrusive_ptr.
Definition DataTypes.h:3092
static boost::intrusive_ptr< RRArray< Y > > StaticVectorToRRArray(boost::container::static_vector< U, N > in)
Convert a boost::container::static_vector to an RRArray.
Definition DataTypes.h:1410
std::string DecodeServicePathIndex(const std::string &index)
Decode a service path index from a Robot Raconteur service path.
static boost::intrusive_ptr< RRMultiDimArray< T > > AllocateEmptyRRMultiDimArray(const std::vector< uint32_t > &dims)
Allocate an empty multidimensional array with the specified dimensions.
Definition DataTypes.h:1787
DataTypes
Type codes for types supported by Robot Raconteur.
Definition RobotRaconteurConstants.h:41
@ DataTypes_single_t
IEEE-754 32-bit floating point number.
Definition RobotRaconteurConstants.h:47
@ DataTypes_uint8_t
8-bit unsigned integer
Definition RobotRaconteurConstants.h:51
@ DataTypes_int16_t
16-bit signed integer
Definition RobotRaconteurConstants.h:53
@ DataTypes_uint32_t
32-bit unsigned integer
Definition RobotRaconteurConstants.h:59
@ DataTypes_uint16_t
16-bit unsigned integer
Definition RobotRaconteurConstants.h:55
@ DataTypes_int8_t
8-bit signed integer
Definition RobotRaconteurConstants.h:49
@ DataTypes_uint64_t
64-bit unsigned integer
Definition RobotRaconteurConstants.h:63
@ DataTypes_double_t
IEEE-754 64-bit floating point number.
Definition RobotRaconteurConstants.h:45
@ DataTypes_int64_t
64-bit signed integer
Definition RobotRaconteurConstants.h:61
@ DataTypes_string_t
UTF-8 string.
Definition RobotRaconteurConstants.h:65
@ DataTypes_int32_t
32-bit signed integer
Definition RobotRaconteurConstants.h:57
@ DataTypes_void_t
void or null type
Definition RobotRaconteurConstants.h:43
@ DataTypes_bool_t
8-bit boolean
Definition RobotRaconteurConstants.h:71
@ DataTypes_cdouble_t
128-bit complex double (real,imag)
Definition RobotRaconteurConstants.h:67
@ DataTypes_csingle_t
64-bit complex float (real,imag)
Definition RobotRaconteurConstants.h:69
DataTypeMismatchException(const std::string &message, std::string sub_name="", const boost::intrusive_ptr< RRValue > &param_=boost::intrusive_ptr< RRValue >())
Construct a DataTypeMismatchException.
Base class for types that can be stored in MessageElement.
Definition DataTypes.h:374
Exception thrown for an unexpected null value.
Definition Error.h:669
Exception thrown when an attempt to access an array or container index is out of range.
Definition Error.h:875
Numeric primitive or character array value type.
Definition DataTypes.h:578
std::ptrdiff_t difference_type
Definition DataTypes.h:614
RRArray< T > & operator=(const RRArray< T2 > &rhs)
assignment with type conversion
Definition DataTypes.h:710
T value_type
Definition DataTypes.h:602
reference operator[](size_type i)
access specified element
Definition DataTypes.h:652
reference back()
access the last element
Definition DataTypes.h:685
RR_OVIRTUAL size_t size() RR_OVERRIDE
Get the number of elements in the array.
Definition DataTypes.h:594
const_reverse_iterator rend() const
returns a reverse iterator to the end
Definition DataTypes.h:647
const_iterator cend() const
returns a const iterator to the end
Definition DataTypes.h:630
bool empty()
checks whether the container is empty
Definition DataTypes.h:691
const T & const_reference
Definition DataTypes.h:610
std::size_t size_type
Definition DataTypes.h:612
void fill(const T &value)
Fill array with value.
Definition DataTypes.h:729
const_reference at(size_type i) const
access specified element with bounds checking
Definition DataTypes.h:672
iterator begin()
returns an iterator to the beginning
Definition DataTypes.h:619
const_reverse_iterator crend() const
returns a reverse iterator to the end
Definition DataTypes.h:649
reverse_iterator rend()
returns a reverse iterator to the end
Definition DataTypes.h:645
iterator end()
returns an iterator to the end
Definition DataTypes.h:626
const_reference operator[](size_type i) const
access specified element
Definition DataTypes.h:659
size_type max_size()
returns the maximum possible number of elements
Definition DataTypes.h:693
reverse_iterator rbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:638
boost::reverse_iterator< const_iterator > const_reverse_iterator
Definition DataTypes.h:635
boost::reverse_iterator< iterator > reverse_iterator
Definition DataTypes.h:633
const_iterator end() const
returns an iterator to the end
Definition DataTypes.h:628
const_reverse_iterator rbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:640
T * data()
direct access to the underlying array
Definition DataTypes.h:698
const_reference back() const
access the last element
Definition DataTypes.h:688
reference front()
access the first element
Definition DataTypes.h:679
const T * const_iterator
Definition DataTypes.h:606
RR_OVIRTUAL void * void_ptr() RR_OVERRIDE
Get a void pointer to the contained array.
Definition DataTypes.h:590
T * iterator
Definition DataTypes.h:604
T & reference
Definition DataTypes.h:608
const_iterator cbegin() const
returns a const iterator to the beginning
Definition DataTypes.h:623
const_reverse_iterator crbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:642
const_reference front() const
access the first element
Definition DataTypes.h:682
const_iterator begin() const
returns an iterator to the beginning
Definition DataTypes.h:621
void assign(const T &value)
Assign one value to all elements.
Definition DataTypes.h:723
reference at(size_type i)
access specified element with bounds checking
Definition DataTypes.h:666
const T * data() const
direct access to the underlying array
Definition DataTypes.h:696
RR_OVIRTUAL size_t ElementSize() RR_OVERRIDE
Get the number of bytes per element of the array.
Definition DataTypes.h:596
Base class for numeric and character array value types.
Definition DataTypes.h:525
virtual size_t size()=0
Get the number of elements in the array.
virtual size_t ElementSize()=0
Get the number of bytes per element of the array.
virtual void * void_ptr()=0
Get a void pointer to the contained array.
List container value type.
Definition DataTypes.h:951
const_iterator begin() const
returns an iterator to the beginning
Definition DataTypes.h:992
std::list< boost::intrusive_ptr< T > >::const_iterator const_iterator
Definition DataTypes.h:983
std::list< boost::intrusive_ptr< T > > & GetStorageContainer()
Get the underlying storage container.
Definition DataTypes.h:1055
void pop_back()
removes the last element
Definition DataTypes.h:1036
std::list< boost::intrusive_ptr< T > >::reference reference
Definition DataTypes.h:973
std::list< boost::intrusive_ptr< T > >::iterator iterator
Definition DataTypes.h:981
std::list< boost::intrusive_ptr< T > >::reverse_iterator reverse_iterator
Definition DataTypes.h:985
std::list< boost::intrusive_ptr< T > >::const_pointer const_pointer
Definition DataTypes.h:971
iterator erase(const_iterator first, const_iterator last)
erases element
Definition DataTypes.h:1042
std::list< boost::intrusive_ptr< T > >::const_reverse_iterator const_reverse_iterator
Definition DataTypes.h:987
const_reverse_iterator const crend()
returns a reverse iterator to the end
Definition DataTypes.h:1014
reference front()
access the first element
Definition DataTypes.h:1022
std::list< boost::intrusive_ptr< T > >::size_type size_type
Definition DataTypes.h:977
void clear()
clears the contents
Definition DataTypes.h:1044
size_type max_size() const
returns the maximum possible number of elements
Definition DataTypes.h:1020
const_reverse_iterator crend() const
returns a reverse iterator to the end
Definition DataTypes.h:1004
iterator insert(const_iterator p, const boost::intrusive_ptr< T > &x)
inserts element
Definition DataTypes.h:1038
std::list< boost::intrusive_ptr< T > >::pointer pointer
Definition DataTypes.h:969
const_reference back() const
access the last element
Definition DataTypes.h:1028
std::list< boost::intrusive_ptr< T > >::difference_type difference_type
Definition DataTypes.h:979
const_reference front() const
access the first element
Definition DataTypes.h:1024
void push_front(const boost::intrusive_ptr< T > &x)
inserts an element at the beginning
Definition DataTypes.h:1030
reference back()
access the last element
Definition DataTypes.h:1026
void remove(const boost::intrusive_ptr< T > &value)
removes elements equal to value
Definition DataTypes.h:1046
reverse_iterator rbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:998
void push_back(const boost::intrusive_ptr< T > &x)
adds an element to the end
Definition DataTypes.h:1032
const_iterator cend() const
returns an iterator to the end
Definition DataTypes.h:1010
const_reverse_iterator const crbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:1012
iterator begin()
returns an iterator to the beginning
Definition DataTypes.h:990
const_reverse_iterator rend() const
returns a reverse iterator to the end
Definition DataTypes.h:1006
bool empty() const
checks whether the container is empty
Definition DataTypes.h:1016
boost::intrusive_ptr< T > value_type
Definition DataTypes.h:967
void pop_front()
removes the first element
Definition DataTypes.h:1034
virtual size_type size() const
returns the number of elements
Definition DataTypes.h:1018
const_iterator end() const
returns an iterator to the end
Definition DataTypes.h:996
const_reverse_iterator rbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:1000
std::list< boost::intrusive_ptr< T > >::const_reference const_reference
Definition DataTypes.h:975
const_iterator cbegin() const
returns an iterator to the beginning
Definition DataTypes.h:1008
reverse_iterator rend()
returns a reverse iterator to the end
Definition DataTypes.h:1002
iterator erase(const_iterator p)
erases element
Definition DataTypes.h:1040
iterator end()
returns an iterator to the end
Definition DataTypes.h:994
Map container value type.
Definition DataTypes.h:825
void erase(iterator p)
erases element
Definition DataTypes.h:916
std::pair< iterator, bool > insert(const value_type &x)
inserts elements
Definition DataTypes.h:902
iterator end()
returns an iterator to the end
Definition DataTypes.h:872
std::map< K, boost::intrusive_ptr< T > >::value_type value_type
Definition DataTypes.h:845
std::map< K, boost::intrusive_ptr< T > >::key_type key_type
Definition DataTypes.h:841
const_reverse_iterator rbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:882
const_iterator begin() const
returns an iterator to the beginning
Definition DataTypes.h:870
const_reverse_iterator crbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:880
mapped_type & operator[](const key_type &k)
access or insert the specified element
Definition DataTypes.h:896
std::map< K, boost::intrusive_ptr< T > > & GetStorageContainer()
Get the underlying storage container.
Definition DataTypes.h:937
std::map< K, boost::intrusive_ptr< T > >::const_iterator const_iterator
Definition DataTypes.h:859
const_reverse_iterator crend() const
returns a reverse iterator to the end
Definition DataTypes.h:886
size_type size() const
returns the number of elements
Definition DataTypes.h:892
const_iterator find(const key_type &x) const
finds element with the specified key
Definition DataTypes.h:926
bool empty() const
checks whether the container is empty
Definition DataTypes.h:890
iterator find(const key_type &x)
finds element with the specified key
Definition DataTypes.h:924
void erase(iterator first, iterator last)
erases element
Definition DataTypes.h:920
std::map< K, boost::intrusive_ptr< T > >::const_reverse_iterator const_reverse_iterator
Definition DataTypes.h:863
const mapped_type & at(const key_type &k) const
access specified element with bounds checking
Definition DataTypes.h:900
std::map< K, boost::intrusive_ptr< T > >::pointer pointer
Definition DataTypes.h:847
size_type count(const key_type &x) const
returns the number of elemnts matching the specified key
Definition DataTypes.h:928
reverse_iterator rend()
returns a reverse iterator to the end
Definition DataTypes.h:884
std::map< K, boost::intrusive_ptr< T > >::iterator iterator
Definition DataTypes.h:857
mapped_type & at(const key_type &k)
access specified element with bounds checking
Definition DataTypes.h:898
const_iterator end() const
returns an iterator to the end
Definition DataTypes.h:876
void clear()
clears the contents
Definition DataTypes.h:922
std::map< K, boost::intrusive_ptr< T > >::reverse_iterator reverse_iterator
Definition DataTypes.h:861
std::map< K, boost::intrusive_ptr< T > >::mapped_type mapped_type
Definition DataTypes.h:843
std::map< K, boost::intrusive_ptr< T > >::reference reference
Definition DataTypes.h:851
const_iterator cend() const
returns an iterator to the end
Definition DataTypes.h:874
size_type max_size() const
returns the maximum possible number of elements
Definition DataTypes.h:894
std::map< K, boost::intrusive_ptr< T > >::const_reference const_reference
Definition DataTypes.h:853
iterator begin()
returns an iterator to the beginning
Definition DataTypes.h:866
iterator insert(const_iterator p, const value_type &x)
inserts elements
Definition DataTypes.h:904
const_reverse_iterator rend() const
returns a reverse iterator to the end
Definition DataTypes.h:888
const_iterator cbegin() const
returns an iterator to the beginning
Definition DataTypes.h:868
std::map< K, boost::intrusive_ptr< T > >::const_pointer const_pointer
Definition DataTypes.h:849
std::map< K, boost::intrusive_ptr< T > >::size_type size_type
Definition DataTypes.h:855
size_type erase(const key_type &x)
erases element
Definition DataTypes.h:918
void insert(InputIterator first, InputIterator last)
inserts elements
Definition DataTypes.h:911
reverse_iterator rbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:878
Numeric primitive multidimensional array value type.
Definition DataTypes.h:1631
virtual void AssignSubArray(const std::vector< uint32_t > &memorypos, const boost::intrusive_ptr< RRMultiDimArray< T > > &buffer, const std::vector< uint32_t > &bufferpos, const std::vector< uint32_t > &count)
Assign a subset of an array.
Definition DataTypes.h:1687
virtual void RetrieveSubArray(const std::vector< uint32_t > &memorypos, const boost::intrusive_ptr< RRMultiDimArray< T > > &buffer, const std::vector< uint32_t > &bufferpos, const std::vector< uint32_t > &count)
Retrieve a subset of an array.
Definition DataTypes.h:1659
Base class for numeric multidimensional arrays.
Definition DataTypes.h:1584
namedarray array value type
Definition DataTypes.h:2300
iterator end()
returns an iterator to the end
Definition DataTypes.h:2374
T & reference
Definition DataTypes.h:2356
const_iterator end() const
returns an iterator to the end
Definition DataTypes.h:2376
const_reverse_iterator crend() const
returns a reverse iterator to the end
Definition DataTypes.h:2397
reverse_iterator rbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:2386
virtual size_t size() const
returns the number of elements (namedarray elements)
Definition DataTypes.h:2326
RR_OVIRTUAL boost::intrusive_ptr< RRBaseArray > GetNumericBaseArray() RR_OVERRIDE
get the underlying numeric array as an RRBaseArray
Definition DataTypes.h:2340
const_reference front() const
access the first element
Definition DataTypes.h:2429
bool empty()
checks whether the container is empty
Definition DataTypes.h:2437
virtual size_t size()
returns the number of elements (namedarray elements)
Definition DataTypes.h:2328
const_reference at(size_type i) const
access specified namedarray element with bounds checking
Definition DataTypes.h:2420
const_iterator cbegin() const
returns an iterator to the beginning
Definition DataTypes.h:2371
reference back()
access the last element
Definition DataTypes.h:2432
std::size_t size_type
Definition DataTypes.h:2360
const T & const_reference
Definition DataTypes.h:2358
RR_OVIRTUAL DataTypes ElementArrayType() RR_OVERRIDE
get the type of the underlying numeric array
Definition DataTypes.h:2334
const_reference operator[](size_type i) const
access specified namedarray element
Definition DataTypes.h:2407
iterator begin()
returns an iterator to the beginning
Definition DataTypes.h:2367
std::ptrdiff_t difference_type
Definition DataTypes.h:2362
reference front()
access the first element
Definition DataTypes.h:2427
RR_OVIRTUAL size_t ElementSize() RR_OVERRIDE
get the number of bytes per namedarray element of the array
Definition DataTypes.h:2332
const_reverse_iterator rbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:2388
const_iterator begin() const
returns an iterator to the beginning
Definition DataTypes.h:2369
RR_OVIRTUAL size_t ElementArrayCount() RR_OVERRIDE
get the total number of elements in the underlying numeric array
Definition DataTypes.h:2336
RRNamedArray(const boost::intrusive_ptr< RRArray< typename RRPrimUtil< T >::ElementArrayType > > &rr_array)
Construct a RRNamedArray object.
Definition DataTypes.h:2317
const_reverse_iterator crbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:2390
const_reference back() const
access the last element
Definition DataTypes.h:2434
virtual boost::intrusive_ptr< RRArray< typename RRPrimUtil< T >::ElementArrayType > > GetNumericArray()
get the underlying numeric RRArray
Definition DataTypes.h:2338
reverse_iterator rend()
returns a reverse iterator to the end
Definition DataTypes.h:2393
size_type max_size()
returns the maximum possible number of elements
Definition DataTypes.h:2439
reference operator[](size_type i)
access specified namedarray element
Definition DataTypes.h:2400
const_reverse_iterator rend() const
returns a reverse iterator to the end
Definition DataTypes.h:2395
T * iterator
Definition DataTypes.h:2352
T value_type
Definition DataTypes.h:2350
boost::reverse_iterator< const_iterator > const_reverse_iterator
Definition DataTypes.h:2383
const_iterator cend() const
returns an iterator to the end
Definition DataTypes.h:2378
const T * const_iterator
Definition DataTypes.h:2354
reference at(size_type i)
access specified namedarray element with bounds checking
Definition DataTypes.h:2414
boost::reverse_iterator< iterator > reverse_iterator
Definition DataTypes.h:2381
virtual void * void_ptr()
get a void pointer to the underlying numeric array
Definition DataTypes.h:2330
Base class for namedarray array value types.
Definition DataTypes.h:2271
Base class for namedarray multidimensional arrays.
Definition DataTypes.h:2459
namedarray multidimensional array value type
Definition DataTypes.h:2486
virtual void AssignSubArray(const std::vector< uint32_t > &memorypos, const boost::intrusive_ptr< RRNamedMultiDimArray< T > > &buffer, const std::vector< uint32_t > &bufferpos, const std::vector< uint32_t > &count)
Assign a subset of an array.
Definition DataTypes.h:2543
virtual void RetrieveSubArray(const std::vector< uint32_t > &memorypos, const boost::intrusive_ptr< RRNamedMultiDimArray< T > > &buffer, const std::vector< uint32_t > &bufferpos, const std::vector< uint32_t > &count)
Retrieve a subset of an array.
Definition DataTypes.h:2512
virtual std::string RRType()=0
Gets the type of the object as a string. This string is in C++ format, using two colons to separate n...
pod array value type
Definition DataTypes.h:1918
std::vector< T >::iterator iterator
Definition DataTypes.h:1950
size_type max_size() const
returns the maximum possible number of elements
Definition DataTypes.h:1987
reference front()
access the first element
Definition DataTypes.h:1989
const_reverse_iterator rbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:1969
T * data()
direct access to the underlying array
Definition DataTypes.h:2005
const_reference at(size_type i) const
access the specified element with bounds checking
Definition DataTypes.h:2003
std::vector< T >::const_reverse_iterator const_reverse_iterator
Definition DataTypes.h:1956
std::vector< T >::const_reference const_reference
Definition DataTypes.h:1946
reference operator[](size_type i)
access the specified element
Definition DataTypes.h:1997
const_iterator cend() const
returns an iterator to the end
Definition DataTypes.h:1977
const_reference operator[](size_type i) const
access the specified element
Definition DataTypes.h:1999
const_reverse_iterator const crend()
returns a reverse iterator to the end
Definition DataTypes.h:1981
const_reverse_iterator const crbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:1979
T value_type
Definition DataTypes.h:1938
iterator begin()
returns an iterator to the beginning
Definition DataTypes.h:1959
const_reference back() const
access the last element
Definition DataTypes.h:1995
std::vector< T > & GetStorageContainer()
Get the underlying storage container.
Definition DataTypes.h:2016
reverse_iterator rend()
returns a reverse iterator to the end
Definition DataTypes.h:1971
const_iterator cbegin() const
returns an iterator to the beginning
Definition DataTypes.h:1975
const_iterator end() const
returns an iterator to the end
Definition DataTypes.h:1965
std::vector< T >::reference reference
Definition DataTypes.h:1944
reference back()
access the last element
Definition DataTypes.h:1993
std::vector< T >::const_iterator const_iterator
Definition DataTypes.h:1952
const T * data() const
direct access to the underlying array
Definition DataTypes.h:2007
const_reference front() const
access the first element
Definition DataTypes.h:1991
std::vector< T >::size_type size_type
Definition DataTypes.h:1948
virtual size_type size() const
returns the number of elements
Definition DataTypes.h:1985
iterator end()
returns an iterator to the end
Definition DataTypes.h:1963
reference at(size_type i)
access the specified element with bounds checking
Definition DataTypes.h:2001
const_iterator begin() const
retuns an iterator to the beginning
Definition DataTypes.h:1961
reverse_iterator rbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:1967
bool empty() const
checks whether the container is empty
Definition DataTypes.h:1983
std::vector< T >::pointer pointer
Definition DataTypes.h:1940
std::vector< T >::reverse_iterator reverse_iterator
Definition DataTypes.h:1954
const_reverse_iterator rend() const
returns a reverse iterator to the end
Definition DataTypes.h:1973
std::vector< T >::const_pointer const_pointer
Definition DataTypes.h:1942
Base class for pod array value types.
Definition DataTypes.h:1897
Base class for pod multidimensional arrays.
Definition DataTypes.h:2044
Base class for user defined pod value types.
Definition DataTypes.h:1886
pod multidimensional array value type
Definition DataTypes.h:2071
virtual void AssignSubArray(const std::vector< uint32_t > &memorypos, const boost::intrusive_ptr< RRPodMultiDimArray< T > > &buffer, const std::vector< uint32_t > &bufferpos, const std::vector< uint32_t > &count)
Assign a subset of an array.
Definition DataTypes.h:2128
virtual void RetrieveSubArray(const std::vector< uint32_t > &memorypos, const boost::intrusive_ptr< RRPodMultiDimArray< T > > &buffer, const std::vector< uint32_t > &bufferpos, const std::vector< uint32_t > &count)
Retrieve a subset of an array.
Definition DataTypes.h:2097
Base class for user defined structure value types.
Definition DataTypes.h:1067
Represents. a point in time. Used by wire members to timestamp packets.
Definition DataTypes.h:2697
bool operator==(const TimeSpec &t2) const
equality comparison
int64_t seconds
Seconds since epoch.
Definition DataTypes.h:2700
bool operator<=(const TimeSpec &t2) const
less-than-or-equal comparison
TimeSpec operator-(const TimeSpec &t2) const
subtraction operator
void cleanup_nanosecs()
normalize nanoseconds to be within 0 and 1e9-1
bool operator>=(const TimeSpec &t2) const
greater-than-or-equal comparison
TimeSpec(int64_t seconds, int32_t nanoseconds)
Construct timespec with specified time.
bool operator!=(const TimeSpec &t2) const
inequality comparison
bool operator<(const TimeSpec &t2) const
less-then comparison
TimeSpec operator+(const TimeSpec &t2) const
addition operator
bool operator>(const TimeSpec &t2) const
greater-than comparison
int32_t nanoseconds
Nanoseconds from epoch. Normalized to be between 0 and 1e9-1.
Definition DataTypes.h:2702
TimeSpec()
Construct empty timespec.
Complex double precision floating point number.
Definition DataTypes.h:77
double real
real component
Definition DataTypes.h:79
cdouble(double r, double i)
Construct a new cdouble.
Definition DataTypes.h:90
cdouble()
Construct a new cdouble with 0.0 real and imag.
Definition DataTypes.h:83
double imag
imaginary component
Definition DataTypes.h:81
Complex single precision floating point number.
Definition DataTypes.h:99
cfloat()
Construct a new csingle with 0.0 real and imag.
Definition DataTypes.h:105
float real
real component
Definition DataTypes.h:101
float imag
imaginary component
Definition DataTypes.h:103
cfloat(float r, float i)
Construct a new cfloat.
Definition DataTypes.h:112
Logical boolean represented using 8 bits.
Definition DataTypes.h:122
rr_bool()
Construct a new false rr_bool.
Definition DataTypes.h:131
uint8_t value
The value of the boolean.
Definition DataTypes.h:128
rr_bool(uint8_t b)
Construct a new rr_bool object.
Definition DataTypes.h:137