cisst-saw
Loading...
Searching...
No Matches
vctFixedSizeVectorRef.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5 Author(s): Ofri Sadowsky, Anton Deguet
6 Created on: 2003-09-30
7
8 (C) Copyright 2003-2015 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19#pragma once
20#ifndef _vctFixedSizeVectorRef_h
21#define _vctFixedSizeVectorRef_h
22
27
29
30
45template <class _elementType, vct::size_type _size, vct::stride_type _stride>
47 _size, _stride, _elementType,
48 typename vctFixedSizeVectorTraits<_elementType, _size, _stride>::pointer >
49{
50 public:
55 typedef typename BaseType::CopyType CopyType;
56
57
60
61
64 SetRef(p);
65 }
66
68 SetRef(other);
69 }
70
75 template <size_type __size, class __dataPtrType>
77 size_type startPosition = 0)
78 {
79 SetRef(otherVector, startPosition);
80 }
81
85 template<class __vectorOwnerType>
87 size_type startPosition = 0)
88 {
89 SetRef(otherVector, startPosition);
90 }
91
92
94 void SetRef(pointer p) {
95 this->Data = p;
96 }
97
98 void SetRef(const ThisType & other) {
99 this->SetRef(other.Data);
100 }
101
108 template <size_type __size, class __dataPtrType>
110 size_type startPosition = 0)
111 {
112 if (startPosition + this->size() > otherVector.size()) {
113 cmnThrow(std::out_of_range("vctFixedSizeVectorRef SetRef out of range"));
114 }
115 SetRef(otherVector.Pointer(startPosition));
116 }
117
124 template<class __vectorOwnerType>
126 size_type startPosition = 0)
127 {
128 if (this->stride() != otherVector.stride()) {
129 cmnThrow(std::runtime_error("vctFixedSizeVectorRef SetRef with incompatible stride"));
130 }
131 if (startPosition + this->size() > otherVector.size()) {
132 cmnThrow(std::out_of_range("vctFixedSizeVectorRef SetRef out of range"));
133 }
134 SetRef(otherVector.Pointer(startPosition));
135 }
136
137
144 inline ThisType & operator = (const ThisType & other) {
145 return reinterpret_cast<ThisType &>(this->Assign(other));
146 }
147
148 template <stride_type __stride>
150 return reinterpret_cast<ThisType &>(this->Assign(other));
151 }
152
153 template <stride_type __stride, class __elementType, class __dataPtrType>
155 return reinterpret_cast<ThisType &>(this->Assign(other));
156 }
157
158 template <class __vectorOwnerType>
160 return reinterpret_cast<ThisType &>(this->Assign(other));
161 }
162
163
165 inline ThisType & operator = (const value_type & value) {
166 this->SetAll(value);
167 return *this;
168 }
169};
170
171#endif // _vctFixedSizeVectorRef_h
Definition vctForwardDeclarations.h:119
Definition vctDynamicVectorBase.h:62
pointer Pointer(index_type index=0)
Definition vctDynamicVectorBase.h:155
A template for a fixed length vector with fixed spacing in memory.
Definition vctFixedSizeConstVectorBase.h:108
size_type size(void) const
Definition vctFixedSizeConstVectorBase.h:205
Definition vctForwardDeclarations.h:86
A template for a fixed length vector with fixed spacing in memory.
Definition vctFixedSizeVectorBase.h:77
pointer Pointer(size_type index=0)
Definition vctFixedSizeVectorBase.h:226
Definition vctForwardDeclarations.h:89
Define common container related types based on the properties of a fixed size container.
Definition vctFixedSizeVectorTraits.h:46
void cmnThrow(const _exceptionType &except, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_ERROR)
Definition cmnThrow.h:76
#define VCT_CONTAINER_TRAITS_TYPEDEFS(type)
Definition vctContainerTraits.h:50
size_type size(void) const
Definition vctDynamicConstMatrixBase.h:228
vctDynamicConstMatrixBase< _matrixOwnerType, _elementType > ThisType
Definition vctDynamicConstMatrixBase.h:86
difference_type stride(dimension_type dimension) const
Definition vctDynamicConstNArrayBase.h:325
vctDynamicVector< _elementType > CopyType
Definition vctDynamicConstVectorBase.h:102
ThisType & operator=(const vctDynamicConstMatrixBase< __matrixOwnerType, __elementType > &otherMatrix)
Definition vctDynamicMatrix.h:255
vctDynamicNArrayBase< vctDynamicNArrayOwner< _elementType, _dimension >, _elementType, _dimension > BaseType
Definition vctDynamicNArray.h:133
void SetRef(pointer p)
Definition vctFixedSizeConstMatrixRef.h:114
Declaration of vctFixedSizeConstVectorRef.