14 #define XSARRAY_DECL(T)\ 16 const XsSize m_size; \ 17 const XsSize m_reserved; \ 19 XsArrayDescriptor const* const m_descriptor; 21 #define XSARRAY_STRUCT(S,T) struct S { XSARRAY_DECL(T) } 22 #define XSARRAY_INITIALIZER(D) { 0, 0, 0, XSDF_Managed, D } 25 typedef void (*XsArrayItemSwapFunc)(
void*,
void*);
26 typedef void (*XsArrayItemStructFunc)(
void*);
27 typedef void (*XsArrayItemCopyFunc)(
void*,
void const*);
28 typedef int (*XsArrayItemCompareFunc)(
void const*,
void const*);
30 #define XSEXPCASTITEMSWAP (XsArrayItemSwapFunc) 31 #define XSEXPCASTITEMMAKE (XsArrayItemStructFunc) 32 #define XSEXPCASTITEMCOPY (XsArrayItemCopyFunc) 33 #define XSEXPCASTITEMCOMP (XsArrayItemCompareFunc) 35 #define XSEXPCASTITEMSWAP 36 #define XSEXPCASTITEMMAKE 37 #define XSEXPCASTITEMCOPY 38 #define XSEXPCASTITEMCOMP 51 template <
typename T, XsArrayDescriptor const& D,
typename I>
friend struct XsArrayImpl;
118 , m_descriptor(descriptor)
152 template <
typename T, XsArrayDescriptor const& D,
typename I>
153 struct XsArrayImpl :
protected XsArray {
155 typedef T value_type;
158 typedef XsArrayImpl<T, D, I> ArrayImpl;
171 inline XsArrayImpl<T, D, I>(ArrayImpl
const& other)
175 #ifndef XSENS_NOITERATOR 177 template <
typename Iterator>
178 inline XsArrayImpl<T, D, I>(Iterator
const& beginIt, Iterator
const& endIt)
185 for (Iterator it = beginIt; it != endIt; ++it)
197 inline ~XsArrayImpl()
213 inline bool operator == (ArrayImpl
const& other)
const 223 inline bool operator != (ArrayImpl
const& other)
const 243 return *m_descriptor;
247 #ifndef XSENS_NOITERATOR 249 template <ptrdiff_t F,
typename R,
typename Derived>
250 struct IteratorImplBase {
255 typedef T value_type;
259 typedef T& reference;
262 typedef std::random_access_iterator_tag iterator_category;
265 typedef Derived this_type;
270 inline explicit IteratorImplBase(
void*
p = 0) : m_ptr((T*)
p) {}
272 inline explicit IteratorImplBase(T*
p) : m_ptr(
p) {}
274 inline IteratorImplBase(this_type
const& i) : m_ptr(i.m_ptr) {}
277 inline this_type operator =(
void*
p)
280 return this_type(m_ptr);
283 inline this_type operator =(T*
p)
286 return this_type(m_ptr);
289 inline this_type operator =(this_type
const& i)
292 return this_type(m_ptr);
297 m_ptr = (T*) ptrAt(m_ptr, F);
298 return this_type(m_ptr);
304 m_ptr = (T*) ptrAt(m_ptr, F);
308 inline this_type operator --()
310 m_ptr = (T*) ptrAt(m_ptr, -F);
311 return this_type(m_ptr);
314 inline this_type operator --(
int)
317 m_ptr = (T*) ptrAt(m_ptr, -F);
323 m_ptr = ptrAt(m_ptr, F*
count);
324 return this_type(m_ptr);
329 m_ptr = ptrAt(m_ptr, -F*
count);
330 return this_type(m_ptr);
335 return this_type(ptrAt(m_ptr, F*
count));
340 return this_type(ptrAt(m_ptr, -F*
count));
349 inline difference_type
operator - (
const this_type& other)
const 351 return (F * (reinterpret_cast<char*>(m_ptr) - reinterpret_cast<char*>(other.m_ptr))) / D.itemSize;
354 inline bool operator == (this_type
const& i)
const {
return m_ptr == i.m_ptr; }
356 inline bool operator <= (this_type
const& i)
const {
return (F==1)?(m_ptr <= i.m_ptr):(m_ptr >= i.m_ptr); }
358 inline bool operator < (this_type
const& i)
const {
return (F==1)?(m_ptr < i.m_ptr):(m_ptr > i.m_ptr); }
360 inline bool operator != (this_type
const& i)
const {
return m_ptr != i.m_ptr; }
362 inline bool operator >= (this_type
const& i)
const {
return (F==1)?(m_ptr >= i.m_ptr):(m_ptr <= i.m_ptr); }
364 inline bool operator > (this_type
const& i)
const {
return (F==1)?(m_ptr > i.m_ptr):(m_ptr < i.m_ptr); }
368 inline R* operator ->()
const {
return (
R*) ptr(); }
370 inline T* ptr()
const {
return m_ptr; }
378 #ifndef XSENS_NOITERATOR 380 template <ptrdiff_t F>
381 struct IteratorImpl :
public IteratorImplBase<F, T, IteratorImpl<F> >
385 typedef IteratorImplBase<F, T, IteratorImpl<F> > ParentType;
388 inline IteratorImpl(
void*
p = 0) : ParentType(
p) {}
390 inline IteratorImpl(T*
p) : ParentType(
p) {}
392 inline IteratorImpl(
const IteratorImpl& i) : ParentType(i) {}
396 template <ptrdiff_t F>
397 struct IteratorImplConst :
public IteratorImplBase<F, T const, IteratorImplConst<F> >
401 typedef IteratorImplBase<F, T const, IteratorImplConst<F> > ParentType;
404 inline IteratorImplConst(
void*
p = 0) : ParentType(
p) {}
406 inline IteratorImplConst(T*
p) : ParentType(
p) {}
408 inline IteratorImplConst(IteratorImpl<F>
const& i) : ParentType(i.ptr()) {}
410 inline IteratorImplConst(IteratorImplConst
const& i) : ParentType(i) {}
416 typedef IteratorImpl<-1> reverse_iterator;
420 typedef IteratorImplConst<-1> const_reverse_iterator;
428 inline const_reverse_iterator rbegin()
const {
return rend() - (
ptrdiff_t)
size(); }
430 inline const_reverse_iterator rend()
const {
return const_reverse_iterator(m_data) + (
ptrdiff_t) 1; }
438 inline reverse_iterator rbegin() {
return rend() - (
ptrdiff_t)
size(); }
440 inline reverse_iterator rend() {
return reverse_iterator(m_data) + (
ptrdiff_t) 1; }
446 return *ptrAt(m_data,
index);
457 #ifdef XSENS_NO_EXCEPTIONS 461 throw std::out_of_range(
"index out of range");
463 return *ptrAt(m_data,
index);
468 #ifdef XSENS_NO_EXCEPTIONS 472 throw std::out_of_range(
"index out of range");
474 return *ptrAt(m_data,
index);
483 insert(&item,
index, 1);
496 #ifndef XSENS_NOITERATOR 504 insert(&item, indexOf(it), 1);
511 inline void insert(T
const& item, const_reverse_iterator it)
513 insert(&item, indexOf(it), 1);
524 insert(items, indexOf(it),
count);
532 inline void insert(T
const* items, const_reverse_iterator it,
XsSize count)
534 insert(items, indexOf(it),
count);
541 insert(&item, (
XsSize) -1, 1);
552 inline void push_front(T
const& item)
574 #ifndef XSENS_NOITERATOR 580 return (idx <
size()) ? ptrAt(m_data, idx) :
end();
583 inline reverse_iterator erase(reverse_iterator it)
587 return (idx <
size()) ? ptrAt(m_data, idx) : rend();
607 inline void append(ArrayImpl
const& other)
612 inline ArrayImpl& operator=(ArrayImpl
const& other)
619 inline bool empty()
const 624 #ifndef XSENS_NOITERATOR 626 inline I
const& inherited()
const {
return *
static_cast<I const*
>(
this); }
629 inline I& inherited() {
return *
static_cast<I*
>(
this); }
633 inline void swap(ArrayImpl& other)
645 #ifndef XSENS_NOITERATOR 654 inline int find(T
const& needle)
const 658 #ifndef XSENS_NOITERATOR 664 template <ptrdiff_t F,
typename R,
typename Derived>
665 XsSize indexOf(IteratorImplBase<F,R,Derived>
const& it)
const 667 ptrdiff_t d = ((
char const*) it.ptr() - (
char const*) m_data);
680 inline void removeDuplicates()
697 return (T*)(
void*)(((
char*)ptr)+
count*D.itemSize);
XSTYPES_DLL_API void const * XsArray_at(void const *thisPtr, XsSize index)
XSTYPES_DLL_API void XsArray_insert(void *thisPtr, XsSize index, XsSize count, void const *src)
bool operator==(const TPoint2D &p1, const TPoint2D &p2)
Exact comparison between 2D points.
GLuint GLuint GLsizei count
This object describes how to treat the data in an array.
EIGEN_STRONG_INLINE bool empty() const
GLsizei const GLvoid * pointer
XSTYPES_DLL_API void XsArray_resize(void *thisPtr, XsSize count)
iterator operator++(int)
A thread-safe (ts) container which minimally emulates a std::map<>'s [] and find() methods but which ...
XSTYPES_DLL_API void XsArray_destruct(void *thisPtr)
The object contains undefined data / should be considered empty. Usually only relevant when XSDF_Fixe...
bool operator!=(const TPoint2D &p1, const TPoint2D &p2)
Exact comparison between 2D points.
void(* itemSwap)(void *a, void *b)
The function to use for swapping the data of two array items.
EIGEN_STRONG_INLINE iterator begin()
EIGEN_STRONG_INLINE void push_back(Scalar val)
Insert an element at the end of the container (for 1D vectors/arrays)
size_t XsSize
XsSize must be unsigned number!
const Scalar * const_iterator
const_iterator find(const KEY &key) const
void clear()
Clear the contents of this container.
XSTYPES_DLL_API int XsArray_compareSet(void const *a, void const *b)
std::vector< T1 > operator+(const std::vector< T1 > &a, const std::vector< T2 > &b)
a+b (element-wise sum)
XSTYPES_DLL_API void XsArray_erase(void *thisPtr, XsSize index, XsSize count)
XSTYPES_DLL_API int XsArray_find(void const *thisPtr, void const *needle)
void(* itemCopyConstruct)(void *e, void const *s)
The function to use for constructing a new array item with a source initializer. This may not be 0...
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
a+=b (element-wise sum)
XSTYPES_DLL_API void XsArray_removeDuplicates(void *thisPtr)
VALUE & operator[](const KEY &key)
Write/read via [i] operator, that creates an element if it didn't exist already.
EIGEN_STRONG_INLINE void setSize(size_t row, size_t col)
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where...
bool operator>(const CArray< T, N > &x, const CArray< T, N > &y)
void(* itemCopy)(void *to, void const *from)
The function to use for copying the data of from to to.
EIGEN_STRONG_INLINE void assign(const Scalar v)
size_t m_size
Number of elements accessed with write access so far.
const XsSize itemSize
The size of an array item in bytes.
void(* itemDestruct)(void *e)
The function to use for destructing a array item. May be 0 for simple types.
std::ostream & operator<<(std::ostream &out, MD5 md5)
XSTYPES_DLL_API void * XsArray_atIndex(void *thisPtr, XsSize index)
XSTYPES_DLL_API int XsArray_compare(void const *a, void const *b)
GLdouble GLdouble GLdouble r
XSTYPES_DLL_API void XsArray_copyConstruct(void *thisPtr, void const *src)
bool operator<=(const CArray< T, N > &x, const CArray< T, N > &y)
bool operator<(const CPoint< DERIVEDCLASS > &a, const CPoint< DERIVEDCLASS > &b)
Used by STL algorithms.
XSTYPES_DLL_API void XsArray_assign(void *thisPtr, XsSize count, void const *src)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
XSTYPES_DLL_API void XsArray_reserve(void *thisPtr, XsSize count)
XSTYPES_DLL_API void XsArray_copy(void *thisPtr, void const *src)
GLubyte GLubyte GLubyte a
TPoint3D operator-(const TPoint3D &p1)
Unary minus operator for 3D points.
XSTYPES_DLL_API void XsArray_swap(void *a, void *b)
XSTYPES_DLL_API void XsArray_append(void *thisPtr, void const *other)
XSTYPES_DLL_API void XsArray_construct(void *thisPtr, XsArrayDescriptor const *const descriptor, XsSize count, void const *src)
XsDataFlags
These flags define the behaviour of data contained by Xsens data structures.
std::vector< T1 > operator*(const std::vector< T1 > &a, const std::vector< T2 > &b)
a*b (element-wise multiplication)
bool operator>=(const CArray< T, N > &x, const CArray< T, N > &y)
void(* itemConstruct)(void *e)
The function to use for constructing a new array item. May be 0 for simple types. ...
int(* itemCompare)(void const *a, void const *b)
The function to use for comparing two items.