Intrepid
Intrepid_MiniTensor_Storage.h
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid Package
5 // Copyright (2007) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions: Alejandro Mota (amota@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 
42 #if !defined(Intrepid_MiniTensor_Storage_h)
43 #define Intrepid_MiniTensor_Storage_h
44 
45 #include "Intrepid_MiniTensor_Definitions.h"
46 #include "Teuchos_ArrayRCP.hpp"
47 
48 namespace Intrepid {
49 namespace MiniTensor {
50 
54 template<typename T>
55 class Storage
56 {
57 public:
61  typedef T type;
62 
66  Storage() {}
67 
72  explicit
73  Storage(Index const number_entries) {resize(number_entries);}
74 
78  virtual
79  ~Storage() {}
80 
85  virtual
86  T const &
87  operator[](Index const i) const = 0;
88 
93  virtual
94  T &
95  operator[](Index const i) = 0;
96 
100  virtual
101  Index
102  size() const = 0;
103 
108  virtual
109  void
110  resize(Index const number_entries) = 0;
111 
115  virtual
116  void
117  clear() = 0;
118 
119 private:
120 
124  Storage(Storage<T> const & s);
125 
129  Storage<T> &
130  operator=(Storage<T> const & s);
131 
132 };
133 
137 template<typename T>
138 class StorageRaw: public Storage<T>
139 {
140 public:
144  StorageRaw();
145 
150  explicit
151  StorageRaw(Index const number_entries);
152 
156  ~StorageRaw();
157 
162  T const &
163  operator[](Index const i) const;
164 
169  T &
170  operator[](Index const i);
171 
175  Index
176  size() const;
177 
182  void
183  resize(Index const number_entries);
184 
188  void
189  clear();
190 
191 private:
192 
196  StorageRaw(StorageRaw<T> const & s);
197 
201  StorageRaw<T> &
202  operator=(StorageRaw<T> const & s);
203 
207  Index
209 
213  T *
215 
216 };
217 
221 template<typename T>
222 class StorageSTLVector: public Storage<T>
223 {
224 public:
229 
234  explicit
235  StorageSTLVector(Index const number_entries);
236 
241 
246  T const &
247  operator[](Index const i) const;
248 
253  T &
254  operator[](Index const i);
255 
259  Index
260  size() const;
261 
266  void
267  resize(Index const number_entries);
268 
272  void
273  clear();
274 
275 private:
276 
281 
286  operator=(StorageSTLVector<T> const & s);
287 
291  std::vector<T>
293 
294 };
295 
299 template<typename T>
300 class StorageRCPArray: public Storage<T>
301 {
302 public:
306  StorageRCPArray();
307 
312  explicit
313  StorageRCPArray(Index const number_entries);
314 
319 
324  T const &
325  operator[](Index const i) const;
326 
331  T &
332  operator[](Index const i);
333 
337  Index
338  size() const;
339 
344  void
345  resize(Index const number_entries);
346 
350  void
351  clear();
352 
353 private:
354 
359 
364  operator=(StorageRCPArray<T> const & s);
365 
369  Teuchos::ArrayRCP<T>
371 
372 };
373 
374 } // namespace MiniTensor
375 } // namespace Intrepid
376 
377 #include "Intrepid_MiniTensor_Storage.i.h"
378 
379 #endif // Intrepid_MiniTensor_Storage_h
T const & operator[](Index const i) const
virtual Index size() const =0
StorageRCPArray< T > & operator=(StorageRCPArray< T > const &s)
StorageSTLVector< T > & operator=(StorageSTLVector< T > const &s)
Storage< T > & operator=(Storage< T > const &s)
virtual T const & operator[](Index const i) const =0
void resize(Index const number_entries)
virtual void resize(Index const number_entries)=0
Storage(Index const number_entries)
StorageRaw< T > & operator=(StorageRaw< T > const &s)