This is Unofficial EPICS BASE Doxygen Site
sharedVector.h
Go to the documentation of this file.
1 /* sharedVector.h */
2 /*
3  * Copyright information and license terms for this software can be
4  * found in the file LICENSE that is included with the distribution
5  */
6 #ifndef SHAREDVECTOR_H
7 #define SHAREDVECTOR_H
8 
9 #include <ostream>
10 #include <algorithm>
11 #include <stdexcept>
12 #include <iterator>
13 
14 #if __cplusplus>=201103L
15 # include <initializer_list>
16 #endif
17 
18 #include <cassert>
19 
20 #include "pv/sharedPtr.h"
21 #include "pv/pvIntrospect.h"
22 #include "pv/typeCast.h"
23 #include "pv/templateMeta.h"
24 
25 namespace epics { namespace pvData {
26 
27 template<typename E, class Enable = void> class shared_vector;
28 
29 template<typename TO, typename FROM>
30 static FORCE_INLINE
32 const_shared_vector_cast(shared_vector<FROM>& src);
33 
34 namespace detail {
35  template<typename E>
36  struct default_array_deleter {void operator()(E a){delete[] a;}};
37 
38  // How values should be passed as arguments to shared_vector methods
39  // really should use boost::call_traits
40  template<typename T> struct call_with { typedef T type; };
41  template<typename T> struct call_with<std::tr1::shared_ptr<T> >
42  { typedef const std::tr1::shared_ptr<T>& type; };
43  template<> struct call_with<std::string> { typedef const std::string& type; };
44 
48 
49  /* All the parts of shared_vector which
50  * don't need special handling for E=void
51  */
52  template<typename E>
54  {
55  // allow specialization for all E to be friends
56  template<typename E1> friend class shared_vector_base;
57  protected:
58  // NOTE: Do no use m_data, since VxWorks has a 'm_data' macro defined
59  std::tr1::shared_ptr<E> m_sdata;
61  size_t m_offset;
63  size_t m_count;
65  size_t m_total;
66 
67  /* invariants
68  * m_count <= m_total (enforced)
69  * m_offset + m_total <= (size_t)-1 (checked w/ assert())
70  */
71 
72  public:
73 #if __cplusplus>=201103L
74  constexpr shared_vector_base() noexcept
76  :m_sdata(), m_offset(0), m_count(0), m_total(0)
77  {}
78 #else
81  :m_sdata(), m_offset(0), m_count(0), m_total(0)
82  {}
83 #endif
84 
85  protected:
86  // helper for constructors
87  // Ensure that offset and size are zero when we are constructed with NULL
88  void _null_input()
89  {
90  if(!m_sdata) {
91  m_offset = m_total = m_count = 0;
92  } else {
93  // ensure we won't have integer overflows later
94  assert( m_offset <= ((size_t)-1) - m_total);
95  }
96  }
97  public:
98 
99  template<typename A>
100  shared_vector_base(A* v, size_t o, size_t c)
101  :m_sdata(v, detail::default_array_deleter<A*>())
102  ,m_offset(o), m_count(c), m_total(c)
103  {_null_input();}
104 
105  shared_vector_base(const std::tr1::shared_ptr<E>& d, size_t o, size_t c)
106  :m_sdata(d), m_offset(o), m_count(c), m_total(c)
107  {_null_input();}
108 
109 
110  template<typename A, typename B>
111  shared_vector_base(A d, B b, size_t o, size_t c)
112  :m_sdata(d,b), m_offset(o), m_count(c), m_total(c)
113  {_null_input();}
114 
116  :m_sdata(O.m_sdata), m_offset(O.m_offset)
117  ,m_count(O.m_count), m_total(O.m_total)
118  {}
119 
120 #if __cplusplus >= 201103L
122  :m_sdata(std::move(O.m_sdata))
123  ,m_offset(O.m_offset)
124  ,m_count(O.m_count)
125  ,m_total(O.m_total)
126  {
127  O.clear();
128  }
129 #endif
130 
131  protected:
133  public:
138  :m_sdata()
139  ,m_offset(O.m_offset)
140  ,m_count(O.m_count)
141  ,m_total(O.m_total)
142  {
143  if(!O.unique())
144  throw std::runtime_error("Can't freeze non-unique vector");
145 #if __cplusplus >= 201103L
146  m_sdata = std::move(O.m_sdata);
147 #else
148  m_sdata = O.m_sdata;
149 #endif
150  O.clear();
151  }
152 
157  :m_sdata()
158  ,m_offset(O.m_offset)
159  ,m_count(O.m_count)
160  ,m_total(O.m_total)
161  {
162  O.make_unique();
163 #if __cplusplus >= 201103L
164  m_sdata = std::move(std::tr1::const_pointer_cast<E>(O.m_sdata));
165 #else
166  m_sdata = std::tr1::const_pointer_cast<E>(O.m_sdata);
167 #endif
168  O.clear();
169  }
170 
173  {
174  if(&o!=this) {
175  m_sdata=o.m_sdata;
176  m_offset=o.m_offset;
177  m_count=o.m_count;
178  m_total=o.m_total;
179  }
180  return *this;
181  }
182 
183 #if __cplusplus >= 201103L
184  shared_vector_base& operator=(shared_vector_base&& o)
186  {
187  if(&o!=this) {
188  m_sdata=std::move(o.m_sdata);
189  m_offset=o.m_offset;
190  m_count=o.m_count;
191  m_total=o.m_total;
192  o.clear();
193  }
194  return *this;
195  }
196 #endif
197 
200  if(&o!=this) {
201  m_sdata.swap(o.m_sdata);
202  std::swap(m_count, o.m_count);
203  std::swap(m_offset, o.m_offset);
204  std::swap(m_total, o.m_total);
205  }
206  }
207 
210  void clear() {
211  m_sdata.reset();
212  m_offset = m_total = m_count = 0;
213  }
214 
216  bool unique() const {return !m_sdata || m_sdata.use_count()<=1;}
217 
218 
220  size_t size() const{return m_count;}
222  bool empty() const{return !m_count;}
223 
224 
244  void slice(size_t offset, size_t length=(size_t)-1)
245  {
246  if(offset>m_count)
247  offset = m_count; // will slice down to zero length
248 
249  const size_t max_count = m_count - offset;
250 
251  m_offset += offset;
252 
253  m_total -= offset;
254 
255  if(length > max_count)
256  length = max_count;
257  m_count = length;
258  }
259 
260  // Access to members.
261  const std::tr1::shared_ptr<E>& dataPtr() const { return m_sdata; }
262  size_t dataOffset() const { return m_offset; }
263  size_t dataCount() const { return m_count; }
264  size_t dataTotal() const { return m_total; }
265  };
266 }
267 
286 template<typename E, class Enable>
288 {
289  typedef detail::shared_vector_base<E> base_t;
290  typedef typename detail::call_with<E>::type param_type;
291  typedef typename meta::strip_const<E>::type _E_non_const;
292 public:
293  typedef E value_type;
294  typedef E& reference;
296  typedef E* pointer;
298  typedef E* iterator;
299  typedef std::reverse_iterator<iterator> reverse_iterator;
301  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
302  typedef ptrdiff_t difference_type;
303  typedef size_t size_type;
304 
305  typedef E element_type;
306  typedef std::tr1::shared_ptr<E> shared_pointer_type;
307 
308  // allow specialization for all E to be friends
309  template<typename E1, class Enable1> friend class shared_vector;
310 
312 #if __cplusplus>=201103L
313  constexpr shared_vector() noexcept :base_t() {}
314 #else
315  shared_vector() :base_t() {}
316 #endif
317 
318 #if __cplusplus>=201103L
319  template<typename A>
320  shared_vector(std::initializer_list<A> L)
321  :base_t(new _E_non_const[L.size()], 0, L.size())
322  {
323  _E_non_const *raw = const_cast<_E_non_const*>(data());
324  std::copy(L.begin(), L.end(), raw);
325  }
326 #endif
327 
329  explicit shared_vector(size_t c)
330  :base_t(new _E_non_const[c], 0, c)
331  {}
332 
334  shared_vector(size_t c, param_type e)
335  :base_t(new _E_non_const[c], 0, c)
336  {
337  std::fill_n((_E_non_const*)this->m_sdata.get(), this->m_count, e);
338  }
339 
346  template<typename A>
347  shared_vector(A v, size_t o, size_t c) :base_t(v,o,c) {}
348 
355  template<typename E1>
356  shared_vector(const std::tr1::shared_ptr<E1>& d, size_t o, size_t c)
357  :base_t(d,o,c) {}
358 
366  template<typename A, typename B>
367  shared_vector(A d, B b, size_t o, size_t c)
368  :base_t(d,b,o,c) {}
369 
371  shared_vector(const shared_vector& o) :base_t(o) {}
372 
373 #if __cplusplus>=201103L
374  shared_vector(shared_vector&& o) :base_t(std::move(o)) {}
376 #endif
377 
380  template<typename FROM>
383  :base_t(std::tr1::static_pointer_cast<E>(src.dataPtr()),
384  src.dataOffset()/sizeof(E),
385  src.dataCount()/sizeof(E))
386  {}
387 
388 
391  :base_t(O,t)
392  {}
393 
396  :base_t(O,t)
397  {}
398 
400  {
401  this->base_t::operator=(o);
402  return *this;
403  }
404 
405 #if __cplusplus>=201103L
406  inline shared_vector& operator=(shared_vector&& o)
407  {
408  this->base_t::operator=(std::move(o));
409  return *this;
410  }
411 #endif
412 
413  size_t max_size() const{return ((size_t)-1)/sizeof(E);}
414 
415  size_t capacity() const { return this->m_total; }
416 
428  void reserve(size_t i) {
429  if(this->unique() && i<=this->m_total)
430  return;
431  size_t new_count = this->m_count;
432  if(new_count > i)
433  new_count = i;
434  _E_non_const* temp=new _E_non_const[i];
435  try{
436  std::copy(begin(), begin()+new_count, temp);
437  this->m_sdata.reset(temp, detail::default_array_deleter<E*>());
438  }catch(...){
439  delete[] temp;
440  throw;
441  }
442  this->m_offset = 0;
443  this->m_count = new_count;
444  this->m_total = i;
445  }
446 
457  void resize(size_t i) {
458  if(i==this->m_count) {
459  make_unique();
460  return;
461  }
462  if(this->m_sdata && this->m_sdata.use_count()==1) {
463  // we have data and exclusive ownership of it
464  if(i<=this->m_total) {
465  // We have room to grow (or shrink)!
466  this->m_count = i;
467  return;
468  }
469  }
470  // must re-allocate :(
471  size_t new_total = this->m_total;
472  if(new_total < i)
473  new_total = i;
474  _E_non_const* temp=new _E_non_const[new_total];
475  try{
476  size_t n = this->size();
477  if(n > i)
478  n = i;
479  // Copy as much as possible from old,
480  // remaining elements are uninitialized.
481  std::copy(begin(),
482  begin()+n,
483  temp);
484  this->m_sdata.reset(temp, detail::default_array_deleter<pointer>());
485  }catch(...){
486  delete[] temp;
487  throw;
488  }
489  this->m_offset= 0;
490  this->m_count = i;
491  this->m_total = new_total;
492  }
493 
498  void resize(size_t i, param_type v) {
499  size_t oldsize=this->size();
500  resize(i);
501  if(this->size()>oldsize) {
502  std::fill(begin()+oldsize, end(), v);
503  }
504  }
505 
526  void make_unique() {
527  if(this->unique())
528  return;
529  // at this point we know that !!m_sdata, so get()!=NULL
530  _E_non_const *d = new _E_non_const[this->m_total];
531  try {
532  std::copy(this->m_sdata.get()+this->m_offset,
533  this->m_sdata.get()+this->m_offset+this->m_count,
534  d);
535  }catch(...){
536  delete[] d;
537  throw;
538  }
539  this->m_sdata.reset(d, detail::default_array_deleter<E*>());
540  this->m_offset=0;
541  }
542 
543 private:
544  /* Hack alert.
545  * For reasons of simplicity and efficiency, we want to use raw pointers for iteration.
546  * However, shared_ptr::get() isn't defined when !m_sdata, although practically it gives NULL.
547  * Unfortunately, many of the MSVC (<= VS 2010) STL methods assert() that iterators are never NULL.
548  * So we fudge here by abusing 'this' so that our iterators are always !NULL.
549  */
550  inline E* base_ptr() const {
551 #if defined(_MSC_VER) && _MSC_VER<=1600
552  return this->m_count ? this->m_sdata.get() : (E*)(this-1);
553 #else
554  return this->m_sdata.get();
555 #endif
556  }
557 public:
558  // STL iterators
559 
560  iterator begin() const{return this->base_ptr()+this->m_offset;}
561  const_iterator cbegin() const{return begin();}
562 
563  iterator end() const{return this->base_ptr()+this->m_offset+this->m_count;}
564  const_iterator cend() const{return end();}
565 
566  reverse_iterator rbegin() const{return reverse_iterator(end());}
567  const_reverse_iterator crbegin() const{return rbegin();}
568 
569  reverse_iterator rend() const{return reverse_iterator(begin());}
570  const_reverse_iterator crend() const{return rend();}
571 
572  reference front() const{return (*this)[0];}
573  reference back() const{return (*this)[this->m_count-1];}
574 
575  // Modifications
576 
577 private:
578  void _push_resize() {
579  if(this->m_count==this->m_total || !this->unique()) {
580  size_t next;
581  if(this->m_total<1024) {
582  // round m_total+1 up to the next power of 2
583  next = this->m_total;
584  next |= next >> 1;
585  next |= next >> 2;
586  next |= next >> 4;
587  next |= next >> 8;
588  next++;
589  } else {
590  // pad m_total up to the next multiple of 1024
591  next = this->m_total+1024;
592  next &= ~0x3ff;
593  }
594  assert(next > this->m_total);
595  reserve(next);
596  }
597  resize(this->size()+1);
598  }
599 
600 public:
601 
602  void push_back(param_type v)
603  {
604  _push_resize();
605  back() = v;
606  }
607 
608  void pop_back()
609  {
610  this->slice(0, this->size()-1);
611  }
612 
613  // data access
614 
616  pointer data() const{return this->m_sdata.get()+this->m_offset;}
617 
620  reference operator[](size_t i) const {return this->m_sdata.get()[this->m_offset+i];}
621 
624  reference at(size_t i) const
625  {
626  if(i>this->m_count)
627  throw std::out_of_range("Index out of bounds");
628  return (*this)[i];
629  }
630 
631 };
632 
653 template<typename E>
654 class shared_vector<E, typename meta::is_void<E>::type >
655  : public detail::shared_vector_base<E>
656 {
658  ScalarType m_vtype;
659 
660  // allow specialization for all E to be friends
661  template<typename E1, class Enable1> friend class shared_vector;
662 public:
663  typedef E value_type;
664  typedef E* pointer;
665  typedef ptrdiff_t difference_type;
666  typedef size_t size_type;
667 
668  typedef std::tr1::shared_ptr<E> shared_pointer_type;
669 
670 #if __cplusplus>=201103L
671  constexpr shared_vector() noexcept :base_t(), m_vtype((ScalarType)-1) {}
672 #else
673  shared_vector() :base_t(), m_vtype((ScalarType)-1) {}
674 #endif
675 
676  shared_vector(pointer v, size_t o, size_t c)
677  :base_t(v,o,c), m_vtype((ScalarType)-1) {}
678 
679  template<typename B>
680  shared_vector(pointer d, B b, size_t o, size_t c)
681  :base_t(d,b,o,c), m_vtype((ScalarType)-1) {}
682 
683  template<typename E1>
684  shared_vector(const std::tr1::shared_ptr<E1>& d, size_t o, size_t c)
685  :base_t(d,o,c), m_vtype((ScalarType)-1) {}
686 
688  :base_t(o), m_vtype(o.m_vtype) {}
689 
690 #if __cplusplus>=201103L
692  :base_t(std::move(o)), m_vtype(o.m_vtype) {}
693 #endif
694 
697  template<typename FROM>
700  :base_t(std::tr1::static_pointer_cast<E>(src.dataPtr()),
701  src.dataOffset()*sizeof(FROM),
702  src.dataCount()*sizeof(FROM))
703  ,m_vtype((ScalarType)ScalarTypeID<FROM>::value)
704  {}
705 
708  :base_t(O,t), m_vtype(O.m_vtype)
709  {}
710 
713  :base_t(O,t), m_vtype(O.m_vtype)
714  {}
715 
717  {
718  if(&o!=this) {
719  this->base_t::operator=(o);
720  m_vtype = o.m_vtype;
721  }
722  return *this;
723  }
724 
725 #if __cplusplus>=201103L
726  shared_vector& operator=(shared_vector&& o)
727  {
728  if(&o!=this) {
729  this->base_t::operator=(std::move(o));
730  m_vtype = o.m_vtype;
731  }
732  return *this;
733  }
734 #endif
735 
736  void swap(shared_vector& o) {
737  base_t::swap(o);
738  std::swap(m_vtype, o.m_vtype);
739  }
740 
741  size_t max_size() const{return (size_t)-1;}
742 
743  pointer data() const{
744  return (pointer)(((char*)this->m_sdata.get())+this->m_offset);
745  }
746 
747  shared_vector& set_original_type(ScalarType t) { m_vtype=t; return *this; }
748  ScalarType original_type() const {return m_vtype;}
749 };
750 
751 namespace detail {
752  template<typename TO, typename FROM, class Enable = void>
753  struct static_shared_vector_caster { /* no default */ };
754  // from void to non-void with same const-ness
755  template<typename TO, typename FROM>
757  typename meta::_and<meta::_and<meta::is_not_void<TO>, meta::is_void<FROM> >,
758  meta::same_const<TO,FROM> >::type> {
759  static inline shared_vector<TO> op(const shared_vector<FROM>& src) {
761  }
762  };
763  // from non-void to void with same const-ness
764  template<typename TO, typename FROM>
766  typename meta::_and<meta::_and<meta::is_void<TO>, meta::is_not_void<FROM> >,
767  meta::same_const<TO,FROM> >::type> {
770  }
771  };
772 
773  // cast to same type, no-op
774  template<typename TOFRO>
775  struct static_shared_vector_caster<TOFRO,TOFRO,void> {
777  return src;
778  }
779  };
780 } // namespace detail
781 
789 template<typename TO, typename FROM>
790 static FORCE_INLINE
792 static_shared_vector_cast(const shared_vector<FROM>& src)
793 {
795 }
796 
797 namespace detail {
798 
799  // Default to type conversion using castUnsafe (C++ type casting) on each element
800  template<typename TO, typename FROM, class Enable = void>
802  static inline shared_vector<TO> op(const shared_vector<FROM>& src)
803  {
804  shared_vector<TO> ret(src.size());
805  std::transform(src.begin(), src.end(), ret.begin(), castUnsafe<TO,FROM>);
806  return ret;
807  }
808  };
809 
810  // copy reference when types are the same (excluding const qualifiers)
811  template<typename TO, typename FROM>
812  struct shared_vector_converter<TO,FROM, typename meta::same_root<TO,FROM>::type > {
814  return src;
815  }
816  };
817 
818  // "convert" to 'void' or 'const void from non-void
819  // is an alias for shared_vector_cast<void>()
820  template<typename TO, typename FROM>
821  struct shared_vector_converter<TO,FROM,
822  typename meta::_and<meta::is_void<TO>, meta::is_not_void<FROM> >::type
823  >
824  {
827  }
828  };
829 
830  // convert from void uses original type or throws an exception.
831  template<typename TO, typename FROM>
832  struct shared_vector_converter<TO,FROM,
833  typename meta::_and<meta::is_not_void<TO>, meta::is_void<FROM> >::type
834  >
835  {
837  typedef typename meta::strip_const<TO>::type to_t;
838  ScalarType stype = src.original_type(),
840  if(stype==dtype) {
841  // no convert needed
843  } else {
844  // alloc and convert
846  castUnsafeV(ret.size(),
847  dtype,
848  static_cast<void*>(ret.data()),
849  stype,
850  static_cast<const void*>(src.data()));
851  return const_shared_vector_cast<TO>(ret);
852  }
853  }
854  };
855 }
856 
868 template<typename TO, typename FROM>
869 static FORCE_INLINE
871 shared_vector_convert(const shared_vector<FROM>& src)
872 {
874 }
875 
882 template<typename SRC>
883 static FORCE_INLINE
885 freeze(SRC& src)
886 {
887  typedef typename meta::decorate_const<typename SRC::value_type>::type const_value;
889 }
890 
897 template<typename SRC>
898 static FORCE_INLINE
900 thaw(SRC& src)
901 {
904 }
905 
906 namespace detail {
907  template<typename TO, typename FROM, class Enable = void>
908  struct const_caster {};
909 
910  template<typename TYPE>
911  struct const_caster<TYPE,const TYPE> {
913  {
914  return thaw(src);
915  }
916  };
917 
918  template<typename TYPE>
919  struct const_caster<const TYPE,TYPE> {
921  {
922  return freeze(src);
923  }
924  };
925 
926  template<typename TYPE>
929  {
930  shared_vector<TYPE> ret(src);
931  src.clear();
932  return ret;
933  }
934  };
935 }
936 
938 template<typename TO, typename FROM>
939 static FORCE_INLINE
941 const_shared_vector_cast(shared_vector<FROM>& src)
942 {
944 }
945 
946 
947 namespace ScalarTypeFunc {
950 
952  template<ScalarType ID>
953  inline
955  allocArray(size_t len)
956  {
957  shared_vector<void> raw(allocArray(ID, len));
958  return static_shared_vector_cast<typename ScalarTypeTraits<ID>::type>(raw);
959  }
960 }
961 
962 }} // namespace epics::pvData
963 
964 // Global operators for shared_vector
965 
966 template<typename A, typename B>
969 {
970  if(a.size() != b.size())
971  return false;
972  if(a.dataOffset()==b.dataOffset() && a.dataPtr().get()==b.dataPtr().get())
973  return true;
974  return std::equal(a.begin(), a.end(), b.begin());
975 }
976 
977 template<typename A, typename B>
978 bool operator!=(const epics::pvData::shared_vector<A>& a,
980 {
981  return !(a==b);
982 }
983 
984 template<typename E>
985 std::ostream& operator<<(std::ostream& strm, const epics::pvData::shared_vector<E>& arr)
986 {
987  strm<<'{'<<arr.size()<<"}[";
988  for(size_t i=0; i<arr.size(); i++) {
989  if(i>10) {
990  strm<<"...";
991  break;
992  }
993  strm<<arr[i];
994  if(i+1<arr.size())
995  strm<<", ";
996  }
997  strm<<']';
998  return strm;
999 }
1000 
1001 
1002 #endif // SHAREDVECTOR_H
1003 
meta::decorate_const< E >::type & const_reference
Definition: sharedVector.h:295
shared_vector_base & operator=(const shared_vector_base &o)
Copy an existing vector.
Definition: sharedVector.h:172
void make_unique()
Ensure (by copying) that this shared_vector is the sole owner of the data array.
Definition: sharedVector.h:526
void resize(size_t i)
Grow or shrink array.
Definition: sharedVector.h:457
Definition: link.h:174
meta::decorate_const< E >::type * const_pointer
Definition: sharedVector.h:297
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
size_t elementSize(ScalarType id)
gives sizeof(T) where T depends on the scalar type id.
Definition: TypeFunc.cpp:82
bool empty() const
shorthand for size()==0
Definition: sharedVector.h:222
A holder for a contiguous piece of memory.
Definition: sharedVector.h:27
pointer data() const
Return Base pointer.
Definition: sharedVector.h:616
shared_vector()
Empty vector (not very interesting)
Definition: sharedVector.h:315
shared_vector(shared_vector< const void > &O, detail::_shared_vector_thaw_tag t)
Definition: sharedVector.h:711
int i
Definition: scan.c:967
#define TYPE
Definition: defs.h:70
shared_vector(const std::tr1::shared_ptr< E1 > &d, size_t o, size_t c)
Build vector from an existing smart pointer.
Definition: sharedVector.h:356
const_reverse_iterator crend() const
Definition: sharedVector.h:570
shared_vector(size_t c, param_type e)
Allocate (with new[]) a new vector of size c and fill with value e.
Definition: sharedVector.h:334
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:788
size_t m_count
Number of visible elements between m_offset and end of data.
Definition: sharedVector.h:63
shared_vector_base(const shared_vector_base &O)
Definition: sharedVector.h:115
static FORCE_INLINE shared_vector< TYPE > op(shared_vector< const TYPE > &src)
Definition: sharedVector.h:912
void resize(size_t i, param_type v)
Grow (and fill) or shrink array.
Definition: sharedVector.h:498
pvd::StructureConstPtr type
shared_vector_base(A d, B b, size_t o, size_t c)
Definition: sharedVector.h:111
#define epicsShareFunc
Definition: shareLib.h:209
Definition: memory.hpp:41
reverse_iterator rbegin() const
Definition: sharedVector.h:566
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
shared_vector_base(A *v, size_t o, size_t c)
Definition: sharedVector.h:100
static FORCE_INLINE shared_vector< TYPE > op(shared_vector< TYPE > &src)
Definition: sharedVector.h:928
shared_vector(A d, B b, size_t o, size_t c)
Build vector from raw pointer and cleanup function.
Definition: sharedVector.h:367
void clear()
Clear contents. size() becomes 0.
Definition: sharedVector.h:210
static shared_vector< TO > op(const shared_vector< FROM > &src)
Definition: sharedVector.h:802
epicsTime begin
Definition: caConnTest.cpp:22
static FORCE_INLINE shared_vector< TO > op(const shared_vector< FROM > &src)
Definition: sharedVector.h:813
size_t m_offset
Offset in the data array of first visible element.
Definition: sharedVector.h:61
shared_vector(shared_vector< void > &O, detail::_shared_vector_freeze_tag t)
Definition: sharedVector.h:706
void copy(PVValueArray< T > &pvFrom, size_t fromOffset, size_t fromStride, PVValueArray< T > &pvTo, size_t toOffset, size_t toStride, size_t count)
Copy a subarray from one scalar array to another.
shared_vector(shared_vector< const E > &O, detail::_shared_vector_thaw_tag t)
Definition: sharedVector.h:394
shared_vector & operator=(const shared_vector &o)
Definition: sharedVector.h:399
void push_back(param_type v)
Definition: sharedVector.h:602
shared_vector< typename ScalarTypeTraits< ID >::type > allocArray(size_t len)
Allocate an untyped array based on ScalarType.
Definition: sharedVector.h:955
const_iterator cend() const
Definition: sharedVector.h:564
shared_vector_base(shared_vector_base< _E_non_const > &O, _shared_vector_freeze_tag)
Definition: sharedVector.h:136
void swap(shared_vector_base &o)
Swap the contents of this vector with another.
Definition: sharedVector.h:199
bool unique() const
Data is not shared?
Definition: sharedVector.h:216
meta::decorate_const< E >::type * const_iterator
Definition: sharedVector.h:300
static FORCE_INLINE const shared_vector< TOFRO > & op(const shared_vector< TOFRO > &src)
Definition: sharedVector.h:776
meta::strip_const< E >::type _E_non_const
Definition: sharedVector.h:132
std::reverse_iterator< iterator > reverse_iterator
Definition: sharedVector.h:299
size_t size() const
Number of elements visible through this vector.
Definition: sharedVector.h:220
shared_vector(shared_vector< typename base_t::_E_non_const > &O, detail::_shared_vector_freeze_tag t)
Definition: sharedVector.h:389
shared_vector(const shared_vector< FROM > &src, detail::_shared_vector_cast_tag)
Definition: sharedVector.h:698
shared_vector(size_t c)
Allocate (with new[]) a new vector of size c.
Definition: sharedVector.h:329
shared_vector(A v, size_t o, size_t c)
Build vector from a raw pointer.
Definition: sharedVector.h:347
bool operator==(const PVField &left, const PVField &right)
Definition: Compare.cpp:328
shared_vector_base(shared_vector< const E > &O, _shared_vector_thaw_tag)
Definition: sharedVector.h:155
epicsShareExtern void castUnsafeV(size_t count, ScalarType to, void *dest, ScalarType from, const void *src)
Definition: typeCast.cpp:72
shared_vector_base(const std::tr1::shared_ptr< E > &d, size_t o, size_t c)
Definition: sharedVector.h:105
const std::tr1::shared_ptr< E > & dataPtr() const
Definition: sharedVector.h:261
shared_vector(const shared_vector &o)
Copy an existing vector of same type.
Definition: sharedVector.h:371
reverse_iterator rend() const
Definition: sharedVector.h:569
void swap(shared_ptr< T > &a, shared_ptr< T > &b) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:783
reference operator[](size_t i) const
Member access Undefined if empty()==true.
Definition: sharedVector.h:620
size_t m_total
Total number of elements between m_offset and the end of data.
Definition: sharedVector.h:65
void slice(size_t offset, size_t length=(size_t)-1)
Reduce the view of this shared_vector.
Definition: sharedVector.h:244
#define FORCE_INLINE
Definition: templateMeta.h:20
ChannelPut::shared_pointer op
Definition: pvAccess.cpp:132
std::tr1::shared_ptr< E > shared_pointer_type
Definition: sharedVector.h:306
shared_ptr< T > const_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:798
static FORCE_INLINE shared_vector< const TYPE > op(shared_vector< TYPE > &src)
Definition: sharedVector.h:920
const_reverse_iterator crbegin() const
Definition: sharedVector.h:567
void reserve(size_t i)
Set array capacity.
Definition: sharedVector.h:428
const_iterator cbegin() const
Definition: sharedVector.h:561
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: sharedVector.h:301
reference at(size_t i) const
Member access.
Definition: sharedVector.h:624
shared_vector(const std::tr1::shared_ptr< E1 > &d, size_t o, size_t c)
Definition: sharedVector.h:684
shared_vector(const shared_vector< FROM > &src, detail::_shared_vector_cast_tag)
Definition: sharedVector.h:381
std::tr1::shared_ptr< E > m_sdata
Definition: sharedVector.h:59
reference back() const
Definition: sharedVector.h:573
reference front() const
Definition: sharedVector.h:572