[cig-commits] r15140 - in cs/spatialdata-0.1/trunk: libsrc/spatialdb tests/libtests/spatialdb
brad at geodynamics.org
brad at geodynamics.org
Mon Jun 8 10:00:55 PDT 2009
Author: brad
Date: 2009-06-08 10:00:54 -0700 (Mon, 08 Jun 2009)
New Revision: 15140
Modified:
cs/spatialdata-0.1/trunk/libsrc/spatialdb/TimeHistory.cc
cs/spatialdata-0.1/trunk/libsrc/spatialdb/TimeHistoryIO.cc
cs/spatialdata-0.1/trunk/tests/libtests/spatialdb/TestTimeHistory.cc
Log:
Minor cleanup.
Modified: cs/spatialdata-0.1/trunk/libsrc/spatialdb/TimeHistory.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/spatialdb/TimeHistory.cc 2009-06-08 16:01:22 UTC (rev 15139)
+++ cs/spatialdata-0.1/trunk/libsrc/spatialdb/TimeHistory.cc 2009-06-08 17:00:54 UTC (rev 15140)
@@ -70,7 +70,6 @@
_npts = 0;
} // close
-#include <iostream>
// ----------------------------------------------------------------------
// Query the database.
int
Modified: cs/spatialdata-0.1/trunk/libsrc/spatialdb/TimeHistoryIO.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/spatialdb/TimeHistoryIO.cc 2009-06-08 16:01:22 UTC (rev 15139)
+++ cs/spatialdata-0.1/trunk/libsrc/spatialdb/TimeHistoryIO.cc 2009-06-08 17:00:54 UTC (rev 15140)
@@ -31,13 +31,13 @@
// ----------------------------------------------------------------------
// Read time history file.
void
-spatialdata::spatialdb::TimeHistoryIO::read(double** time,
- double** amplitude,
+spatialdata::spatialdb::TimeHistoryIO::read(double** ptime,
+ double** pamplitude,
int* npts,
const char* filename)
{ // read
- assert(0 != time);
- assert(0 != amplitude);
+ assert(0 != ptime);
+ assert(0 != pamplitude);
assert(0 != npts);
try {
@@ -123,19 +123,23 @@
const double scale = uparser.parse(timeUnits.c_str());
const int size = *npts;
- delete[] *time; *time = (size > 0) ? new double[size] : 0;
- delete[] *amplitude; *amplitude = (size > 0) ? new double[size] : 0;
+
+ double* time = (size > 0) ? new double[size] : 0;
+ double* amplitude = (size > 0) ? new double[size] : 0;
for (int i=0; i < size; ++i) {
buffer.str(parser.next());
buffer.clear();
- buffer >> (*time)[i];
- buffer >> (*amplitude)[i];
- (*time)[i] *= scale;
+ buffer >> time[i];
+ buffer >> amplitude[i];
+ time[i] *= scale;
} // for
if (!filein.good())
throw std::runtime_error("Unknown error while reading.");
+
+ delete[] *ptime; *ptime = time;
+ delete[] *pamplitude; *pamplitude = amplitude;
} catch (const std::exception& err) {
std::ostringstream msg;
msg << "Error occurred while reading time history file '"
Modified: cs/spatialdata-0.1/trunk/tests/libtests/spatialdb/TestTimeHistory.cc
===================================================================
--- cs/spatialdata-0.1/trunk/tests/libtests/spatialdb/TestTimeHistory.cc 2009-06-08 16:01:22 UTC (rev 15139)
+++ cs/spatialdata-0.1/trunk/tests/libtests/spatialdb/TestTimeHistory.cc 2009-06-08 17:00:54 UTC (rev 15140)
@@ -60,6 +60,10 @@
TimeHistory th;
th.filename(filename);
+
+ // Test calling close on upopened db
+ th.close();
+
th.open();
units::Parser parser;
@@ -81,6 +85,8 @@
CPPUNIT_ASSERT_EQUAL(0, th._npts);
CPPUNIT_ASSERT(0 == th._time);
CPPUNIT_ASSERT(0 == th._amplitude);
+
+ th.close(); // Test calling close when already closed
} // testOpenClose
// ----------------------------------------------------------------------
More information about the CIG-COMMITS
mailing list