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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 474 - (hide annotations)
Mon Jan 30 04:23:44 2006 UTC (13 years, 9 months ago) by jgs
File size: 3180 byte(s)
restructure escript source tree
move src/Data/* -> src
remove inc
modify #includes and cpppath settings accordingly

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     using namespace std;
18    
19     namespace escript {
20    
21     DataBlocks2D::DataBlocks2D():
22 jgs 151 m_numRows(0),
23     m_numCols(0),
24     m_blockSize(0)
25     {
26 jgs 117 }
27 jgs 82
28     DataBlocks2D::DataBlocks2D(const DataBlocks2D& other):
29 jgs 151 m_numRows(other.m_numRows),
30     m_numCols(other.m_numCols),
31     m_blockSize(other.m_blockSize)
32 jgs 117 {
33 jgs 82 m_data=other.m_data;
34 jgs 117 }
35 jgs 82
36     DataBlocks2D::DataBlocks2D(int numRows, int numCols, int blockSize):
37 jgs 151 m_numRows(numRows),
38     m_numCols(numCols),
39     m_blockSize(blockSize)
40 jgs 117 {
41 jgs 82 resize(m_numRows,numCols,blockSize);
42 jgs 117 }
43 jgs 82
44     DataBlocks2D::~DataBlocks2D()
45 jgs 151 {
46     m_numRows=-1;
47     m_numCols=-1;
48     m_blockSize=-1;
49 jgs 117 }
50 jgs 82
51     void
52     DataBlocks2D::resize(int numRows, int numCols, int blockSize)
53 jgs 117 {
54 jgs 151 if (numRows < 1 || numCols < 1 || blockSize < 1) {
55     stringstream temp;
56     temp << "DataBlocks2D: Error - Invalid resize parameter. numRows: " << numRows
57 jgs 82 << " numCols: " << numCols << " blockSize: " << blockSize;
58 jgs 151 throw DataException(temp.str());
59 jgs 82 }
60     ValueType::size_type size=numRows*numCols*blockSize;
61 jgs 151 m_data.resize(size, 0.0, numCols*blockSize);
62 jgs 82 m_numRows=numRows;
63     m_numCols=numCols;
64     m_blockSize=blockSize;
65 jgs 117 }
66 jgs 82
67     void
68     DataBlocks2D::Swap(DataBlocks2D& other)
69 jgs 117 {
70 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
71 jgs 82 swap(m_data,other.m_data);
72     swap(m_blockSize,other.m_blockSize);
73     swap(m_numRows,other.m_numRows);
74     swap(m_numCols,other.m_numCols);
75 jgs 117 }
76 jgs 82
77     DataBlocks2D&
78     DataBlocks2D::operator=(const DataBlocks2D& other)
79 jgs 117 {
80 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
81 jgs 82 DataBlocks2D temp(other);
82     Swap(temp);
83     return *this;
84 jgs 117 }
85 jgs 123
86     int
87     DataBlocks2D::archiveData(ofstream& archiveFile,
88     const ValueType::size_type noValues) const
89     {
90 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
91     return (m_data.archiveData(archiveFile, noValues));
92 jgs 123 }
93    
94     int
95     DataBlocks2D::extractData(ifstream& archiveFile,
96     const ValueType::size_type noValues)
97     {
98 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
99     return (m_data.extractData(archiveFile, noValues));
100 jgs 123 }
101 jgs 117
102 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