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

Annotation of /temp_trunk_copy/escript/src/DataBlocks2D.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 478 - (hide annotations)
Tue Jan 31 02:21:49 2006 UTC (13 years, 7 months ago) by jgs
Original Path: trunk/escript/src/DataBlocks2D.cpp
File size: 3232 byte(s)
rationalise #includes

1 jgs 82 /*
2     ******************************************************************************
3     * *
4     * COPYRIGHT ACcESS 2004 - All Rights Reserved *
5     * *
6     * This software is the property of ACcESS. No part of this code *
7     * may be copied in any form or by any means without the expressed written *
8     * consent of ACcESS. Copying, use or modification of this software *
9     * by any unauthorised person is illegal unless that person has a software *
10     * license agreement with ACcESS. *
11     * *
12     ******************************************************************************
13     */
14 jgs 117
15 jgs 474 #include "DataBlocks2D.h"
16 jgs 82
17 jgs 478 #include "DataException.h"
18     #include "EsysAssert.h"
19    
20 jgs 82 using namespace std;
21    
22     namespace escript {
23    
24     DataBlocks2D::DataBlocks2D():
25 jgs 151 m_numRows(0),
26     m_numCols(0),
27     m_blockSize(0)
28     {
29 jgs 117 }
30 jgs 82
31     DataBlocks2D::DataBlocks2D(const DataBlocks2D& other):
32 jgs 151 m_numRows(other.m_numRows),
33     m_numCols(other.m_numCols),
34     m_blockSize(other.m_blockSize)
35 jgs 117 {
36 jgs 82 m_data=other.m_data;
37 jgs 117 }
38 jgs 82
39     DataBlocks2D::DataBlocks2D(int numRows, int numCols, int blockSize):
40 jgs 151 m_numRows(numRows),
41     m_numCols(numCols),
42     m_blockSize(blockSize)
43 jgs 117 {
44 jgs 82 resize(m_numRows,numCols,blockSize);
45 jgs 117 }
46 jgs 82
47     DataBlocks2D::~DataBlocks2D()
48 jgs 151 {
49     m_numRows=-1;
50     m_numCols=-1;
51     m_blockSize=-1;
52 jgs 117 }
53 jgs 82
54     void
55     DataBlocks2D::resize(int numRows, int numCols, int blockSize)
56 jgs 117 {
57 jgs 151 if (numRows < 1 || numCols < 1 || blockSize < 1) {
58     stringstream temp;
59     temp << "DataBlocks2D: Error - Invalid resize parameter. numRows: " << numRows
60 jgs 82 << " numCols: " << numCols << " blockSize: " << blockSize;
61 jgs 151 throw DataException(temp.str());
62 jgs 82 }
63     ValueType::size_type size=numRows*numCols*blockSize;
64 jgs 151 m_data.resize(size, 0.0, numCols*blockSize);
65 jgs 82 m_numRows=numRows;
66     m_numCols=numCols;
67     m_blockSize=blockSize;
68 jgs 117 }
69 jgs 82
70     void
71     DataBlocks2D::Swap(DataBlocks2D& other)
72 jgs 117 {
73 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
74 jgs 82 swap(m_data,other.m_data);
75     swap(m_blockSize,other.m_blockSize);
76     swap(m_numRows,other.m_numRows);
77     swap(m_numCols,other.m_numCols);
78 jgs 117 }
79 jgs 82
80     DataBlocks2D&
81     DataBlocks2D::operator=(const DataBlocks2D& other)
82 jgs 117 {
83 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
84 jgs 82 DataBlocks2D temp(other);
85     Swap(temp);
86     return *this;
87 jgs 117 }
88 jgs 123
89     int
90     DataBlocks2D::archiveData(ofstream& archiveFile,
91     const ValueType::size_type noValues) const
92     {
93 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
94     return (m_data.archiveData(archiveFile, noValues));
95 jgs 123 }
96    
97     int
98     DataBlocks2D::extractData(ifstream& archiveFile,
99     const ValueType::size_type noValues)
100     {
101 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
102     return (m_data.extractData(archiveFile, noValues));
103 jgs 123 }
104 jgs 117
105 jgs 82 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26