cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vctDynamicConstMatrixRef.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 
6  Author(s): Ofri Sadowsky, Anton Deguet
7  Created on: 2004-07-01
8 
9  (C) Copyright 2004-2007 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 */
20 
21 #pragma once
22 #ifndef _vctDynamicConstMatrixRef_h
23 #define _vctDynamicConstMatrixRef_h
24 
32 
78 template <class _elementType>
80  public vctDynamicConstMatrixBase<vctDynamicMatrixRefOwner<_elementType>, _elementType>
81 {
82 public:
83  VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType);
84  enum {DIMENSION = 2};
86 
94 
95 
97  SetRef(0, 0, 1, 1, static_cast<pointer>(0));
98  }
99 
102  BaseType()
103  {
104  SetRef(other.sizes(), other.strides(), other.Pointer());
105  }
106 
113  stride_type rowStride, stride_type colStride,
114  pointer dataPointer)
115  {
116  SetRef(rows, cols, rowStride, colStride, dataPointer);
117  }
119  stride_type rowStride, stride_type colStride,
120  const_pointer dataPointer)
121  {
122  SetRef(rows, cols, rowStride, colStride, dataPointer);
123  }
124 
125  vctDynamicConstMatrixRef(const nsize_type & matrixSize, stride_type rowStride, stride_type colStride,
126  pointer dataPointer)
127  {
128  SetRef(matrixSize, rowStride, colStride, dataPointer);
129  }
130  vctDynamicConstMatrixRef(const nsize_type & matrixSize, stride_type rowStride, stride_type colStride,
131  const_pointer dataPointer)
132  {
133  SetRef(matrixSize, rowStride, colStride, dataPointer);
134  }
135 
136  vctDynamicConstMatrixRef(const nsize_type & matrixSize, const nstride_type & matrixStride,
137  pointer dataPointer)
138  {
139  SetRef(matrixSize, matrixStride, dataPointer);
140  }
141  vctDynamicConstMatrixRef(const nsize_type & matrixSize, const nstride_type & matrixStride,
142  const_pointer dataPointer)
143  {
144  SetRef(matrixSize, matrixStride, dataPointer);
145  }
147 
148 
155  bool storageOrder = VCT_DEFAULT_STORAGE)
156  {
157  SetRef(rows, cols, dataPointer, storageOrder);
158  }
159  vctDynamicConstMatrixRef(size_type rows, size_type cols, const_pointer dataPointer,
160  bool storageOrder = VCT_DEFAULT_STORAGE)
161  {
162  SetRef(rows, cols, dataPointer, storageOrder);
163  }
164 
165  vctDynamicConstMatrixRef(const nsize_type & matrixSize, pointer dataPointer,
166  bool storageOrder = VCT_DEFAULT_STORAGE)
167  {
168  SetRef(matrixSize, dataPointer, storageOrder);
169  }
170  vctDynamicConstMatrixRef(const nsize_type & matrixSize, const_pointer dataPointer,
171  bool storageOrder = VCT_DEFAULT_STORAGE)
172  {
173  SetRef(matrixSize, dataPointer, storageOrder);
174  }
176 
177 
183  template <size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
185  & otherMatrix)
186  {
187  SetRef(otherMatrix);
188  }
189 
200  template <size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
202  size_type startRow, size_type startCol, size_type rows, size_type cols)
203  {
204  SetRef(otherMatrix, startRow, startCol, rows, cols);
205  }
206 
212  template <class __ownerType>
214  {
215  SetRef(otherMatrix);
216  }
217 
229  template <class __ownerType>
231  size_type startRow, size_type startCol, size_type rows, size_type cols)
232  {
233  SetRef(otherMatrix, startRow, startCol, rows, cols);
234  }
235 
236  template <class __ownerType>
238  const nsize_type & start, const nsize_type & matrixSize)
239  {
240  SetRef(otherMatrix, start, matrixSize);
241  }
243 
249  stride_type rowStride, stride_type colStride,
250  pointer dataPointer)
251  {
252  this->Matrix.SetRef(rows, cols, rowStride, colStride, dataPointer);
253  }
255  stride_type rowStride, stride_type colStride,
256  const_pointer dataPointer)
257  {
258  this->Matrix.SetRef(rows, cols, rowStride, colStride, const_cast<pointer>(dataPointer));
259  }
260 
261  void SetRef(const nsize_type & matrixSize,
262  stride_type rowStride, stride_type colStride,
263  pointer dataPointer) {
264  this->Matrix.SetRef(matrixSize, rowStride, colStride, dataPointer);
265  }
266  void SetRef(const nsize_type & matrixSize,
267  stride_type rowStride, stride_type colStride,
268  const_pointer dataPointer) {
269  this->Matrix.SetRef(matrixSize, rowStride, colStride, const_cast<pointer>(dataPointer));
270  }
271 
272  void SetRef(const nsize_type & matrixSize,
273  const nstride_type & matrixStride,
274  pointer dataPointer) {
275  this->Matrix.SetRef(matrixSize, matrixStride, dataPointer);
276  }
277  void SetRef(const nsize_type & matrixSize,
278  const nstride_type & matrixStride,
279  const_pointer dataPointer) {
280  this->Matrix.SetRef(matrixSize, matrixStride, const_cast<pointer>(dataPointer));
281  }
283 
284 
290  void SetRef(size_type rows, size_type cols, pointer dataPointer, bool storageOrder = VCT_DEFAULT_STORAGE)
291  {
292  this->Matrix.SetRef(rows, cols, dataPointer, storageOrder);
293  }
294  void SetRef(size_type rows, size_type cols, const_pointer dataPointer, bool storageOrder = VCT_DEFAULT_STORAGE)
295  {
296  this->Matrix.SetRef(rows, cols, const_cast<pointer>(dataPointer), storageOrder);
297  }
298 
299  void SetRef(const nsize_type & sizes, pointer dataPointer, bool storageOrder = VCT_DEFAULT_STORAGE)
300  {
301  this->Matrix.SetRef(sizes, dataPointer, storageOrder);
302  }
303  void SetRef(const nsize_type & sizes, const_pointer dataPointer, bool storageOrder = VCT_DEFAULT_STORAGE)
304  {
305  this->Matrix.SetRef(sizes, const_cast<pointer>(dataPointer), storageOrder);
306  }
308 
309 
313  template <size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
315  & otherMatrix)
316  {
317  SetRef(otherMatrix.rows(), otherMatrix.cols(), otherMatrix.row_stride(), otherMatrix.col_stride(),
318  otherMatrix.Pointer());
319  }
320 
321 
334  template <size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
336  size_type startRow, size_type startCol,
338  {
339  if ( (startRow + rows > otherMatrix.rows()) || (startCol + cols > otherMatrix.cols()) ) {
340  cmnThrow(std::out_of_range("vctDynamicConstMatrixRef SetRef out of range"));
341  }
342  SetRef(rows, cols, otherMatrix.row_stride(), otherMatrix.col_stride(), otherMatrix.Pointer(startRow, startCol));
343  }
344 
348  template <class __ownerType>
350  {
351  SetRef(otherMatrix.rows(), otherMatrix.cols(), otherMatrix.row_stride(), otherMatrix.col_stride(),
352  otherMatrix.Pointer());
353  }
354 
368  template <class __ownerType>
370  size_type startRow, size_type startCol,
372  {
373  if ( (startRow + rows > otherMatrix.rows()) || (startCol + cols > otherMatrix.cols()) ) {
374  cmnThrow(std::out_of_range("vctDynamicConstMatrixRef SetRef out of range"));
375  }
376  SetRef(rows, cols, otherMatrix.row_stride(), otherMatrix.col_stride(),
377  otherMatrix.Pointer(startRow, startCol));
378  }
379 
380  template <class __ownerType>
382  const nsize_type & start, const nsize_type & matrixSize)
383  {
384  SetRef(otherMatrix,
385  start.Element(0), start.Element(1), matrixSize.Element(0), matrixSize.Element(1));
386  }
388 };
389 
390 
391 #endif // _vctDynamicConstMatrixRef_h
392 
void SetRef(const nsize_type &matrixSize, stride_type rowStride, stride_type colStride, pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:261
void SetRef(size_type rows, size_type cols, const_pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
Definition: vctDynamicConstMatrixRef.h:294
A template for a fixed size matrix with fixed spacing in memory.
Definition: vctFixedSizeConstMatrixBase.h:103
vctDynamicConstMatrixRef(const ThisType &other)
Definition: vctDynamicConstMatrixRef.h:101
void SetRef(size_type rows, size_type cols, pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
Definition: vctDynamicConstMatrixRef.h:290
void SetRef(const nsize_type &matrixSize, stride_type rowStride, stride_type colStride, const_pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:266
Declaration of vctDynamicConstMatrixBase.
vctDynamicConstMatrixRef(const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix)
Definition: vctDynamicConstMatrixRef.h:213
vctDynamicConstMatrixRef(size_type rows, size_type cols, pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
Definition: vctDynamicConstMatrixRef.h:154
void SetRef(const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &otherMatrix)
Definition: vctDynamicConstMatrixRef.h:314
vctDynamicConstMatrixRef(const nsize_type &matrixSize, const_pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
Definition: vctDynamicConstMatrixRef.h:170
size_t size_type
Definition: vctContainerTraits.h:35
void SetRef(size_type rows, size_type cols, stride_type rowStride, stride_type colStride, const_pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:254
MatrixOwnerType::iterator iterator
Definition: vctDynamicConstMatrixRef.h:90
vctDynamicConstMatrixRef(const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix, size_type startRow, size_type startCol, size_type rows, size_type cols)
Definition: vctDynamicConstMatrixRef.h:230
const bool VCT_DEFAULT_STORAGE
Definition: vctForwardDeclarations.h:49
vctDynamicConstMatrixRef(size_type rows, size_type cols, stride_type rowStride, stride_type colStride, pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:112
Definition: vctDynamicConstMatrixRef.h:84
const nstride_type & strides(void) const
Definition: vctDynamicConstMatrixBase.h:258
vctDynamicConstMatrixRef(const nsize_type &matrixSize, stride_type rowStride, stride_type colStride, pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:125
MatrixOwnerType::const_iterator const_iterator
Definition: vctDynamicConstMatrixRef.h:91
MatrixOwnerType::reverse_iterator reverse_iterator
Definition: vctDynamicConstMatrixRef.h:92
Definition: vctDynamicConstMatrixBase.h:77
vctDynamicConstMatrixRef(const nsize_type &matrixSize, const nstride_type &matrixStride, const_pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:141
vctDynamicConstMatrixBase< vctDynamicMatrixRefOwner< _elementType >, _elementType > BaseType
Definition: vctDynamicConstMatrixRef.h:89
VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType)
Dynamic matrix referencing existing memory (const)
Definition: vctDynamicConstMatrixRef.h:79
void SetRef(const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix, size_type startRow, size_type startCol, size_type rows, size_type cols)
Definition: vctDynamicConstMatrixRef.h:369
size_type rows() const
Definition: vctDynamicConstMatrixBase.h:238
vctDynamicConstMatrixRef(size_type rows, size_type cols, const_pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
Definition: vctDynamicConstMatrixRef.h:159
size_type cols() const
Definition: vctDynamicConstMatrixBase.h:243
void SetRef(const nsize_type &sizes, pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
Definition: vctDynamicConstMatrixRef.h:299
VCT_NARRAY_TRAITS_TYPEDEFS(DIMENSION)
const_pointer Pointer(index_type rowIndex, index_type colIndex) const
Definition: vctDynamicConstMatrixBase.h:306
Declaration of vctDynamicMatrixRefOwner.
vctDynamicConstMatrixRef(const nsize_type &matrixSize, const nstride_type &matrixStride, pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:136
#define cmnThrow(a)
Definition: MinimalCmn.h:4
void SetRef(const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &otherMatrix, size_type startRow, size_type startCol, size_type rows, size_type cols)
Definition: vctDynamicConstMatrixRef.h:335
MatrixOwnerType::const_reverse_iterator const_reverse_iterator
Definition: vctDynamicConstMatrixRef.h:93
void SetRef(const nsize_type &matrixSize, const nstride_type &matrixStride, pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:272
Definition: vctDynamicMatrixRefOwner.h:39
void SetRef(const nsize_type &matrixSize, const nstride_type &matrixStride, const_pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:277
ptrdiff_t stride_type
Definition: vctContainerTraits.h:37
vctDynamicMatrixRefOwner< _elementType > MatrixOwnerType
Definition: vctDynamicConstMatrixRef.h:88
vctDynamicConstMatrixRef(const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix, const nsize_type &start, const nsize_type &matrixSize)
Definition: vctDynamicConstMatrixRef.h:237
void SetRef(size_type rows, size_type cols, stride_type rowStride, stride_type colStride, pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:248
difference_type row_stride() const
Definition: vctDynamicConstMatrixBase.h:263
difference_type col_stride() const
Definition: vctDynamicConstMatrixBase.h:268
vctDynamicConstMatrixRef(const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &otherMatrix, size_type startRow, size_type startCol, size_type rows, size_type cols)
Definition: vctDynamicConstMatrixRef.h:201
void SetRef(size_type rows, size_type cols, pointer dataPointer, bool storageOrder)
Definition: vctDynamicMatrixRefOwner.h:74
void SetRef(const nsize_type &sizes, const_pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
Definition: vctDynamicConstMatrixRef.h:303
Definition: vctVarStrideMatrixIterator.h:40
vctDynamicConstMatrixRef(const nsize_type &matrixSize, stride_type rowStride, stride_type colStride, const_pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:130
vctDynamicConstMatrixRef< _elementType > ThisType
Definition: vctDynamicConstMatrixRef.h:87
vctDynamicConstMatrixRef(const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, _elementType, __dataPtrType > &otherMatrix)
Definition: vctDynamicConstMatrixRef.h:184
void SetRef(const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix)
Definition: vctDynamicConstMatrixRef.h:349
const nsize_type & sizes(void) const
Definition: vctDynamicConstMatrixBase.h:233
vctDynamicConstMatrixRef(size_type rows, size_type cols, stride_type rowStride, stride_type colStride, const_pointer dataPointer)
Definition: vctDynamicConstMatrixRef.h:118
const_reference Element(size_type rowIndex, size_type colIndex) const
Definition: vctDynamicConstMatrixBase.h:362
Definition: vctVarStrideMatrixIterator.h:287
vctDynamicConstMatrixRef()
Definition: vctDynamicConstMatrixRef.h:96
void SetRef(const vctDynamicConstMatrixBase< __ownerType, _elementType > &otherMatrix, const nsize_type &start, const nsize_type &matrixSize)
Definition: vctDynamicConstMatrixRef.h:381
vctDynamicConstMatrixRef(const nsize_type &matrixSize, pointer dataPointer, bool storageOrder=VCT_DEFAULT_STORAGE)
Definition: vctDynamicConstMatrixRef.h:165