/[escript]/trunk/escript/src/DataBlocks2D.cpp
ViewVC logotype

Contents of /trunk/escript/src/DataBlocks2D.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1388 - (show annotations)
Fri Jan 11 07:45:58 2008 UTC (11 years, 7 months ago) by trankine
File size: 2795 byte(s)
And get the *(&(*&(* name right
1
2 /* $Id$ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 #include "DataBlocks2D.h"
17
18 #include "DataException.h"
19 #include "esysUtils/EsysAssert.h"
20
21 using namespace std;
22
23 namespace escript {
24
25 DataBlocks2D::DataBlocks2D():
26 m_numRows(0),
27 m_numCols(0),
28 m_blockSize(0)
29 {
30 }
31
32 DataBlocks2D::DataBlocks2D(const DataBlocks2D& other):
33 m_numRows(other.m_numRows),
34 m_numCols(other.m_numCols),
35 m_blockSize(other.m_blockSize)
36 {
37 m_data=other.m_data;
38 }
39
40 DataBlocks2D::DataBlocks2D(int numRows, int numCols, int blockSize):
41 m_numRows(numRows),
42 m_numCols(numCols),
43 m_blockSize(blockSize)
44 {
45 resize(m_numRows,numCols,blockSize);
46 }
47
48 DataBlocks2D::~DataBlocks2D()
49 {
50 m_numRows=-1;
51 m_numCols=-1;
52 m_blockSize=-1;
53 }
54
55 void
56 DataBlocks2D::resize(int numRows, int numCols, int blockSize)
57 {
58 if (numRows < 1 || numCols < 1 || blockSize < 1) {
59 stringstream temp;
60 temp << "DataBlocks2D: Error - Invalid resize parameter. numRows: " << numRows
61 << " numCols: " << numCols << " blockSize: " << blockSize;
62 throw DataException(temp.str());
63 }
64 ValueType::size_type size=numRows*numCols*blockSize;
65 m_data.resize(size, 0.0, numCols*blockSize);
66 m_numRows=numRows;
67 m_numCols=numCols;
68 m_blockSize=blockSize;
69 }
70
71 void
72 DataBlocks2D::Swap(DataBlocks2D& other)
73 {
74 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
75 swap(m_data,other.m_data);
76 swap(m_blockSize,other.m_blockSize);
77 swap(m_numRows,other.m_numRows);
78 swap(m_numCols,other.m_numCols);
79 }
80
81 DataBlocks2D&
82 DataBlocks2D::operator=(const DataBlocks2D& other)
83 {
84 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
85 DataBlocks2D temp(other);
86 Swap(temp);
87 return *this;
88 }
89
90 int
91 DataBlocks2D::archiveData(ofstream& archiveFile,
92 const ValueType::size_type noValues) const
93 {
94 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
95 return (m_data.archiveData(archiveFile, noValues));
96 }
97
98 int
99 DataBlocks2D::extractData(ifstream& archiveFile,
100 const ValueType::size_type noValues)
101 {
102 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
103 return (m_data.extractData(archiveFile, noValues));
104 }
105
106 } // end of namespace

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26