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) { return rr_cast<RRValue>(stringToRRArray(val)); }
472 static std::string PreUnpack(const RR_INTRUSIVE_PTR<RRValue>& val)
473 {
474 return RRArrayToString(rr_cast<RRArray<char> >(val));
475 }
476
477 virtual ~RRPrimUtil(){};
478
479 typedef RR_INTRUSIVE_PTR<RRArray<char> > BoxedType;
480};
481
482#define RRPrimUtilNumeric(x, code) \
483 template <> \
484 class RRPrimUtil<x> \
485 { \
486 public: \
487 static DataTypes GetTypeID() { return code; } \
488 static MessageStringPtr GetElementTypeString() { return MessageStringPtr(""); } \
489 static boost::string_ref GetRRElementTypeString() { return ""; } \
490 static RR_INTRUSIVE_PTR<RRArray<x> > PrePack(const x& val) { return ScalarToRRArray(val); } \
491 template <typename U> \
492 static x PreUnpack(const U& val) \
493 { \
494 return RRArrayToScalar(rr_cast<RRArray<x> >(val)); \
495 } \
496 typedef RR_INTRUSIVE_PTR<RRArray<x> > BoxedType; \
497 };
498
499RRPrimUtilNumeric(double, DataTypes_double_t);
500RRPrimUtilNumeric(float, DataTypes_single_t);
501
502RRPrimUtilNumeric(int8_t, DataTypes_int8_t);
503RRPrimUtilNumeric(uint8_t, DataTypes_uint8_t);
504RRPrimUtilNumeric(int16_t, DataTypes_int16_t);
505RRPrimUtilNumeric(uint16_t, DataTypes_uint16_t);
506RRPrimUtilNumeric(int32_t, DataTypes_int32_t);
507RRPrimUtilNumeric(uint32_t, DataTypes_uint32_t);
508RRPrimUtilNumeric(int64_t, DataTypes_int64_t);
509RRPrimUtilNumeric(uint64_t, DataTypes_uint64_t);
510RRPrimUtilNumeric(char, DataTypes_string_t);
511RRPrimUtilNumeric(cdouble, DataTypes_cdouble_t);
512RRPrimUtilNumeric(cfloat, DataTypes_csingle_t);
513RRPrimUtilNumeric(rr_bool, DataTypes_bool_t);
514
515ROBOTRACONTEUR_CORE_API std::string GetRRDataTypeString(DataTypes type);
516ROBOTRACONTEUR_CORE_API bool IsTypeRRArray(DataTypes type);
517ROBOTRACONTEUR_CORE_API bool IsTypeNumeric(DataTypes type);
518
527class ROBOTRACONTEUR_CORE_API RRBaseArray : public MessageElementData
528{
529 public:
530 RR_OVIRTUAL MessageStringPtr GetTypeString() RR_OVERRIDE
531 {
532 std::string type = GetRRDataTypeString(GetTypeID());
533 return type + "[]";
534 }
535
536 RR_OVIRTUAL ~RRBaseArray() RR_OVERRIDE {}
537
543 virtual size_t size() = 0;
544
545 RR_OVIRTUAL std::string RRType() RR_OVERRIDE;
546
552 virtual void* void_ptr() = 0;
553
559 virtual size_t ElementSize() = 0;
560};
561
579template <typename T>
580class RRArray : public RRBaseArray
581{
582 public:
583 RR_OVIRTUAL DataTypes GetTypeID() RR_OVERRIDE { return RRPrimUtil<T>::GetTypeID(); }
584
585 RRArray(T* data, size_t length, bool owned) : data_(data), element_count(length), owned(owned) {}
586
587 RR_OVIRTUAL ~RRArray() RR_OVERRIDE
588 {
589 if (owned)
590 delete[] data_;
591 }
592
593 RR_OVIRTUAL void* void_ptr() RR_OVERRIDE { return data(); }
594
595 T* operator->() const { return data; }
596
597 RR_OVIRTUAL size_t size() RR_OVERRIDE { return element_count; }
598
599 RR_OVIRTUAL size_t ElementSize() RR_OVERRIDE { return sizeof(T); }
600
601 // C++ container support functions based on boost::array
602
603 // type definitions
605 typedef T value_type;
607 typedef T* iterator;
609 typedef const T* const_iterator;
611 typedef T& reference;
613 typedef const T& const_reference;
615 typedef std::size_t size_type;
617 typedef std::ptrdiff_t difference_type;
618
619 // iterator support
620
622 iterator begin() { return data_; }
624 const_iterator begin() const { return data_; }
626 const_iterator cbegin() const { return data_; }
627
629 iterator end() { return data_ + element_count; }
631 const_iterator end() const { return data_ + element_count; }
633 const_iterator cend() const { return data_ + element_count; }
634
636 typedef boost::reverse_iterator<iterator> reverse_iterator;
638 typedef boost::reverse_iterator<const_iterator> const_reverse_iterator;
639
646
653
656 {
657 BOOST_ASSERT_MSG(i < element_count, "out of range");
658 return data_[i];
659 }
660
663 {
664 BOOST_ASSERT_MSG(i < element_count, "out of range");
665 return data_[i];
666 }
667
670 {
671 rangecheck(i);
672 return data_[i];
673 }
674
676 {
677 rangecheck(i);
678 return data_[i];
679 }
680
682 reference front() { return data_[0]; }
683
685 const_reference front() const { return data_[0]; }
686
688 reference back() { return data_[element_count - 1]; }
689
691 const_reference back() const { return data_[element_count - 1]; }
692
694 bool empty() { return false; }
696 size_type max_size() { return element_count; }
697
699 const T* data() const { return data_; }
701 T* data() { return data_; }
702
703 T* c_array() { return data_; }
704
712 template <typename T2>
713 RRArray<T>& operator=(const RRArray<T2>& rhs)
714 {
715 std::copy(rhs.begin(), rhs.end(), begin());
716 return *this;
717 }
718
726 void assign(const T& value) { fill(value); }
732 void fill(const T& value) { std::fill_n(begin(), size(), value); }
733
734 void rangecheck(size_type i)
735 {
736 if (i >= size())
737 {
738 std::out_of_range e("array<>: index out of range");
739 boost::throw_exception(e);
740 }
741 }
742
743 private:
744 T* data_;
745 size_t element_count;
746 bool owned;
747};
748
749template <typename T>
750class RRMap_keytype
751{
752 public:
753 static boost::string_ref get()
754 {
755 BOOST_STATIC_ASSERT_MSG(sizeof(T) == 0, "Invalid key type for Robot Raconteur map");
756 throw DataTypeException("Unknown data type");
757 }
758
759 static std::string get_map_rrtype()
760 {
761 BOOST_STATIC_ASSERT_MSG(sizeof(T) == 0, "Invalid key type for Robot Raconteur map");
762 throw DataTypeException("Unknown data type");
763 }
764};
765
766template <>
767class RRMap_keytype<int32_t>
768{
769 public:
770 static boost::string_ref get() { return "int32_t"; }
771
772 static std::string get_map_rrtype() { return "RobotRaconteur.RRMap<int32_t>"; }
773};
774
775template <>
776class RRMap_keytype<std::string>
777{
778 public:
779 static boost::string_ref get() { return "string"; }
780
781 static std::string get_map_rrtype() { return "RobotRaconteur.RRMap<string>"; }
782};
783
794template <typename K, typename T>
795class RRMap : public RRValue
796{
797 protected:
798 std::map<K, RR_INTRUSIVE_PTR<T> > map;
799
800 public:
801 RRMap() {}
802
803 RRMap(const std::map<K, RR_INTRUSIVE_PTR<T> >& mapin) : map(mapin) {}
804
805 RR_OVIRTUAL ~RRMap() RR_OVERRIDE {}
806
807 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return RRMap_keytype<K>::get_map_rrtype(); }
808
809 // C++ container support based on boost::container::map
810
812 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::key_type key_type;
814 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::mapped_type mapped_type;
816 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::value_type value_type;
818 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::pointer pointer;
820 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::const_pointer const_pointer;
822 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::reference reference;
824 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::const_reference const_reference;
826 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::size_type size_type;
828 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::iterator iterator;
830 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::const_iterator const_iterator;
832 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::reverse_iterator reverse_iterator;
834 typedef typename std::map<K, RR_INTRUSIVE_PTR<T> >::const_reverse_iterator const_reverse_iterator;
835
837 iterator begin() { return map.begin(); }
839 const_iterator cbegin() const { return map.cbegin(); }
841 const_iterator begin() const { return map.begin(); }
843 iterator end() { return map.end(); }
845 const_iterator cend() const { return map.end(); }
847 const_iterator end() const { return map.end(); }
849 reverse_iterator rbegin() { return map.rbegin(); };
851 const_reverse_iterator crbegin() const { return map.crbegin(); };
853 const_reverse_iterator rbegin() const { return map.rbegin(); };
855 reverse_iterator rend() { return map.rend(); }
857 const_reverse_iterator crend() const { return map.rend(); }
859 const_reverse_iterator rend() const { return map.rend(); }
861 bool empty() const { return map.empty(); }
863 size_type size() const { return map.size(); }
865 size_type max_size() const { return map.max_size(); };
867 mapped_type& operator[](const key_type& k) { return map[k]; }
869 mapped_type& at(const key_type& k) { return map.at(k); }
871 const mapped_type& at(const key_type& k) const { return map.at(k); }
873 std::pair<iterator, bool> insert(const value_type& x) { return map.insert(x); }
876 {
877 RR_UNUSED(p);
878 return map.insert(x);
879 }
880
881 template <class InputIterator>
882 void insert(InputIterator first, InputIterator last)
883 {
884 map.insert(first, last);
885 }
886
887 void erase(iterator p) { map.erase(p); }
889 size_type erase(const key_type& x) { return map.erase(x); }
891 void erase(iterator first, iterator last) { map.erase(first, last); }
893 void clear() { map.clear(); }
895 iterator find(const key_type& x) { return map.find(x); }
897 const_iterator find(const key_type& x) const { return map.find(x); }
899 size_type count(const key_type& x) const { return map.count(x); }
900
908 typename std::map<K, RR_INTRUSIVE_PTR<T> >& GetStorageContainer() { return map; }
909};
910
920template <typename T>
921class RRList : public RRValue
922{
923 protected:
924 std::list<RR_INTRUSIVE_PTR<T> > list;
925
926 public:
927 RRList() {}
928
929 RRList(std::list<RR_INTRUSIVE_PTR<T> > listin) { list = listin; }
930
931 RR_OVIRTUAL ~RRList() RR_OVERRIDE {}
932
933 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRList"; }
934
935 // C++ container support based on boost::container::list
936
938 typedef RR_INTRUSIVE_PTR<T> value_type;
940 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::pointer pointer;
942 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::const_pointer const_pointer;
944 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::reference reference;
946 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::const_reference const_reference;
948 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::size_type size_type;
950 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::difference_type difference_type;
952 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::iterator iterator;
954 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::const_iterator const_iterator;
956 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::reverse_iterator reverse_iterator;
958 typedef typename std::list<RR_INTRUSIVE_PTR<T> >::const_reverse_iterator const_reverse_iterator;
959
961 iterator begin() { return list.begin(); }
963 const_iterator begin() const { return list.begin(); }
965 iterator end() { return list.end(); }
967 const_iterator end() const { return list.end(); }
969 reverse_iterator rbegin() { return list.rbegin(); }
971 const_reverse_iterator rbegin() const { return list.rbegin(); }
973 reverse_iterator rend() { return list.rend(); }
975 const_reverse_iterator crend() const { return list.crend(); }
977 const_reverse_iterator rend() const { return list.rend(); }
979 const_iterator cbegin() const { return list.cbegin(); }
981 const_iterator cend() const { return list.cend(); }
983 const_reverse_iterator const crbegin() { return list.crbegin(); }
985 const_reverse_iterator const crend() { return list.crend(); }
987 bool empty() const { return list.empty(); }
989 virtual size_type size() const { return list.size(); }
991 size_type max_size() const { return list.max_size(); }
993 reference front() { return list.front(); }
995 const_reference front() const { return list.front(); }
997 reference back() { return list.back(); }
999 const_reference back() const { return list.back(); }
1001 void push_front(const RR_INTRUSIVE_PTR<T>& x) { list.push_front(x); }
1003 void push_back(const RR_INTRUSIVE_PTR<T>& x) { list.push_back(x); }
1005 void pop_front() { list.pop_front(); }
1007 void pop_back() { list.pop_back(); }
1009 iterator insert(const_iterator p, const RR_INTRUSIVE_PTR<T>& x) { list.insert(p, x); }
1011 iterator erase(const_iterator p) { list.erase(p); }
1013 iterator erase(const_iterator first, const_iterator last) { list.erase(first, last); }
1015 void clear() { list.clear(); }
1017 void remove(const RR_INTRUSIVE_PTR<T>& value) { list.remove(value); }
1018
1026 typename std::list<RR_INTRUSIVE_PTR<T> >& GetStorageContainer() { return list; }
1027};
1028
1037class ROBOTRACONTEUR_CORE_API RRStructure : public RRValue
1038{
1039 public:
1040 RR_OVIRTUAL ~RRStructure() RR_OVERRIDE {}
1041};
1042
1058template <typename T>
1059static RR_INTRUSIVE_PTR<RRArray<T> > AllocateRRArray(size_t length)
1060{
1061 return RR_INTRUSIVE_PTR<RRArray<T> >(new RRArray<T>(new T[length], length, true));
1062}
1063
1082template <typename T>
1083static RR_INTRUSIVE_PTR<RRArray<T> > AttachRRArray(T* data, size_t length, bool owned)
1084{
1085 return RR_INTRUSIVE_PTR<RRArray<T> >(new RRArray<T>(data, length, owned));
1086}
1087
1100template <typename T>
1101static RR_INTRUSIVE_PTR<RRArray<T> > AttachRRArrayCopy(const T* data, const size_t length)
1102{
1103 RR_INTRUSIVE_PTR<RRArray<T> > ret(new RRArray<T>(new T[length], length, true));
1104 memcpy(ret->void_ptr(), data, length * sizeof(T));
1105 return ret;
1106}
1107
1125ROBOTRACONTEUR_CORE_API RR_INTRUSIVE_PTR<RRBaseArray> AllocateRRArrayByType(DataTypes type, size_t length);
1126
1141template <typename T>
1142static RR_INTRUSIVE_PTR<RRArray<T> > AllocateEmptyRRArray(size_t length)
1143{
1144 RR_INTRUSIVE_PTR<RRArray<T> > o = AllocateRRArray<T>(length);
1145 if (length > 0)
1146 {
1147 memset(static_cast<void*>(o->data()), 0, length * sizeof(T));
1148 }
1149 return o;
1150}
1151
1165ROBOTRACONTEUR_CORE_API size_t RRArrayElementSize(DataTypes type);
1166
1174template <typename T>
1175static RR_INTRUSIVE_PTR<RRArray<T> > ScalarToRRArray(T value)
1176{
1177 return AttachRRArrayCopy(&value, 1);
1178}
1179
1187template <typename T>
1188static T RRArrayToScalar(const RR_INTRUSIVE_PTR<RRArray<T> >& value)
1189{
1190 if (!value)
1191 {
1192 throw NullValueException("Null pointer");
1193 }
1194
1195 if (value->size() == 0)
1196 throw OutOfRangeException("Index out of range");
1197
1198 return (*value)[0];
1199}
1200
1214template <typename Y, typename U>
1215static std::vector<Y> RRArrayToVector(const RR_INTRUSIVE_PTR<RRArray<U> >& in)
1216{
1217 if (!in)
1218 throw NullValueException("Unexpected null array");
1219 std::vector<Y> out(in->size());
1220 for (size_t i = 0; i < in->size(); i++)
1221 out[i] = boost::numeric_cast<Y>((*in)[i]);
1222 return out;
1223}
1224
1236template <typename Y, typename U>
1237static RR_INTRUSIVE_PTR<RRArray<Y> > VectorToRRArray(const std::vector<U>& in)
1238{
1239 RR_INTRUSIVE_PTR<RRArray<Y> > out = AllocateRRArray<Y>(in.size());
1240 for (size_t i = 0; i < in.size(); i++)
1241 (*out)[i] = boost::numeric_cast<Y>(in[i]);
1242 return out;
1243}
1244
1257template <typename Y, std::size_t N, typename U>
1258static boost::array<Y, N> RRArrayToArray(const RR_INTRUSIVE_PTR<RRArray<U> >& in)
1259{
1260 if (!in)
1261 throw NullValueException("Unexpected null array");
1262 if (in->size() != N)
1263 throw OutOfRangeException("Array is incorrect size");
1264 boost::array<Y, N> out = {};
1265 for (size_t i = 0; i < N; i++)
1266 out[i] = boost::numeric_cast<Y>((*in)[i]);
1267 return out;
1268}
1269
1281template <typename Y, std::size_t N, typename U>
1282static void RRArrayToArray(boost::array<Y, N>& out, const RR_INTRUSIVE_PTR<RRArray<U> >& in)
1283{
1284 if (!in)
1285 throw NullValueException("Unexpected null array");
1286 if (in->size() != N)
1287 throw OutOfRangeException("Array is incorrect size");
1288 for (size_t i = 0; i < N; i++)
1289 out[i] = boost::numeric_cast<Y>((*in)[i]);
1290}
1291
1304template <typename Y, typename U, std::size_t N>
1305static RR_INTRUSIVE_PTR<RRArray<Y> > ArrayToRRArray(boost::array<U, N> in)
1306{
1307 RR_INTRUSIVE_PTR<RRArray<Y> > out = AllocateRRArray<Y>(N);
1308 for (size_t i = 0; i < N; i++)
1309 (*out)[i] = boost::numeric_cast<Y>(in[i]);
1310 return out;
1311}
1312
1327template <typename Y, std::size_t N, typename U>
1328static boost::container::static_vector<Y, N> RRArrayToStaticVector(const RR_INTRUSIVE_PTR<RRArray<U> >& in)
1329{
1330 if (!in)
1331 throw NullValueException("Unexpected null array");
1332 if (in->size() > N)
1333 throw OutOfRangeException("Array is too large for static vector size");
1334 boost::container::static_vector<Y, N> out(in->size());
1335 for (size_t i = 0; i < in->size(); i++)
1336 out[i] = boost::numeric_cast<Y>((*in)[i]);
1337 return out;
1338}
1339
1354template <typename Y, std::size_t N, typename U>
1355static void RRArrayToStaticVector(boost::container::static_vector<Y, N>& out, const RR_INTRUSIVE_PTR<RRArray<U> >& in)
1356{
1357 if (!in)
1358 throw NullValueException("Unexpected null array");
1359 if (in->size() > N)
1360 throw OutOfRangeException("Array is too large for static vector size");
1361 out.resize(in->size());
1362 for (size_t i = 0; i < in->size(); i++)
1363 out[i] = boost::numeric_cast<Y>((*in)[i]);
1364}
1365
1380template <typename Y, typename U, std::size_t N>
1381static RR_INTRUSIVE_PTR<RRArray<Y> > StaticVectorToRRArray(boost::container::static_vector<U, N> in)
1382{
1383 RR_INTRUSIVE_PTR<RRArray<Y> > out = AllocateRRArray<Y>(in.size());
1384 for (size_t i = 0; i < in.size(); i++)
1385 (*out)[i] = boost::numeric_cast<Y>(in[i]);
1386 return out;
1387}
1388
1397ROBOTRACONTEUR_CORE_API RR_INTRUSIVE_PTR<RRList<RRArray<char> > > stringVectorToRRList(
1398 const std::vector<std::string>& string_vector);
1399
1408ROBOTRACONTEUR_CORE_API std::vector<std::string> RRListToStringVector(
1409 const RR_INTRUSIVE_PTR<RRList<RRArray<char> > >& list);
1410
1422template <typename T>
1423RR_INTRUSIVE_PTR<T>& rr_null_check(RR_INTRUSIVE_PTR<T>& ptr)
1424{
1425 if (!ptr)
1426 {
1427 throw NullValueException("Unexpected null value");
1428 }
1429 return ptr;
1430}
1431
1445template <typename T>
1446RR_INTRUSIVE_PTR<T>& rr_null_check(RR_INTRUSIVE_PTR<T>& ptr, const char* msg)
1447{
1448 if (!ptr)
1449 {
1450 throw NullValueException(msg);
1451 }
1452 return ptr;
1453}
1454
1466template <typename T>
1467const RR_INTRUSIVE_PTR<T>& rr_null_check(const RR_INTRUSIVE_PTR<T>& ptr)
1468{
1469 if (!ptr)
1470 {
1471 throw NullValueException("Unexpected null value");
1472 }
1473 return ptr;
1474}
1475
1489template <typename T>
1490const RR_INTRUSIVE_PTR<T>& rr_null_check(const RR_INTRUSIVE_PTR<T>& ptr, const char* msg)
1491{
1492 if (!ptr)
1493 {
1494 throw NullValueException(msg);
1495 }
1496 return ptr;
1497}
1498
1499#define RR_NULL_CHECK rr_null_check
1500
1501template <typename T>
1502static RR_INTRUSIVE_PTR<RRArray<T> > VerifyRRArrayLength(const RR_INTRUSIVE_PTR<RRArray<T> >& a, size_t len,
1503 bool varlength)
1504{
1505 if (!a)
1506 throw NullValueException("Arrays must not be null");
1507 if (len != 0)
1508 {
1509 if (varlength && (a->size() > len))
1510 {
1511 throw DataTypeException("Array dimension mismatch");
1512 }
1513 if (!varlength && (a->size() != len))
1514 {
1515 throw DataTypeException("Array dimension mismatch");
1516 }
1517 }
1518 return a;
1519}
1520
1521template <typename T>
1522static RR_INTRUSIVE_PTR<RRList<T> > VerifyRRArrayLength(const RR_INTRUSIVE_PTR<RRList<T> >& a, size_t len,
1523 bool varlength)
1524{
1525 if (!a)
1526 return a;
1527 BOOST_FOREACH (RR_INTRUSIVE_PTR<T>& aa, (*a))
1528 {
1529 VerifyRRArrayLength(aa, len, varlength);
1530 }
1531 return a;
1532}
1533
1534template <typename K, typename T>
1535static RR_INTRUSIVE_PTR<RRMap<K, T> > VerifyRRArrayLength(const RR_INTRUSIVE_PTR<RRMap<K, T> >& a, size_t len,
1536 bool varlength)
1537{
1538 if (!a)
1539 return a;
1540 BOOST_FOREACH (const RR_INTRUSIVE_PTR<T>& aa, *a | boost::adaptors::map_values)
1541 {
1542 VerifyRRArrayLength(aa, len, varlength);
1543 }
1544 return a;
1545}
1546
1554class ROBOTRACONTEUR_CORE_API RRMultiDimBaseArray : public RRValue
1555{
1556 public:
1557 RR_OVIRTUAL ~RRMultiDimBaseArray() RR_OVERRIDE {}
1558
1559 virtual DataTypes GetElementTypeID() = 0;
1560};
1561
1562namespace detail
1563{
1564ROBOTRACONTEUR_CORE_API class MultiDimArray_CalculateCopyIndicesIter
1565{
1566 public:
1567 virtual bool Next(uint32_t& indexa, uint32_t& indexb, uint32_t& len) = 0;
1568
1569 virtual ~MultiDimArray_CalculateCopyIndicesIter();
1570};
1571
1572// cSpell: ignore mema, memb
1573ROBOTRACONTEUR_CORE_API RR_SHARED_PTR<MultiDimArray_CalculateCopyIndicesIter>
1574MultiDimArray_CalculateCopyIndicesBeginIter(const std::vector<uint32_t>& mema_dims,
1575 const std::vector<uint32_t>& mema_pos,
1576 const std::vector<uint32_t>& memb_dims,
1577 const std::vector<uint32_t>& memb_pos, const std::vector<uint32_t>& count);
1578} // namespace detail
1579
1600template <typename T>
1601class RRMultiDimArray : public RRMultiDimBaseArray
1602{
1603 public:
1604 RR_INTRUSIVE_PTR<RRArray<uint32_t> > Dims;
1605
1606 RR_INTRUSIVE_PTR<RRArray<T> > Array;
1607
1608 RRMultiDimArray(){};
1609
1610 RRMultiDimArray(const RR_INTRUSIVE_PTR<RRArray<uint32_t> >& Dims, const RR_INTRUSIVE_PTR<RRArray<T> >& Array)
1611 {
1612 this->Dims = Dims;
1613 this->Array = Array;
1614 }
1615
1616 RR_OVIRTUAL ~RRMultiDimArray() RR_OVERRIDE {}
1617
1618 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRMultiDimArray"; }
1619
1620 RR_OVIRTUAL DataTypes GetElementTypeID() RR_OVERRIDE { return RRPrimUtil<T>::GetTypeID(); }
1621
1630 virtual void RetrieveSubArray(const std::vector<uint32_t>& memorypos,
1631 const RR_INTRUSIVE_PTR<RRMultiDimArray<T> >& buffer,
1632 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
1633 {
1634
1635 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
1636 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
1637 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
1638 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
1639
1640 uint32_t len = 0;
1641 uint32_t indexa = 0;
1642 uint32_t indexb = 0;
1643
1644 while (iter->Next(indexa, indexb, len))
1645 {
1646 memcpy((buffer->Array->data() + indexb), (Array->data()) + indexa, len * sizeof(T));
1647 }
1648 }
1649
1658 virtual void AssignSubArray(const std::vector<uint32_t>& memorypos,
1659 const RR_INTRUSIVE_PTR<RRMultiDimArray<T> >& buffer,
1660 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
1661 {
1662
1663 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
1664 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
1665 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
1666 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
1667
1668 uint32_t len = 0;
1669 uint32_t indexa = 0;
1670 uint32_t indexb = 0;
1671
1672 while (iter->Next(indexa, indexb, len))
1673 {
1674 memcpy((Array->data() + indexa), (buffer->Array->data() + indexb), len * sizeof(T));
1675 }
1676 }
1677};
1678
1679template <size_t Ndims, typename T>
1680static RR_INTRUSIVE_PTR<RRMultiDimArray<T> > VerifyRRMultiDimArrayLength(const RR_INTRUSIVE_PTR<RRMultiDimArray<T> >& a,
1681 size_t n_elems,
1682 const boost::array<uint32_t, Ndims>& dims)
1683{
1684 if (!a)
1685 throw NullValueException("Arrays must not be null");
1686
1687 if (a->Dims->size() != Ndims)
1688 {
1689 throw DataTypeException("Array dimension mismatch");
1690 }
1691
1692 if (a->Array->size() != n_elems)
1693 {
1694 throw DataTypeException("Array dimension mismatch");
1695 }
1696
1697 for (size_t i = 0; i < Ndims; i++)
1698 {
1699 if ((*a->Dims)[i] != dims[i])
1700 {
1701 throw DataTypeException("Array dimension mismatch");
1702 }
1703 }
1704
1705 return a;
1706}
1707
1708template <size_t Ndims, typename T>
1709static RR_INTRUSIVE_PTR<RRList<T> > VerifyRRMultiDimArrayLength(const RR_INTRUSIVE_PTR<RRList<T> >& a, size_t n_elems,
1710 const boost::array<uint32_t, Ndims>& dims)
1711{
1712 if (!a)
1713 {
1714 // Containers can be null
1715 return a;
1716 }
1717 else
1718 {
1719 BOOST_FOREACH (const RR_INTRUSIVE_PTR<T>& aa, (*a))
1720 {
1721 VerifyRRMultiDimArrayLength<Ndims>(aa, n_elems, dims);
1722 }
1723 }
1724 return a;
1725}
1726
1727template <size_t Ndims, typename K, typename T>
1728static RR_INTRUSIVE_PTR<RRMap<K, T> > VerifyRRMultiDimArrayLength(const RR_INTRUSIVE_PTR<RRMap<K, T> >& a,
1729 size_t n_elems,
1730 const boost::array<uint32_t, Ndims>& dims)
1731{
1732 if (!a)
1733 {
1734 // Containers can be null
1735 return a;
1736 }
1737 else
1738 {
1739 BOOST_FOREACH (const RR_INTRUSIVE_PTR<T>& aa, *a | boost::adaptors::map_values)
1740 {
1741 VerifyRRMultiDimArrayLength<Ndims>(aa, n_elems, dims);
1742 }
1743 return a;
1744 }
1745}
1746
1757template <typename T>
1758static RR_INTRUSIVE_PTR<RRMultiDimArray<T> > AllocateEmptyRRMultiDimArray(const std::vector<uint32_t>& dims)
1759{
1760 uint32_t n_elems = boost::accumulate(dims, 1, std::multiplies<uint32_t>());
1762}
1763
1770template <typename T>
1771static RR_INTRUSIVE_PTR<RRMultiDimArray<T> > AllocateEmptyRRMultiDimArray()
1772{
1773 std::vector<uint32_t> length;
1774 length.push_back(0);
1776}
1777
1788template <typename T>
1789static RR_INTRUSIVE_PTR<RRMultiDimArray<T> > AllocateRRMultiDimArray(const RR_INTRUSIVE_PTR<RRArray<uint32_t> >& dims,
1790 const RR_INTRUSIVE_PTR<RRArray<T> >& array_)
1791{
1792 return new RRMultiDimArray<T>(dims, array_); // NOLINT(cppcoreguidelines-owning-memory)
1793}
1794
1801template <typename T>
1802RR_INTRUSIVE_PTR<RRList<T> > AllocateEmptyRRList()
1803{
1804 return new RRList<T>(); // NOLINT(cppcoreguidelines-owning-memory)
1805}
1806
1815template <typename T, typename U>
1816RR_INTRUSIVE_PTR<RRList<T> > AllocateRRList(const U& c)
1817{
1818 return new RRList<T>(c); // NOLINT(cppcoreguidelines-owning-memory)
1819}
1820
1828template <typename K, typename T>
1829RR_INTRUSIVE_PTR<RRMap<K, T> > AllocateEmptyRRMap()
1830{
1831 return new RRMap<K, T>(); // NOLINT(cppcoreguidelines-owning-memory)
1832}
1833
1843template <typename K, typename T, typename U>
1844RR_INTRUSIVE_PTR<RRMap<K, T> > AllocateRRMap(const U& c)
1845{
1846 return new RRMap<K, T>(c); // NOLINT(cppcoreguidelines-owning-memory)
1847}
1848
1856class ROBOTRACONTEUR_CORE_API RRPod
1857{
1858 public:
1859};
1860
1867class RRPodBaseArray : public RRValue
1868{
1869 public:
1870 virtual boost::string_ref RRElementTypeString() = 0;
1871};
1872
1887template <typename T>
1888class RRPodArray : public RRPodBaseArray
1889{
1890 protected:
1891 typename std::vector<T> pod_array;
1892
1893 public:
1894 RRPodArray(size_t n) { pod_array.resize(n); }
1895
1896 RRPodArray(typename std::vector<T>& array_in) : pod_array(array_in) {}
1897
1898 RRPodArray(const T& value_in) { pod_array.push_back(value_in); }
1899
1900 RR_OVIRTUAL ~RRPodArray() RR_OVERRIDE {}
1901
1902 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRPodArray"; }
1903
1904 RR_OVIRTUAL boost::string_ref RRElementTypeString() RR_OVERRIDE { return RRPrimUtil<T>::GetRRElementTypeString(); }
1905
1906 // C++ container support based on boost::container::vector
1907
1909 typedef T value_type;
1911 typedef typename std::vector<T>::pointer pointer;
1913 typedef typename std::vector<T>::const_pointer const_pointer;
1915 typedef typename std::vector<T>::reference reference;
1917 typedef typename std::vector<T>::const_reference const_reference;
1919 typedef typename std::vector<T>::size_type size_type;
1921 typedef typename std::vector<T>::iterator iterator;
1923 typedef typename std::vector<T>::const_iterator const_iterator;
1925 typedef typename std::vector<T>::reverse_iterator reverse_iterator;
1927 typedef typename std::vector<T>::const_reverse_iterator const_reverse_iterator;
1928
1930 iterator begin() { return pod_array.begin(); }
1932 const_iterator begin() const { return pod_array.begin(); }
1934 iterator end() { return pod_array.end(); }
1936 const_iterator end() const { return pod_array.end(); }
1938 reverse_iterator rbegin() { return pod_array.rbegin(); }
1940 const_reverse_iterator rbegin() const { return pod_array.rbegin(); }
1942 reverse_iterator rend() { return pod_array.rend(); }
1944 const_reverse_iterator rend() const { return pod_array.rend(); }
1946 const_iterator cbegin() const { return pod_array.cbegin(); }
1948 const_iterator cend() const { return pod_array.cend(); }
1950 const_reverse_iterator const crbegin() { return pod_array.crbegin(); }
1952 const_reverse_iterator const crend() { return pod_array.crend(); }
1954 bool empty() const { return pod_array.empty(); }
1956 virtual size_type size() const { return pod_array.size(); }
1958 size_type max_size() const { return size(); }
1960 reference front() { return pod_array.front(); }
1962 const_reference front() const { return pod_array.front(); }
1964 reference back() { return pod_array.back(); }
1966 const_reference back() const { return pod_array.back(); }
1968 reference operator[](size_type i) { return pod_array[i]; }
1970 const_reference operator[](size_type i) const { return pod_array[i]; }
1972 reference at(size_type i) { return pod_array.at(i); }
1974 const_reference at(size_type i) const { return pod_array.at(i); }
1976 T* data() { return pod_array.data(); }
1978 const T* data() const { return pod_array.data(); }
1979
1987 typename std::vector<T>& GetStorageContainer() { return pod_array; }
1988};
1989
1990#define RRPrimUtilPod(x, type_string) \
1991 template <> \
1992 class RRPrimUtil<x> \
1993 { \
1994 public: \
1995 static DataTypes GetTypeID() { return DataTypes_pod_t; } \
1996 static MessageStringPtr GetElementTypeString() { return MessageStringPtr(type_string); } \
1997 static boost::string_ref GetRRElementTypeString() { return type_string; } \
1998 static RR_INTRUSIVE_PTR<RRPodArray<x> > PrePack(const x& val) { return ScalarToRRPodArray(val); } \
1999 template <typename U> \
2000 static x PreUnpack(const U& val) \
2001 { \
2002 return RRPodArrayToScalar(rr_cast<RRPodArray<x> >(val)); \
2003 } \
2004 typedef RR_INTRUSIVE_PTR<RRPodArray<x> > BoxedType; \
2005 };
2006
2014class RRPodBaseMultiDimArray : public RRValue
2015{
2016 public:
2017 RR_INTRUSIVE_PTR<RRArray<uint32_t> > Dims;
2018 virtual boost::string_ref RRElementTypeString() = 0;
2019};
2020
2040template <typename T>
2041class RRPodMultiDimArray : public RRPodBaseMultiDimArray
2042{
2043 public:
2044 typename RR_INTRUSIVE_PTR<RRPodArray<T> > PodArray;
2045
2046 RRPodMultiDimArray() {}
2047
2048 RRPodMultiDimArray(const RR_INTRUSIVE_PTR<RRArray<uint32_t> >& dims, const RR_INTRUSIVE_PTR<RRPodArray<T> >& a)
2049 {
2050 this->Dims = dims;
2051 this->PodArray = a;
2052 }
2053
2054 RR_OVIRTUAL ~RRPodMultiDimArray() RR_OVERRIDE {}
2055
2056 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRPodMultiDimArray"; }
2057
2058 RR_OVIRTUAL boost::string_ref RRElementTypeString() RR_OVERRIDE { return RRPrimUtil<T>::GetRRElementTypeString(); }
2059
2068 virtual void RetrieveSubArray(const std::vector<uint32_t>& memorypos,
2069 const RR_INTRUSIVE_PTR<RRPodMultiDimArray<T> >& buffer,
2070 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
2071 {
2072
2073 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
2074 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
2075 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
2076 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
2077
2078 uint32_t len = 0;
2079 uint32_t indexa = 0;
2080 uint32_t indexb = 0;
2081
2082 while (iter->Next(indexa, indexb, len))
2083 {
2084 for (size_t i = 0; i < len; i++)
2085 {
2086 buffer->PodArray->at(indexb + i) = PodArray->at(indexa + i);
2087 }
2088 }
2089 }
2090
2099 virtual void AssignSubArray(const std::vector<uint32_t>& memorypos,
2100 const RR_INTRUSIVE_PTR<RRPodMultiDimArray<T> >& buffer,
2101 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
2102 {
2103
2104 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
2105 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
2106 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
2107 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
2108
2109 uint32_t len = 0;
2110 uint32_t indexa = 0;
2111 uint32_t indexb = 0;
2112
2113 while (iter->Next(indexa, indexb, len))
2114 {
2115 for (size_t i = 0; i < len; i++)
2116 {
2117 PodArray->at(indexa + i) = buffer->PodArray->at(indexb + i);
2118 }
2119 }
2120 }
2121};
2122
2130template <typename T>
2131static RR_INTRUSIVE_PTR<RRPodArray<T> > ScalarToRRPodArray(const T& value)
2132{
2133 return new RRPodArray<T>(value); // NOLINT(cppcoreguidelines-owning-memory)
2134}
2135
2143template <typename T>
2144static T RRPodArrayToScalar(const RR_INTRUSIVE_PTR<RRPodArray<T> >& value)
2145{
2146 if (!value)
2147 {
2148 throw NullValueException("Null pointer");
2149 }
2150
2151 if (value->size() == 0)
2152 throw OutOfRangeException("Index out of range");
2153
2154 return value->at(0);
2155}
2156
2170template <typename T>
2171static RR_INTRUSIVE_PTR<RRPodArray<T> > AllocateEmptyRRPodArray(size_t length)
2172{
2173 return new RRPodArray<T>(length); // NOLINT(cppcoreguidelines-owning-memory)
2174}
2175
2189template <typename T>
2190static RR_INTRUSIVE_PTR<RRPodMultiDimArray<T> > AllocateEmptyRRPodMultiDimArray(const std::vector<uint32_t>& dims)
2191{
2192 uint32_t n_elems = boost::accumulate(dims, 1, std::multiplies<uint32_t>());
2194}
2195
2206template <typename T>
2207static RR_INTRUSIVE_PTR<RRPodMultiDimArray<T> > AllocateEmptyRRPodMultiDimArray()
2208{
2209 std::vector<uint32_t> length;
2210 length.push_back(0);
2212}
2213
2214#define RRPrimUtilNamedArray(x, type_string, array_type) \
2215 template <> \
2216 class RRPrimUtil<x> \
2217 { \
2218 public: \
2219 static DataTypes GetTypeID() { return DataTypes_pod_t; } \
2220 static MessageStringPtr GetElementTypeString() { return MessageStringPtr(type_string); } \
2221 static boost::string_ref GetRRElementTypeString() { return type_string; } \
2222 static RR_INTRUSIVE_PTR<RRNamedArray<x> > PrePack(const x& val) { return ScalarToRRNamedArray(val); } \
2223 template <typename U> \
2224 static x PreUnpack(const U& val) \
2225 { \
2226 return RRNamedArrayToScalar(rr_cast<RRNamedArray<x> >(val)); \
2227 } \
2228 typedef RR_INTRUSIVE_PTR<RRNamedArray<x> > BoxedType; \
2229 typedef array_type ElementArrayType; \
2230 static const size_t ElementArrayCount = sizeof(x) / sizeof(array_type); \
2231 static size_t GetElementArrayCount() { return ElementArrayCount; } \
2232 static DataTypes GetElementArrayTypeID() { return RRPrimUtil<array_type>::GetTypeID(); } \
2233 };
2234
2241class ROBOTRACONTEUR_CORE_API RRNamedBaseArray : public RRValue
2242{
2243 public:
2244 virtual DataTypes ElementArrayType() = 0;
2245
2246 virtual size_t ElementSize() = 0;
2247
2248 virtual size_t ElementArrayCount() = 0;
2249
2250 virtual RR_INTRUSIVE_PTR<RRBaseArray> GetNumericBaseArray() = 0;
2251
2252 virtual boost::string_ref RRElementTypeString() = 0;
2253};
2254
2269template <typename T>
2271{
2272 protected:
2273 RR_INTRUSIVE_PTR<RRArray<typename RRPrimUtil<T>::ElementArrayType> > rr_array;
2274
2275 public:
2288 RRNamedArray(const RR_INTRUSIVE_PTR<RRArray<typename RRPrimUtil<T>::ElementArrayType> >& rr_array)
2289 {
2290 if (!rr_array)
2291 throw NullValueException("Numeric array for namedarray must not be null");
2292 this->rr_array = rr_array;
2293 }
2294
2295 virtual DataTypes GetTypeID() { return RRPrimUtil<T>::GetTypeID(); }
2297 virtual size_t size() const { return rr_array->size() / (RRPrimUtil<T>::ElementArrayCount); }
2299 virtual size_t size() { return rr_array->size() / (RRPrimUtil<T>::ElementArrayCount); }
2301 virtual void* void_ptr() { return rr_array->void_ptr(); }
2303 RR_OVIRTUAL size_t ElementSize() RR_OVERRIDE { return sizeof(T); }
2305 RR_OVIRTUAL DataTypes ElementArrayType() RR_OVERRIDE { return RRPrimUtil<T>::GetElementArrayTypeID(); }
2307 RR_OVIRTUAL size_t ElementArrayCount() RR_OVERRIDE { return RRPrimUtil<T>::ElementArrayCount; }
2309 virtual RR_INTRUSIVE_PTR<RRArray<typename RRPrimUtil<T>::ElementArrayType> > GetNumericArray() { return rr_array; }
2311 RR_OVIRTUAL RR_INTRUSIVE_PTR<RRBaseArray> GetNumericBaseArray() RR_OVERRIDE { return rr_array; }
2312
2313 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRNamedArray"; }
2314
2315 RR_OVIRTUAL boost::string_ref RRElementTypeString() RR_OVERRIDE { return RRPrimUtil<T>::GetRRElementTypeString(); }
2316
2317 // C++ container support functions based on boost::array
2318
2319 // type definitions
2321 typedef T value_type;
2323 typedef T* iterator;
2325 typedef const T* const_iterator;
2327 typedef T& reference;
2329 typedef const T& const_reference;
2331 typedef std::size_t size_type;
2333 typedef std::ptrdiff_t difference_type;
2334
2335 // iterator support
2336
2338 iterator begin() { return static_cast<T*>(rr_array->begin()); }
2340 const_iterator begin() const { return static_cast<const T*>(rr_array->begin()); }
2342 const_iterator cbegin() const { return static_cast<const T*>(rr_array->begin()); }
2343
2345 iterator end() { return static_cast<T*>(rr_array->end()); }
2347 const_iterator end() const { return static_cast<T*>(rr_array->end()); }
2349 const_iterator cend() const { return static_cast<T*>(rr_array->end()); }
2350
2352 typedef boost::reverse_iterator<iterator> reverse_iterator;
2354 typedef boost::reverse_iterator<const_iterator> const_reverse_iterator;
2355
2362
2369
2372 {
2373 BOOST_ASSERT_MSG(i < size(), "out of range");
2374 return (static_cast<T*>(rr_array->void_ptr())[i]);
2375 }
2376
2379 {
2380 BOOST_ASSERT_MSG(i < size(), "out of range");
2381 return (static_cast<T*>(rr_array->void_ptr())[i]);
2382 }
2383
2386 {
2387 rangecheck(i);
2388 return (static_cast<T*>(rr_array->void_ptr())[i]);
2389 }
2390
2392 {
2393 rangecheck(i);
2394 (static_cast<T*>(rr_array->void_ptr())[i]);
2395 }
2396
2398 reference front() { return this->at(0); }
2400 const_reference front() const { return this->at(0); }
2401
2403 reference back() { return this->at(size() - 1); }
2405 const_reference back() const { return this->at(size() - 1); }
2406
2408 bool empty() { return rr_array->empty(); }
2410 size_type max_size() { return size(); }
2411
2412 void rangecheck(size_type i)
2413 {
2414 if (i >= size())
2415 {
2416 std::out_of_range e("array<>: index out of range");
2417 boost::throw_exception(e);
2418 }
2419 }
2420};
2421
2429class RRNamedBaseMultiDimArray : public RRValue
2430{
2431 public:
2432 RR_INTRUSIVE_PTR<RRArray<uint32_t> > Dims;
2433 virtual boost::string_ref RRElementTypeString() = 0;
2434};
2435
2455template <typename T>
2456class RRNamedMultiDimArray : public RRNamedBaseMultiDimArray
2457{
2458 public:
2459 typename RR_INTRUSIVE_PTR<RRNamedArray<T> > NamedArray;
2460
2461 RRNamedMultiDimArray() {}
2462
2463 RRNamedMultiDimArray(const RR_INTRUSIVE_PTR<RRArray<uint32_t> >& dims, const RR_INTRUSIVE_PTR<RRNamedArray<T> >& a)
2464 {
2465 this->Dims = dims;
2466 this->NamedArray = a;
2467 }
2468
2469 RR_OVIRTUAL ~RRNamedMultiDimArray() RR_OVERRIDE {}
2470
2471 RR_OVIRTUAL std::string RRType() RR_OVERRIDE { return "RobotRaconteur.RRNamedMultiDimArray"; }
2472
2473 RR_OVIRTUAL boost::string_ref RRElementTypeString() RR_OVERRIDE { return RRPrimUtil<T>::GetRRElementTypeString(); }
2474
2483 virtual void RetrieveSubArray(const std::vector<uint32_t>& memorypos,
2484 const RR_INTRUSIVE_PTR<RRNamedMultiDimArray<T> >& buffer,
2485 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
2486 {
2487
2488 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
2489 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
2490 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
2491 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
2492
2493 uint32_t len = 0;
2494 uint32_t indexa = 0;
2495 uint32_t indexb = 0;
2496
2497 while (iter->Next(indexa, indexb, len))
2498 {
2499 for (size_t i = 0; i < len; i++)
2500 {
2501 (*buffer->NamedArray)[(indexb + i)] = (*NamedArray)[(indexa + i)];
2502 }
2503 }
2504 }
2505
2514 virtual void AssignSubArray(const std::vector<uint32_t>& memorypos,
2515 const RR_INTRUSIVE_PTR<RRNamedMultiDimArray<T> >& buffer,
2516 const std::vector<uint32_t>& bufferpos, const std::vector<uint32_t>& count)
2517 {
2518
2519 std::vector<uint32_t> mema_dims = RRArrayToVector<uint32_t>(Dims);
2520 std::vector<uint32_t> memb_dims = RRArrayToVector<uint32_t>(buffer->Dims);
2521 RR_SHARED_PTR<detail::MultiDimArray_CalculateCopyIndicesIter> iter =
2522 detail::MultiDimArray_CalculateCopyIndicesBeginIter(mema_dims, memorypos, memb_dims, bufferpos, count);
2523
2524 uint32_t len = 0;
2525 uint32_t indexa = 0;
2526 uint32_t indexb = 0;
2527
2528 while (iter->Next(indexa, indexb, len))
2529 {
2530 for (size_t i = 0; i < len; i++)
2531 {
2532 (*NamedArray)[(indexa + i)] = (*buffer->NamedArray)[(indexb + i)];
2533 }
2534 }
2535 }
2536};
2537
2551template <typename T>
2552static RR_INTRUSIVE_PTR<RRNamedArray<T> > AllocateEmptyRRNamedArray(size_t length)
2553{
2554 typedef typename RRPrimUtil<T>::ElementArrayType a_type;
2555 RR_INTRUSIVE_PTR<RRArray<a_type> > a = AllocateEmptyRRArray<a_type>(length * RRPrimUtil<T>::GetElementArrayCount());
2556 return new RRNamedArray<T>(a); // NOLINT(cppcoreguidelines-owning-memory)
2557}
2558
2572template <typename T>
2573static RR_INTRUSIVE_PTR<RRNamedMultiDimArray<T> > AllocateEmptyRRNamedMultiDimArray(const std::vector<uint32_t>& dims)
2574{
2575 uint32_t n_elems = boost::accumulate(dims, 1, std::multiplies<uint32_t>());
2577}
2578
2589template <typename T>
2590static RR_INTRUSIVE_PTR<RRNamedMultiDimArray<T> > AllocateEmptyRRNamedMultiDimArray()
2591{
2592 std::vector<uint32_t> length;
2593 length.push_back(0);
2595}
2596
2607template <typename T>
2608static RR_INTRUSIVE_PTR<RRNamedArray<T> > ScalarToRRNamedArray(const T& value)
2609{
2610 RR_INTRUSIVE_PTR<RRNamedArray<T> > a = AllocateEmptyRRNamedArray<T>(1);
2611 (*a)[0] = value;
2612 return a;
2613}
2614
2625template <typename T>
2626static T RRNamedArrayToScalar(const RR_INTRUSIVE_PTR<RRNamedArray<T> >& value)
2627{
2628 if (!value)
2629 {
2630 throw NullValueException("Null pointer");
2631 }
2632
2633 if (value->size() == 0)
2634 throw OutOfRangeException("Index out of range");
2635
2636 return (*value)[0];
2637}
2638
2639#define RRPrimUtilEnum(x) \
2640 template <> \
2641 class RRPrimUtil<x> \
2642 { \
2643 public: \
2644 static DataTypes GetTypeID() { return DataTypes_enum_t; } \
2645 static MessageStringPtr GetElementTypeString() { return MessageStringPtr(""); } \
2646 static boost::string_ref GetRRElementTypeString() { return ""; } \
2647 static RR_INTRUSIVE_PTR<RRArray<int32_t> > PrePack(const x& val) { return ScalarToRRArray((int32_t)val); } \
2648 template <typename U> \
2649 static x PreUnpack(const U& val) \
2650 { \
2651 return (x)RRArrayToScalar(rr_cast<RRArray<int32_t> >(val)); \
2652 } \
2653 typedef RR_INTRUSIVE_PTR<RRArray<int32_t> > BoxedType; \
2654 };
2655
2656class ROBOTRACONTEUR_CORE_API RobotRaconteurNode;
2657
2667class ROBOTRACONTEUR_CORE_API TimeSpec
2668{
2669 public:
2671 int64_t seconds;
2674
2677
2684 TimeSpec(int64_t seconds, int32_t nanoseconds);
2685
2687 bool operator==(const TimeSpec& t2) const;
2689 bool operator!=(const TimeSpec& t2) const;
2691 TimeSpec operator-(const TimeSpec& t2) const;
2693 TimeSpec operator+(const TimeSpec& t2) const;
2695 bool operator>(const TimeSpec& t2) const;
2697 bool operator>=(const TimeSpec& t2) const;
2699 bool operator<(const TimeSpec& t2) const;
2701 bool operator<=(const TimeSpec& t2) const;
2702
2705};
2706
2713
2714boost::posix_time::ptime ROBOTRACONTEUR_CORE_API TimeSpecToPTime(const TimeSpec& ts);
2721TimeSpec ROBOTRACONTEUR_CORE_API ptimeToTimeSpec(const boost::posix_time::ptime& t);
2722
2723#ifdef ROBOTRACONTEUR_USE_SMALL_VECTOR
2724typedef boost::container::small_vector<boost::asio::const_buffer, 4> const_buffers;
2725typedef boost::container::small_vector<boost::asio::mutable_buffer, 4> mutable_buffers;
2726#else
2727typedef std::vector<boost::asio::const_buffer> const_buffers;
2728typedef std::vector<boost::asio::mutable_buffer> mutable_buffers;
2729#endif
2730
2731template <typename BufferSequence>
2732void buffers_consume(BufferSequence& b, size_t count)
2733{
2734 typename BufferSequence::iterator e = b.begin();
2735 ;
2736 typename BufferSequence::iterator end = b.end();
2737 for (; e != end;)
2738 {
2739 if (count > 0)
2740 {
2741 if (count > boost::asio::buffer_size(*e))
2742 {
2743 count -= boost::asio::buffer_size(*e);
2744 e = b.erase(e);
2745 }
2746 else
2747 {
2748 *e = *e + count;
2749 count = 0;
2750 ++e;
2751 }
2752 }
2753 else
2754 {
2755 break;
2756 }
2757 }
2758}
2759
2760template <typename BufferSequence>
2761BufferSequence buffers_consume_copy(BufferSequence& b, size_t count)
2762{
2763 BufferSequence o;
2764 typename BufferSequence::iterator e = b.begin();
2765 ;
2766 typename BufferSequence::iterator end = b.end();
2767 for (; e != end; e++)
2768 {
2769 if (count > 0)
2770 {
2771 if (count > boost::asio::buffer_size(*e))
2772 {
2773 count -= boost::asio::buffer_size(*e);
2774 }
2775 else
2776 {
2777 o.push_back(*e + count);
2778 count = 0;
2779 }
2780 }
2781 else
2782 {
2783 o.push_back(*e);
2784 }
2785 }
2786
2787 return o;
2788}
2789
2790template <typename BufferSequence>
2791BufferSequence buffers_consume_copy(const BufferSequence& b, size_t count)
2792{
2793 BufferSequence o;
2794 typename BufferSequence::const_iterator e = b.begin();
2795 ;
2796 typename BufferSequence::const_iterator end = b.end();
2797 for (; e != end; e++)
2798 {
2799 if (count > 0)
2800 {
2801 if (count > boost::asio::buffer_size(*e))
2802 {
2803 count -= boost::asio::buffer_size(*e);
2804 }
2805 else
2806 {
2807 o.push_back(*e + count);
2808 count = 0;
2809 }
2810 }
2811 else
2812 {
2813 o.push_back(*e);
2814 }
2815 }
2816
2817 return o;
2818}
2819
2820template <typename BufferSequence>
2821BufferSequence buffers_truncate(BufferSequence& b, size_t count)
2822{
2823 BufferSequence o;
2824 typename BufferSequence::iterator e = b.begin();
2825 ;
2826 typename BufferSequence::iterator end = b.end();
2827 size_t p = 0;
2828 for (; e != end; e++)
2829 {
2830 if (p + boost::asio::buffer_size(*e) <= count)
2831 {
2832 o.push_back(*e);
2833 p += boost::asio::buffer_size(*e);
2834 }
2835 else
2836 {
2837 o.push_back(boost::asio::buffer(*e, count - p));
2838 break;
2839 }
2840 }
2841
2842 return o;
2843}
2844
2845template <typename BufferSequence>
2846BufferSequence buffers_truncate(const BufferSequence& b, size_t count)
2847{
2848 BufferSequence o;
2849 typename BufferSequence::const_iterator e = b.begin();
2850 ;
2851 typename BufferSequence::const_iterator end = b.end();
2852 size_t p = 0;
2853 for (; e != end; e++)
2854 {
2855 if (p + boost::asio::buffer_size(*e) <= count)
2856 {
2857 o.push_back(*e);
2858 p += boost::asio::buffer_size(*e);
2859 }
2860 else
2861 {
2862 o.push_back(boost::asio::buffer(*e, count - p));
2863 break;
2864 }
2865 }
2866
2867 return o;
2868}
2869
2870/***
2871 * @brief Service path segment containing a name and an optional index
2872 */
2873struct ROBOTRACONTEUR_CORE_API ServicePathSegment
2874{
2875
2876 ServicePathSegment();
2877
2878 ServicePathSegment(const std::string& name,
2879 const boost::optional<std::string>& index = boost::optional<std::string>());
2880
2882 std::string name;
2884 boost::optional<std::string> index;
2885};
2886
2887ROBOTRACONTEUR_CORE_API bool operator==(const ServicePathSegment& lhs, const ServicePathSegment& rhs);
2888
2889ROBOTRACONTEUR_CORE_API bool operator!=(const ServicePathSegment& lhs, const ServicePathSegment& rhs);
2890
2897ROBOTRACONTEUR_CORE_API std::string EncodeServicePathIndex(const std::string& index);
2898
2905ROBOTRACONTEUR_CORE_API std::string DecodeServicePathIndex(const std::string& index);
2906
2913ROBOTRACONTEUR_CORE_API std::vector<ServicePathSegment> ParseServicePath(const std::string& path);
2914
2921ROBOTRACONTEUR_CORE_API std::string BuildServicePath(const std::vector<ServicePathSegment>& segments);
2922
2929ROBOTRACONTEUR_CORE_API bool IsStringName(boost::string_ref str);
2936ROBOTRACONTEUR_CORE_API bool IsStringScopedName(boost::string_ref str);
2943ROBOTRACONTEUR_CORE_API bool IsStringUUID(boost::string_ref str);
2950ROBOTRACONTEUR_CORE_API bool IsStringIdentifier(boost::string_ref str);
2951
2952namespace detail
2953{
2954ROBOTRACONTEUR_CORE_API std::string encode_index(boost::string_ref index);
2955
2956ROBOTRACONTEUR_CORE_API std::string decode_index(boost::string_ref index);
2957
2958template <typename T, typename U>
2959bool try_convert_string_to_number(const U& arg, T& result)
2960{
2961 if (boost::conversion::try_lexical_convert(arg, result))
2962 {
2963 return true;
2964 }
2965
2966 if (!boost::is_integral<T>::value)
2967 {
2968 return false;
2969 }
2970
2971 boost::regex hex_regex("^[+\\-]?0x[\\da-fA-F]+$");
2972 if (!boost::regex_match(arg.begin(), arg.end(), hex_regex))
2973 {
2974 return false;
2975 }
2976
2977 std::stringstream ss;
2978 ss << std::hex << arg;
2979 T v;
2980 ss >> v;
2981 if (ss.fail() || !ss.eof())
2982 {
2983 return false;
2984 }
2985
2986 result = v;
2987
2988 return true;
2989}
2990
2991} // namespace detail
2992
2993#ifndef ROBOTRACONTEUR_NO_CXX11_TEMPLATE_ALIASES
2995using RRObjectPtr = RR_SHARED_PTR<RRObject>;
2997using RRObjectConstPtr = RR_SHARED_PTR<const RRObject>;
2999using RRValuePtr = RR_INTRUSIVE_PTR<RRValue>;
3001using RRValueConstPtr = RR_INTRUSIVE_PTR<const RRValue>;
3003using MessageElementDataPtr = RR_INTRUSIVE_PTR<MessageElementData>;
3005using MessageElementDataConstPtr = RR_INTRUSIVE_PTR<const MessageElementData>;
3007using RRBaseArrayPtr = RR_INTRUSIVE_PTR<RRBaseArray>;
3009using RRBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRBaseArray>;
3011template <typename T>
3012using RRArrayPtr = RR_INTRUSIVE_PTR<RRArray<T> >;
3014template <typename T>
3015using RRArrayConstPtr = RR_INTRUSIVE_PTR<const RRArray<T> >;
3017template <typename K, typename T>
3018using RRMapPtr = RR_INTRUSIVE_PTR<RRMap<K, T> >;
3020template <typename K, typename T>
3021using RRMapConstPtr = RR_INTRUSIVE_PTR<const RRMap<K, T> >;
3023template <typename T>
3024using RRListPtr = RR_INTRUSIVE_PTR<RRList<T> >;
3026template <typename T>
3027using RRListConstPtr = RR_INTRUSIVE_PTR<const RRList<T> >;
3029using RRStructurePtr = RR_INTRUSIVE_PTR<RRStructure>;
3031using RRStructureConstPtr = RR_INTRUSIVE_PTR<const RRStructure>;
3033using RRMultiDimBaseArrayPtr = RR_INTRUSIVE_PTR<RRMultiDimBaseArray>;
3035using RRMultiDimBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRMultiDimBaseArray>;
3037template <typename T>
3038using RRMultiDimArrayPtr = RR_INTRUSIVE_PTR<RRMultiDimArray<T> >;
3040template <typename T>
3041using RRMultiDimArrayConstPtr = RR_INTRUSIVE_PTR<const RRMultiDimArray<T> >;
3043using RRPodBaseArrayPtr = RR_INTRUSIVE_PTR<RRPodBaseArray>;
3045using RRPodBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRPodBaseArray>;
3047template <typename T>
3048using RRPodArrayPtr = RR_INTRUSIVE_PTR<RRPodArray<T> >;
3050template <typename T>
3051using RRPodArrayConstPtr = RR_INTRUSIVE_PTR<const RRPodArray<T> >;
3053using RRPodBaseMultiDimArrayPtr = RR_INTRUSIVE_PTR<RRPodBaseMultiDimArray>;
3055using RRPodBaseMultiDimBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRPodBaseMultiDimArray>;
3057template <typename T>
3058using RRPodMultiDimArrayPtr = RR_INTRUSIVE_PTR<RRPodMultiDimArray<T> >;
3060template <typename T>
3061using RRPodMultiDimArrayConstPtr = RR_INTRUSIVE_PTR<const RRPodMultiDimArray<T> >;
3063using RRNamedBaseArrayPtr = RR_INTRUSIVE_PTR<RRNamedBaseArray>;
3065using RRNamedBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRNamedBaseArray>;
3067template <typename T>
3068using RRNamedArrayPtr = RR_INTRUSIVE_PTR<RRNamedArray<T> >;
3070template <typename T>
3071using RRNamedArrayConstPtr = RR_INTRUSIVE_PTR<const RRNamedArray<T> >;
3073using RRNamedBaseMultiDimArrayPtr = RR_INTRUSIVE_PTR<RRNamedBaseMultiDimArray>;
3075using RRNamedBaseMultiDimBaseArrayConstPtr = RR_INTRUSIVE_PTR<const RRNamedBaseMultiDimArray>;
3077template <typename T>
3078using RRNamedMultiDimArrayPtr = RR_INTRUSIVE_PTR<RRNamedMultiDimArray<T> >;
3080template <typename T>
3081using RRNamedMultiDimArrayConstPtr = RR_INTRUSIVE_PTR<const RRNamedMultiDimArray<T> >;
3082#endif
3083} // namespace RobotRaconteur
boost::intrusive_ptr< RRMap< K, T > > AllocateEmptyRRMap()
Allocate an empty RRMap.
Definition DataTypes.h:1829
static T RRNamedArrayToScalar(const boost::intrusive_ptr< RRNamedArray< T > > &value)
Convert a namedarray array with one element into a namedarray.
Definition DataTypes.h:2626
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:2171
static boost::intrusive_ptr< RRArray< Y > > VectorToRRArray(const std::vector< U > &in)
Convert a std::vector to an RRArray<Y>.
Definition DataTypes.h:1237
boost::shared_ptr< const RRObject > RRObjectConstPtr
Convenience alias for RRObject const shared_ptr.
Definition DataTypes.h:2997
boost::intrusive_ptr< RRList< T > > RRListPtr
Convenience alias for RRList intrusive_ptr.
Definition DataTypes.h:3024
boost::intrusive_ptr< RRPodBaseMultiDimArray > RRPodBaseMultiDimArrayPtr
Convenience alias for RRPodBaseMultiDimArray intrusive_ptr.
Definition DataTypes.h:3053
boost::intrusive_ptr< T > & rr_null_check(boost::intrusive_ptr< T > &ptr)
Checks if a value RR_INTRUSIVE_PTR is null.
Definition DataTypes.h:1423
static boost::intrusive_ptr< RRArray< Y > > ArrayToRRArray(boost::array< U, N > in)
Convert a boost::array to an RRArray.
Definition DataTypes.h:1305
static T RRArrayToScalar(const boost::intrusive_ptr< RRArray< T > > &value)
Convert an array with one element into a scalar.
Definition DataTypes.h:1188
boost::intrusive_ptr< RRMap< K, T > > RRMapPtr
Convenience alias for RRMap intrusive_ptr.
Definition DataTypes.h:3018
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:1101
boost::intrusive_ptr< const RRList< T > > RRListConstPtr
Convenience alias for RRList const intrusive_ptr.
Definition DataTypes.h:3027
boost::intrusive_ptr< RRPodBaseArray > RRPodBaseArrayPtr
Convenience alias for RRPodBaseArray intrusive_ptr.
Definition DataTypes.h:3043
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:3048
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:2190
static boost::intrusive_ptr< RRArray< T > > ScalarToRRArray(T value)
Convert a scalar number into an array with one element.
Definition DataTypes.h:1175
boost::intrusive_ptr< const MessageElementData > MessageElementDataConstPtr
Convenience alias for MessageElementData const intrusive_ptr.
Definition DataTypes.h:3005
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:3075
boost::intrusive_ptr< MessageElementData > MessageElementDataPtr
Convenience alias for MessageElementData intrusive_ptr.
Definition DataTypes.h:3003
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:2999
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:3061
static boost::intrusive_ptr< RRPodArray< T > > ScalarToRRPodArray(const T &value)
Convert a scalar pod into a pod array with one element.
Definition DataTypes.h:2131
boost::intrusive_ptr< RRList< T > > AllocateRRList(const U &c)
Allocate RRList with a value.
Definition DataTypes.h:1816
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:2144
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:3058
boost::intrusive_ptr< const RRPodArray< T > > RRPodArrayConstPtr
Convenience alias for RRPodArray const intrusive_ptr.
Definition DataTypes.h:3051
boost::intrusive_ptr< const RRPodBaseMultiDimArray > RRPodBaseMultiDimBaseArrayConstPtr
Convenience alias for RRPodBaseMultiDimArray const intrusive_ptr.
Definition DataTypes.h:3055
boost::intrusive_ptr< const RRNamedBaseArray > RRNamedBaseArrayConstPtr
Convenience alias for RRNamedBaseArray const intrusive_ptr.
Definition DataTypes.h:3065
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:1142
boost::shared_ptr< RRObject > RRObjectPtr
Convenience alias for RRObject shared_ptr.
Definition DataTypes.h:2995
boost::intrusive_ptr< RRNamedArray< T > > RRNamedArrayPtr
Convenience alias for RRNamedArray intrusive_ptr.
Definition DataTypes.h:3068
boost::intrusive_ptr< const RRMultiDimArray< T > > RRMultiDimArrayConstPtr
Convenience alias for RRMultiDimArray const intrusive_ptr.
Definition DataTypes.h:3041
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:2552
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:3033
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:1059
boost::intrusive_ptr< RRNamedBaseMultiDimArray > RRNamedBaseMultiDimArrayPtr
Convenience alias for RRNamedBaseMultiDimArray intrusive_ptr.
Definition DataTypes.h:3073
boost::intrusive_ptr< const RRArray< T > > RRArrayConstPtr
Convenience alias for RRArray const intrusive_ptr.
Definition DataTypes.h:3015
boost::intrusive_ptr< RRNamedMultiDimArray< T > > RRNamedMultiDimArrayPtr
Convenience alias for RRNamedMultiDimArray intrusive_ptr.
Definition DataTypes.h:3078
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:3035
boost::intrusive_ptr< RRArray< T > > RRArrayPtr
Convenience alias for RRArray intrusive_ptr.
Definition DataTypes.h:3012
boost::intrusive_ptr< RRStructure > RRStructurePtr
Convenience alias for RRStructure intrusive_ptr.
Definition DataTypes.h:3029
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:1789
static boost::intrusive_ptr< RRNamedArray< T > > ScalarToRRNamedArray(const T &value)
Convert a scalar namedarray into a namedarray array with one element.
Definition DataTypes.h:2608
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:3009
boost::intrusive_ptr< RRBaseArray > RRBaseArrayPtr
Convenience alias for RRBaseArray intrusive_ptr.
Definition DataTypes.h:3007
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:1083
boost::intrusive_ptr< RRMap< K, T > > AllocateRRMap(const U &c)
Allocate RRMap with value.
Definition DataTypes.h:1844
boost::intrusive_ptr< RRMultiDimArray< T > > RRMultiDimArrayPtr
Convenience alias for RRMultiDimArray intrusive_ptr.
Definition DataTypes.h:3038
boost::intrusive_ptr< const RRPodBaseArray > RRPodBaseArrayConstPtr
Convenience alias for RRPodBaseArray const intrusive_ptr.
Definition DataTypes.h:3045
boost::intrusive_ptr< const RRStructure > RRStructureConstPtr
Convenience alias for RRStructure const intrusive_ptr.
Definition DataTypes.h:3031
boost::intrusive_ptr< const RRValue > RRValueConstPtr
Convenience alias for RRValue const intrusive_ptr.
Definition DataTypes.h:3001
boost::intrusive_ptr< const RRMap< K, T > > RRMapConstPtr
Convenience alias for RRMap const intrusive_ptr.
Definition DataTypes.h:3021
boost::intrusive_ptr< const RRNamedMultiDimArray< T > > RRNamedMultiDimArrayConstPtr
Convenience alias for RRNamedMultiDimArray const intrusive_ptr.
Definition DataTypes.h:3081
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:3071
boost::intrusive_ptr< RRList< T > > AllocateEmptyRRList()
Allocate an empty RRList.
Definition DataTypes.h:1802
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:1328
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:2573
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:1215
static boost::array< Y, N > RRArrayToArray(const boost::intrusive_ptr< RRArray< U > > &in)
Convert an RRArray to a boost::array.
Definition DataTypes.h:1258
boost::intrusive_ptr< RRNamedBaseArray > RRNamedBaseArrayPtr
Convenience alias for RRNamedBaseArray intrusive_ptr.
Definition DataTypes.h:3063
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:1381
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:1758
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
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:581
std::ptrdiff_t difference_type
Definition DataTypes.h:617
RRArray< T > & operator=(const RRArray< T2 > &rhs)
assignment with type conversion
Definition DataTypes.h:713
T value_type
Definition DataTypes.h:605
reference operator[](size_type i)
access specified element
Definition DataTypes.h:655
reference back()
access the last element
Definition DataTypes.h:688
RR_OVIRTUAL size_t size() RR_OVERRIDE
Get the number of elements in the array.
Definition DataTypes.h:597
const_reverse_iterator rend() const
returns a reverse iterator to the end
Definition DataTypes.h:650
const_iterator cend() const
returns a const iterator to the end
Definition DataTypes.h:633
bool empty()
checks whether the container is empty
Definition DataTypes.h:694
const T & const_reference
Definition DataTypes.h:613
std::size_t size_type
Definition DataTypes.h:615
void fill(const T &value)
Fill array with value.
Definition DataTypes.h:732
const_reference at(size_type i) const
access specified element with bounds checking
Definition DataTypes.h:675
iterator begin()
returns an iterator to the beginning
Definition DataTypes.h:622
const_reverse_iterator crend() const
returns a reverse iterator to the end
Definition DataTypes.h:652
reverse_iterator rend()
returns a reverse iterator to the end
Definition DataTypes.h:648
iterator end()
returns an iterator to the end
Definition DataTypes.h:629
const_reference operator[](size_type i) const
access specified element
Definition DataTypes.h:662
size_type max_size()
returns the maximum possible number of elements
Definition DataTypes.h:696
reverse_iterator rbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:641
boost::reverse_iterator< const_iterator > const_reverse_iterator
Definition DataTypes.h:638
boost::reverse_iterator< iterator > reverse_iterator
Definition DataTypes.h:636
const_iterator end() const
returns an iterator to the end
Definition DataTypes.h:631
const_reverse_iterator rbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:643
T * data()
direct access to the underlying array
Definition DataTypes.h:701
const_reference back() const
access the last element
Definition DataTypes.h:691
reference front()
access the first element
Definition DataTypes.h:682
const T * const_iterator
Definition DataTypes.h:609
RR_OVIRTUAL void * void_ptr() RR_OVERRIDE
Get a void pointer to the contained array.
Definition DataTypes.h:593
T * iterator
Definition DataTypes.h:607
T & reference
Definition DataTypes.h:611
const_iterator cbegin() const
returns a const iterator to the beginning
Definition DataTypes.h:626
const_reverse_iterator crbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:645
const_reference front() const
access the first element
Definition DataTypes.h:685
const_iterator begin() const
returns an iterator to the beginning
Definition DataTypes.h:624
void assign(const T &value)
Assign one value to all elements.
Definition DataTypes.h:726
reference at(size_type i)
access specified element with bounds checking
Definition DataTypes.h:669
const T * data() const
direct access to the underlying array
Definition DataTypes.h:699
RR_OVIRTUAL size_t ElementSize() RR_OVERRIDE
Get the number of bytes per element of the array.
Definition DataTypes.h:599
Base class for numeric and character array value types.
Definition DataTypes.h:528
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:922
const_iterator begin() const
returns an iterator to the beginning
Definition DataTypes.h:963
std::list< boost::intrusive_ptr< T > >::const_iterator const_iterator
Definition DataTypes.h:954
std::list< boost::intrusive_ptr< T > > & GetStorageContainer()
Get the underlying storage container.
Definition DataTypes.h:1026
void pop_back()
removes the last element
Definition DataTypes.h:1007
std::list< boost::intrusive_ptr< T > >::reference reference
Definition DataTypes.h:944
std::list< boost::intrusive_ptr< T > >::iterator iterator
Definition DataTypes.h:952
std::list< boost::intrusive_ptr< T > >::reverse_iterator reverse_iterator
Definition DataTypes.h:956
std::list< boost::intrusive_ptr< T > >::const_pointer const_pointer
Definition DataTypes.h:942
iterator erase(const_iterator first, const_iterator last)
erases element
Definition DataTypes.h:1013
std::list< boost::intrusive_ptr< T > >::const_reverse_iterator const_reverse_iterator
Definition DataTypes.h:958
const_reverse_iterator const crend()
returns a reverse iterator to the end
Definition DataTypes.h:985
reference front()
access the first element
Definition DataTypes.h:993
std::list< boost::intrusive_ptr< T > >::size_type size_type
Definition DataTypes.h:948
void clear()
clears the contents
Definition DataTypes.h:1015
size_type max_size() const
returns the maximum possible number of elements
Definition DataTypes.h:991
const_reverse_iterator crend() const
returns a reverse iterator to the end
Definition DataTypes.h:975
iterator insert(const_iterator p, const boost::intrusive_ptr< T > &x)
inserts element
Definition DataTypes.h:1009
std::list< boost::intrusive_ptr< T > >::pointer pointer
Definition DataTypes.h:940
const_reference back() const
access the last element
Definition DataTypes.h:999
std::list< boost::intrusive_ptr< T > >::difference_type difference_type
Definition DataTypes.h:950
const_reference front() const
access the first element
Definition DataTypes.h:995
void push_front(const boost::intrusive_ptr< T > &x)
inserts an element at the beginning
Definition DataTypes.h:1001
reference back()
access the last element
Definition DataTypes.h:997
void remove(const boost::intrusive_ptr< T > &value)
removes elements equal to value
Definition DataTypes.h:1017
reverse_iterator rbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:969
void push_back(const boost::intrusive_ptr< T > &x)
adds an element to the end
Definition DataTypes.h:1003
const_iterator cend() const
returns an iterator to the end
Definition DataTypes.h:981
const_reverse_iterator const crbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:983
iterator begin()
returns an iterator to the beginning
Definition DataTypes.h:961
const_reverse_iterator rend() const
returns a reverse iterator to the end
Definition DataTypes.h:977
bool empty() const
checks whether the container is empty
Definition DataTypes.h:987
boost::intrusive_ptr< T > value_type
Definition DataTypes.h:938
void pop_front()
removes the first element
Definition DataTypes.h:1005
virtual size_type size() const
returns the number of elements
Definition DataTypes.h:989
const_iterator end() const
returns an iterator to the end
Definition DataTypes.h:967
const_reverse_iterator rbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:971
std::list< boost::intrusive_ptr< T > >::const_reference const_reference
Definition DataTypes.h:946
const_iterator cbegin() const
returns an iterator to the beginning
Definition DataTypes.h:979
reverse_iterator rend()
returns a reverse iterator to the end
Definition DataTypes.h:973
iterator erase(const_iterator p)
erases element
Definition DataTypes.h:1011
iterator end()
returns an iterator to the end
Definition DataTypes.h:965
Map container value type.
Definition DataTypes.h:796
void erase(iterator p)
erases element
Definition DataTypes.h:887
std::pair< iterator, bool > insert(const value_type &x)
inserts elements
Definition DataTypes.h:873
iterator end()
returns an iterator to the end
Definition DataTypes.h:843
std::map< K, boost::intrusive_ptr< T > >::value_type value_type
Definition DataTypes.h:816
std::map< K, boost::intrusive_ptr< T > >::key_type key_type
Definition DataTypes.h:812
const_reverse_iterator rbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:853
const_iterator begin() const
returns an iterator to the beginning
Definition DataTypes.h:841
const_reverse_iterator crbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:851
mapped_type & operator[](const key_type &k)
access or insert the specified element
Definition DataTypes.h:867
std::map< K, boost::intrusive_ptr< T > > & GetStorageContainer()
Get the underlying storage container.
Definition DataTypes.h:908
std::map< K, boost::intrusive_ptr< T > >::const_iterator const_iterator
Definition DataTypes.h:830
const_reverse_iterator crend() const
returns a reverse iterator to the end
Definition DataTypes.h:857
size_type size() const
returns the number of elements
Definition DataTypes.h:863
const_iterator find(const key_type &x) const
finds element with the specified key
Definition DataTypes.h:897
bool empty() const
checks whether the container is empty
Definition DataTypes.h:861
iterator find(const key_type &x)
finds element with the specified key
Definition DataTypes.h:895
void erase(iterator first, iterator last)
erases element
Definition DataTypes.h:891
std::map< K, boost::intrusive_ptr< T > >::const_reverse_iterator const_reverse_iterator
Definition DataTypes.h:834
const mapped_type & at(const key_type &k) const
access specified element with bounds checking
Definition DataTypes.h:871
std::map< K, boost::intrusive_ptr< T > >::pointer pointer
Definition DataTypes.h:818
size_type count(const key_type &x) const
returns the number of elemnts matching the specified key
Definition DataTypes.h:899
reverse_iterator rend()
returns a reverse iterator to the end
Definition DataTypes.h:855
std::map< K, boost::intrusive_ptr< T > >::iterator iterator
Definition DataTypes.h:828
mapped_type & at(const key_type &k)
access specified element with bounds checking
Definition DataTypes.h:869
const_iterator end() const
returns an iterator to the end
Definition DataTypes.h:847
void clear()
clears the contents
Definition DataTypes.h:893
std::map< K, boost::intrusive_ptr< T > >::reverse_iterator reverse_iterator
Definition DataTypes.h:832
std::map< K, boost::intrusive_ptr< T > >::mapped_type mapped_type
Definition DataTypes.h:814
std::map< K, boost::intrusive_ptr< T > >::reference reference
Definition DataTypes.h:822
const_iterator cend() const
returns an iterator to the end
Definition DataTypes.h:845
size_type max_size() const
returns the maximum possible number of elements
Definition DataTypes.h:865
std::map< K, boost::intrusive_ptr< T > >::const_reference const_reference
Definition DataTypes.h:824
iterator begin()
returns an iterator to the beginning
Definition DataTypes.h:837
iterator insert(const_iterator p, const value_type &x)
inserts elements
Definition DataTypes.h:875
const_reverse_iterator rend() const
returns a reverse iterator to the end
Definition DataTypes.h:859
const_iterator cbegin() const
returns an iterator to the beginning
Definition DataTypes.h:839
std::map< K, boost::intrusive_ptr< T > >::const_pointer const_pointer
Definition DataTypes.h:820
std::map< K, boost::intrusive_ptr< T > >::size_type size_type
Definition DataTypes.h:826
size_type erase(const key_type &x)
erases element
Definition DataTypes.h:889
void insert(InputIterator first, InputIterator last)
inserts elements
Definition DataTypes.h:882
reverse_iterator rbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:849
Numeric primitive multidimensional array value type.
Definition DataTypes.h:1602
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:1658
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:1630
Base class for numeric multidimensional arrays.
Definition DataTypes.h:1555
namedarray array value type
Definition DataTypes.h:2271
iterator end()
returns an iterator to the end
Definition DataTypes.h:2345
T & reference
Definition DataTypes.h:2327
const_iterator end() const
returns an iterator to the end
Definition DataTypes.h:2347
const_reverse_iterator crend() const
returns a reverse iterator to the end
Definition DataTypes.h:2368
reverse_iterator rbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:2357
virtual size_t size() const
returns the number of elements (namedarray elements)
Definition DataTypes.h:2297
RR_OVIRTUAL boost::intrusive_ptr< RRBaseArray > GetNumericBaseArray() RR_OVERRIDE
get the underlying numeric array as an RRBaseArray
Definition DataTypes.h:2311
const_reference front() const
access the first element
Definition DataTypes.h:2400
bool empty()
checks whether the container is empty
Definition DataTypes.h:2408
virtual size_t size()
returns the number of elements (namedarray elements)
Definition DataTypes.h:2299
const_reference at(size_type i) const
access specified namedarray element with bounds checking
Definition DataTypes.h:2391
const_iterator cbegin() const
returns an iterator to the beginning
Definition DataTypes.h:2342
reference back()
access the last element
Definition DataTypes.h:2403
std::size_t size_type
Definition DataTypes.h:2331
const T & const_reference
Definition DataTypes.h:2329
RR_OVIRTUAL DataTypes ElementArrayType() RR_OVERRIDE
get the type of the underlying numeric array
Definition DataTypes.h:2305
const_reference operator[](size_type i) const
access specified namedarray element
Definition DataTypes.h:2378
iterator begin()
returns an iterator to the beginning
Definition DataTypes.h:2338
std::ptrdiff_t difference_type
Definition DataTypes.h:2333
reference front()
access the first element
Definition DataTypes.h:2398
RR_OVIRTUAL size_t ElementSize() RR_OVERRIDE
get the number of bytes per namedarray element of the array
Definition DataTypes.h:2303
const_reverse_iterator rbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:2359
const_iterator begin() const
returns an iterator to the beginning
Definition DataTypes.h:2340
RR_OVIRTUAL size_t ElementArrayCount() RR_OVERRIDE
get the total number of elements in the underlying numeric array
Definition DataTypes.h:2307
RRNamedArray(const boost::intrusive_ptr< RRArray< typename RRPrimUtil< T >::ElementArrayType > > &rr_array)
Construct a RRNamedArray object.
Definition DataTypes.h:2288
const_reverse_iterator crbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:2361
const_reference back() const
access the last element
Definition DataTypes.h:2405
virtual boost::intrusive_ptr< RRArray< typename RRPrimUtil< T >::ElementArrayType > > GetNumericArray()
get the underlying numeric RRArray
Definition DataTypes.h:2309
reverse_iterator rend()
returns a reverse iterator to the end
Definition DataTypes.h:2364
size_type max_size()
returns the maximum possible number of elements
Definition DataTypes.h:2410
reference operator[](size_type i)
access specified namedarray element
Definition DataTypes.h:2371
const_reverse_iterator rend() const
returns a reverse iterator to the end
Definition DataTypes.h:2366
T * iterator
Definition DataTypes.h:2323
T value_type
Definition DataTypes.h:2321
boost::reverse_iterator< const_iterator > const_reverse_iterator
Definition DataTypes.h:2354
const_iterator cend() const
returns an iterator to the end
Definition DataTypes.h:2349
const T * const_iterator
Definition DataTypes.h:2325
reference at(size_type i)
access specified namedarray element with bounds checking
Definition DataTypes.h:2385
boost::reverse_iterator< iterator > reverse_iterator
Definition DataTypes.h:2352
virtual void * void_ptr()
get a void pointer to the underlying numeric array
Definition DataTypes.h:2301
Base class for namedarray array value types.
Definition DataTypes.h:2242
Base class for namedarray multidimensional arrays.
Definition DataTypes.h:2430
namedarray multidimensional array value type
Definition DataTypes.h:2457
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:2514
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:2483
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:1889
std::vector< T >::iterator iterator
Definition DataTypes.h:1921
size_type max_size() const
returns the maximum possible number of elements
Definition DataTypes.h:1958
reference front()
access the first element
Definition DataTypes.h:1960
const_reverse_iterator rbegin() const
returns a reverse iterator to the beginning
Definition DataTypes.h:1940
T * data()
direct access to the underlying array
Definition DataTypes.h:1976
const_reference at(size_type i) const
access the specified element with bounds checking
Definition DataTypes.h:1974
std::vector< T >::const_reverse_iterator const_reverse_iterator
Definition DataTypes.h:1927
std::vector< T >::const_reference const_reference
Definition DataTypes.h:1917
reference operator[](size_type i)
access the specified element
Definition DataTypes.h:1968
const_iterator cend() const
returns an iterator to the end
Definition DataTypes.h:1948
const_reference operator[](size_type i) const
access the specified element
Definition DataTypes.h:1970
const_reverse_iterator const crend()
returns a reverse iterator to the end
Definition DataTypes.h:1952
const_reverse_iterator const crbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:1950
T value_type
Definition DataTypes.h:1909
iterator begin()
returns an iterator to the beginning
Definition DataTypes.h:1930
const_reference back() const
access the last element
Definition DataTypes.h:1966
std::vector< T > & GetStorageContainer()
Get the underlying storage container.
Definition DataTypes.h:1987
reverse_iterator rend()
returns a reverse iterator to the end
Definition DataTypes.h:1942
const_iterator cbegin() const
returns an iterator to the beginning
Definition DataTypes.h:1946
const_iterator end() const
returns an iterator to the end
Definition DataTypes.h:1936
std::vector< T >::reference reference
Definition DataTypes.h:1915
reference back()
access the last element
Definition DataTypes.h:1964
std::vector< T >::const_iterator const_iterator
Definition DataTypes.h:1923
const T * data() const
direct access to the underlying array
Definition DataTypes.h:1978
const_reference front() const
access the first element
Definition DataTypes.h:1962
std::vector< T >::size_type size_type
Definition DataTypes.h:1919
virtual size_type size() const
returns the number of elements
Definition DataTypes.h:1956
iterator end()
returns an iterator to the end
Definition DataTypes.h:1934
reference at(size_type i)
access the specified element with bounds checking
Definition DataTypes.h:1972
const_iterator begin() const
retuns an iterator to the beginning
Definition DataTypes.h:1932
reverse_iterator rbegin()
returns a reverse iterator to the beginning
Definition DataTypes.h:1938
bool empty() const
checks whether the container is empty
Definition DataTypes.h:1954
std::vector< T >::pointer pointer
Definition DataTypes.h:1911
std::vector< T >::reverse_iterator reverse_iterator
Definition DataTypes.h:1925
const_reverse_iterator rend() const
returns a reverse iterator to the end
Definition DataTypes.h:1944
std::vector< T >::const_pointer const_pointer
Definition DataTypes.h:1913
Base class for pod array value types.
Definition DataTypes.h:1868
Base class for pod multidimensional arrays.
Definition DataTypes.h:2015
Base class for user defined pod value types.
Definition DataTypes.h:1857
pod multidimensional array value type
Definition DataTypes.h:2042
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:2099
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:2068
Base class for user defined structure value types.
Definition DataTypes.h:1038
Represents. a point in time. Used by wire members to timestamp packets.
Definition DataTypes.h:2668
bool operator==(const TimeSpec &t2) const
equality comparison
int64_t seconds
Seconds since epoch.
Definition DataTypes.h:2671
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:2673
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