cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vctDynamicConstVectorRef.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 _vctDynamicConstVectorRef_h
23 #define _vctDynamicConstVectorRef_h
24 
32 
78 template <class _elementType>
80  public vctDynamicConstVectorBase<vctDynamicVectorRefOwner<_elementType>, _elementType>
81 {
82 public:
83  VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType);
87  typedef typename BaseType::CopyType CopyType;
92 
95  {}
96 
99  BaseType()
100  {
101  SetRef(other.size(), other.Pointer(), other.stride());
102  }
103 
105  SetRef(size, data, stride);
106  }
107 
109  SetRef(size, data, stride);
110  }
111 
117  template <size_type __size, stride_type __stride, class __dataPtrType>
119  {
120  SetRef(otherVector);
121  }
122 
129  template <size_type __size, stride_type __stride, class __dataPtrType>
131  size_type startPosition, size_type length)
132  {
133  SetRef(otherVector, startPosition, length);
134  }
135 
139  template <class __vectorOwnerType>
141  {
142  SetRef(otherVector);
143  }
144 
149  template <class __vectorOwnerType>
151  size_type startPosition, size_type length)
152  {
153  SetRef(otherVector, startPosition, length);
154  }
155 
156  void SetRef(size_type size, const_pointer p, stride_type stride = 1) {
157  this->Vector.SetRef(size, const_cast<pointer>(p), stride);
158  }
159 
164  template <size_type __size, stride_type __stride, class __dataPtrType>
166  {
167  SetRef(otherVector.size(), otherVector.Pointer(), otherVector.stride());
168  }
169 
176  template <size_type __size, stride_type __stride, class __dataPtrType>
178  size_type startPosition, size_type length) throw(std::out_of_range)
179  {
180  if (startPosition + length > otherVector.size()) {
181  cmnThrow(std::out_of_range("vctDynamicConstVectorRef SetRef out of range"));
182  }
183  SetRef(length, otherVector.Pointer(startPosition), otherVector.stride());
184  }
185 
190  template <class __vectorOwnerType>
192  {
193  SetRef(otherVector.size(), otherVector.Pointer(), otherVector.stride());
194  }
195 
202  template <class __vectorOwnerType>
204  size_type startPosition, size_type length) throw(std::out_of_range)
205  {
206  if (startPosition + length > otherVector.size()) {
207  cmnThrow(std::out_of_range("vctDynamicConstVectorRef SetRef out of range"));
208  }
209  SetRef(length, otherVector.Pointer(startPosition), otherVector.stride());
210  }
211 
212 };
213 
214 
215 #endif // _vctDynamicConstVectorRef_h
216 
void SetRef(size_type size, value_type *data, stride_type stride=1)
Definition: vctDynamicVectorRefOwner.h:67
A vector object of dynamic size.
Definition: vctDynamicVector.h:127
Dynamic vector referencing existing memory (const)
Definition: vctDynamicConstVectorRef.h:79
vctDynamicConstVectorBase< vctDynamicVectorRefOwner< value_type >, _elementType > BaseType
Definition: vctDynamicConstVectorRef.h:86
void SetRef(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector)
Definition: vctDynamicConstVectorRef.h:191
size_t size_type
Definition: vctContainerTraits.h:35
void SetRef(const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &otherVector)
Definition: vctDynamicConstVectorRef.h:165
size_type size(void) const
Definition: vctDynamicConstVectorBase.h:164
VectorOwnerType::const_iterator const_iterator
Definition: vctDynamicConstVectorRef.h:89
VectorOwnerType::const_reverse_iterator const_reverse_iterator
Definition: vctDynamicConstVectorRef.h:91
difference_type stride(void) const
Definition: vctFixedSizeConstVectorBase.h:218
VectorOwnerType::reverse_iterator reverse_iterator
Definition: vctDynamicConstVectorRef.h:90
vctDynamicConstVectorRef(const ThisType &other)
Definition: vctDynamicConstVectorRef.h:98
size_type size(void) const
Definition: vctFixedSizeConstVectorBase.h:205
void SetRef(size_type size, const_pointer p, stride_type stride=1)
Definition: vctDynamicConstVectorRef.h:156
const_pointer Pointer(size_type index=0) const
Definition: vctFixedSizeConstVectorBase.h:268
difference_type stride() const
Definition: vctDynamicConstVectorBase.h:169
#define cmnThrow(a)
Definition: MinimalCmn.h:4
vctDynamicConstVectorRef(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector, size_type startPosition, size_type length)
Definition: vctDynamicConstVectorRef.h:150
const_pointer Pointer(index_type index=0) const
Definition: vctDynamicConstVectorBase.h:221
vctDynamicConstVectorRef(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector)
Definition: vctDynamicConstVectorRef.h:140
Definition: vctDynamicVectorRefOwner.h:39
Declaration of vctDynamicConstVectorBase.
ptrdiff_t stride_type
Definition: vctContainerTraits.h:37
vctDynamicVectorRefOwner< value_type > VectorOwnerType
Definition: vctDynamicConstVectorRef.h:85
vctDynamicConstVectorRef(const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &otherVector, size_type startPosition, size_type length)
Definition: vctDynamicConstVectorRef.h:130
Definition: vctVarStrideVectorIterator.h:222
BaseType::CopyType CopyType
Definition: vctDynamicConstVectorRef.h:87
Definition: vctDynamicConstVectorBase.h:77
A template for a fixed length vector with fixed spacing in memory.
Definition: vctFixedSizeConstVectorBase.h:107
vctDynamicConstVectorRef(const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &otherVector)
Definition: vctDynamicConstVectorRef.h:118
VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType)
vctDynamicConstVectorRef(size_type size, const_pointer data, stride_type stride=1)
Definition: vctDynamicConstVectorRef.h:108
vctDynamicConstVectorRef(size_type size, pointer data, stride_type stride=1)
Definition: vctDynamicConstVectorRef.h:104
VectorOwnerType::iterator iterator
Definition: vctDynamicConstVectorRef.h:88
void SetRef(const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &otherVector, size_type startPosition, size_type length)
Definition: vctDynamicConstVectorRef.h:177
vctDynamicConstVectorRef< value_type > ThisType
Definition: vctDynamicConstVectorRef.h:84
Definition: vctVarStrideVectorIterator.h:56
vctDynamicConstVectorRef()
Definition: vctDynamicConstVectorRef.h:94
Declaration of vctDynamicVectorRefOwner.
void SetRef(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector, size_type startPosition, size_type length)
Definition: vctDynamicConstVectorRef.h:203