escript  Revision_
DataVectorTaipan.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 
17 
18 #if !defined escript_DataVectorTaipan_H
19 #define escript_DataVectorTaipan_H
20 #include "system_dep.h"
21 
22 #include "Assert.h"
23 #include "DataTypes.h"
24 #include "WrappedArray.h"
25 
26 namespace escript
27 {
28 
29 namespace DataTypes
30 {
31 
45 
46  public:
47 
48  //
49  // The type of the elements stored in the vector.
50  typedef double ElementType;
51 
52  //
53  // The underlying type used to implement the vector.
54  typedef ElementType * VectorStorageType;
55 
56 
57  //
58  // Various types exported to clients of this class.
59  typedef const ElementType * const_pointer;
60  typedef ElementType value_type;
61  typedef long size_type;
62  typedef ElementType & reference;
63  typedef const ElementType & const_reference;
64 
73 
82  DataVectorTaipan(const DataVectorTaipan& other);
83 
102  DataVectorTaipan(const size_type size,
103  const value_type val=0.0,
104  const size_type blockSize=1);
105 
113  ~DataVectorTaipan();
114 
125  void
126  resize(const size_type newSize,
127  const value_type newVal=0.0,
128  const size_type newBlockSize=1);
129 
136  void
137  copyFromArray(const escript::WrappedArray& value, size_type copies);
138 
139  void
140  copyFromArrayToOffset(const escript::WrappedArray& value, size_type offset, size_type copies);
141 
142 
147  inline
148  size_type
149  size() const;
150 
157  operator=(const DataVectorTaipan& other);
158 
164  bool
165  operator==(const DataVectorTaipan& other) const;
166 
172  bool
173  operator!=(const DataVectorTaipan& other) const;
174 
183  inline
184  reference
185  operator[](const size_type i);
186 
187  inline
188  const_reference
189  operator[](const size_type i) const;
190 
191 
192  protected:
193 
194  private:
195 
196  size_type m_size;
197  size_type m_dim;
198  size_type m_N;
199 
200  //
201  // The container for the elements contained in this DataVectorTaipan.
202  VectorStorageType m_array_data;
203 };
204 
205 
212 
213 
214 
215 inline
218 {
219  return m_size;
220 }
221 
222 inline
225 {
226  ESYS_ASSERT(i<size(), "DataVectorTaipan: invalid index specified. " << i << " of " << size());
227  return m_array_data[i];
228 }
229 
230 inline
233 {
234  ESYS_ASSERT(i<size(),"DataVectorTaipan: invalid index specified. " << i << " of " << size());
235  return m_array_data[i];
236 }
237 
238 
239 } // end of namespace
240 } // end of namespace
241 
242 
243 
244 #endif
double ElementType
Definition: DataVectorTaipan.h:50
ElementType value_type
Definition: DataVectorTaipan.h:60
Definition: AbstractContinuousDomain.cpp:22
ElementType & reference
Definition: DataVectorTaipan.h:62
ElementType * VectorStorageType
Definition: DataVectorTaipan.h:54
size_type size() const
Return the number of elements in this DataVectorTaipan.
Definition: DataVectorTaipan.h:217
reference operator[](const size_type i)
Return a reference to the element at position i in this DataVectorTaipan. Will throw an exception if ...
Definition: DataVectorTaipan.h:224
const ElementType & const_reference
Definition: DataVectorTaipan.h:63
size_type m_N
Definition: DataVectorTaipan.h:198
void releaseUnusedMemory()
releases unused memory in the memory manager.
Definition: DataVectorTaipan.cpp:40
VectorStorageType m_array_data
Definition: DataVectorTaipan.h:202
const ElementType * const_pointer
Definition: DataVectorTaipan.h:59
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:29
size_type m_dim
Definition: DataVectorTaipan.h:197
#define ESYS_ASSERT(a, b)
EsysAssert is a MACRO that will throw an exception if the boolean condition specified is false...
Definition: Assert.h:78
Definition: WrappedArray.h:31
long size_type
Definition: DataVectorTaipan.h:61
DataVectorTaipan implements an arbitrarily long vector of data values. DataVectorTaipan is the underl...
Definition: DataVectorTaipan.h:44
size_type m_size
Definition: DataVectorTaipan.h:196