cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vctDynamicVectorRefOwner.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 _vctDynamicVectorRefOwner_h
23 #define _vctDynamicVectorRefOwner_h
24 
31 
38 template<class _elementType>
40 {
41 public:
42  /* define most types from vctContainerTraits */
43  VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType);
44 
47 
48  /* iterators are container specific */
53 
54 
56  : Size(0)
57  , Stride(1)
58  , Data(0)
59  {}
60 
62  : Size(size)
63  , Stride(stride)
64  , Data(data)
65  {}
66 
67  void SetRef(size_type size, value_type * data, stride_type stride = 1)
68  {
69  Size = size;
70  Stride = stride;
71  Data = data;
72  }
73 
74  size_type size(void) const {
75  return Size;
76  }
77 
78  stride_type stride(void) const {
79  return Stride;
80  }
81 
82  pointer Pointer(index_type index = 0) {
83  return Data + Stride * index;
84  }
85 
86  const_pointer Pointer(index_type index = 0) const {
87  return Data + Stride * index;
88  }
89 
90  const_iterator begin(void) const {
91  return const_iterator(Data, Stride);
92  }
93 
94  const_iterator end(void) const {
95  return const_iterator(Data + Size * Stride, Stride);
96  }
97 
98  iterator begin(void) {
99  return iterator(Data, Stride);
100  }
101 
102  iterator end(void) {
103  return iterator(Data + Size * Stride, Stride);
104  }
105 
107  return const_reverse_iterator(Data + (Size-1) * Stride, -Stride);
108  }
109 
112  }
113 
115  return reverse_iterator(Data + (Size-1) * Stride, -Stride);
116  }
117 
119  return reverse_iterator(Data - Stride, -Stride);
120  }
121 
122 protected:
125  value_type* Data;
126 
127 private:
128  // copy constructor private to prevent any call
129  vctDynamicVectorRefOwner(const ThisType & CMN_UNUSED(other)) {};
130 
131 };
132 
133 
134 #endif // _vctDynamicVectorRefOwner_h
135 
size_t index_type
Definition: vctContainerTraits.h:36
value_type * Data
Definition: vctDynamicVectorRefOwner.h:125
void SetRef(size_type size, value_type *data, stride_type stride=1)
Definition: vctDynamicVectorRefOwner.h:67
iterator begin(void)
Definition: vctDynamicVectorRefOwner.h:98
vctDynamicVectorRefOwner()
Definition: vctDynamicVectorRefOwner.h:55
#define CMN_UNUSED(argument)
Definition: cmnPortability.h:479
vctVarStrideVectorIterator< value_type > reverse_iterator
Definition: vctDynamicVectorRefOwner.h:52
stride_type Stride
Definition: vctDynamicVectorRefOwner.h:124
size_t size_type
Definition: vctContainerTraits.h:35
vctVarStrideVectorConstIterator< value_type > const_iterator
Definition: vctDynamicVectorRefOwner.h:49
const_iterator end(void) const
Definition: vctDynamicVectorRefOwner.h:94
const_reverse_iterator rbegin(void) const
Definition: vctDynamicVectorRefOwner.h:106
vctDynamicVectorRefOwner< _elementType > ThisType
Definition: vctDynamicVectorRefOwner.h:46
const_pointer Pointer(index_type index=0) const
Definition: vctDynamicVectorRefOwner.h:86
const_iterator begin(void) const
Definition: vctDynamicVectorRefOwner.h:90
stride_type stride(void) const
Definition: vctDynamicVectorRefOwner.h:78
const_reverse_iterator rend(void) const
Definition: vctDynamicVectorRefOwner.h:110
reverse_iterator rend(void)
Definition: vctDynamicVectorRefOwner.h:118
iterator end(void)
Definition: vctDynamicVectorRefOwner.h:102
VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType)
vctVarStrideVectorIterator< value_type > iterator
Definition: vctDynamicVectorRefOwner.h:50
Declaration of vctVarStrideVectorConstIterator and vctVarStrideVectorIterator.
reverse_iterator rbegin(void)
Definition: vctDynamicVectorRefOwner.h:114
size_type Size
Definition: vctDynamicVectorRefOwner.h:123
vctDynamicVectorRefOwner(size_type size, value_type *data, stride_type stride=1)
Definition: vctDynamicVectorRefOwner.h:61
size_type size(void) const
Definition: vctDynamicVectorRefOwner.h:74
Definition: vctDynamicVectorRefOwner.h:39
ptrdiff_t stride_type
Definition: vctContainerTraits.h:37
Definition: vctVarStrideVectorIterator.h:222
vctVarStrideVectorConstIterator< value_type > const_reverse_iterator
Definition: vctDynamicVectorRefOwner.h:51
Definition: vctVarStrideVectorIterator.h:56
pointer Pointer(index_type index=0)
Definition: vctDynamicVectorRefOwner.h:82