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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 468 - (hide annotations)
Wed Jan 25 06:50:39 2006 UTC (13 years, 6 months ago) by jgs
Original Path: trunk/escript/src/Data/DataBlocks2D.cpp
File size: 3298 byte(s)
reorganised esysUtils to remove inc directory
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 82 #include "escript/Data/DataException.h"
16     #include "escript/Data/DataBlocks2D.h"
17 jgs 468 #include "EsysAssert.h"
18 jgs 82
19     #include <sstream>
20     #include <iostream>
21    
22     using namespace std;
23    
24     namespace escript {
25    
26     DataBlocks2D::DataBlocks2D():
27 jgs 151 m_numRows(0),
28     m_numCols(0),
29     m_blockSize(0)
30     {
31 jgs 117 }
32 jgs 82
33     DataBlocks2D::DataBlocks2D(const DataBlocks2D& other):
34 jgs 151 m_numRows(other.m_numRows),
35     m_numCols(other.m_numCols),
36     m_blockSize(other.m_blockSize)
37 jgs 117 {
38 jgs 82 m_data=other.m_data;
39 jgs 117 }
40 jgs 82
41     DataBlocks2D::DataBlocks2D(int numRows, int numCols, int blockSize):
42 jgs 151 m_numRows(numRows),
43     m_numCols(numCols),
44     m_blockSize(blockSize)
45 jgs 117 {
46 jgs 82 resize(m_numRows,numCols,blockSize);
47 jgs 117 }
48 jgs 82
49     DataBlocks2D::~DataBlocks2D()
50 jgs 151 {
51     m_numRows=-1;
52     m_numCols=-1;
53     m_blockSize=-1;
54 jgs 117 }
55 jgs 82
56     void
57     DataBlocks2D::resize(int numRows, int numCols, int blockSize)
58 jgs 117 {
59 jgs 151 if (numRows < 1 || numCols < 1 || blockSize < 1) {
60     stringstream temp;
61     temp << "DataBlocks2D: Error - Invalid resize parameter. numRows: " << numRows
62 jgs 82 << " numCols: " << numCols << " blockSize: " << blockSize;
63 jgs 151 throw DataException(temp.str());
64 jgs 82 }
65     ValueType::size_type size=numRows*numCols*blockSize;
66 jgs 151 m_data.resize(size, 0.0, numCols*blockSize);
67 jgs 82 m_numRows=numRows;
68     m_numCols=numCols;
69     m_blockSize=blockSize;
70 jgs 117 }
71 jgs 82
72     void
73     DataBlocks2D::Swap(DataBlocks2D& other)
74 jgs 117 {
75 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
76 jgs 82 swap(m_data,other.m_data);
77     swap(m_blockSize,other.m_blockSize);
78     swap(m_numRows,other.m_numRows);
79     swap(m_numCols,other.m_numCols);
80 jgs 117 }
81 jgs 82
82     DataBlocks2D&
83     DataBlocks2D::operator=(const DataBlocks2D& other)
84 jgs 117 {
85 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
86 jgs 82 DataBlocks2D temp(other);
87     Swap(temp);
88     return *this;
89 jgs 117 }
90 jgs 123
91     int
92     DataBlocks2D::archiveData(ofstream& archiveFile,
93     const ValueType::size_type noValues) const
94     {
95 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
96     return (m_data.archiveData(archiveFile, noValues));
97 jgs 123 }
98    
99     int
100     DataBlocks2D::extractData(ifstream& archiveFile,
101     const ValueType::size_type noValues)
102     {
103 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
104     return (m_data.extractData(archiveFile, noValues));
105 jgs 123 }
106 jgs 117
107 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