//: C02:Datalog.cpp {O} // From Thinking in C++, 2nd Edition // Available at http://www.BruceEckel.com // (c) Bruce Eckel 2000 // Copyright notice in Copyright.txt // Datapoint member functions #include "DataLogger.h" #include #include using namespace std; tm DataPoint::getTime() { return time; } void DataPoint::setTime(tm t) { time = t; } const char* DataPoint::getLatitude() { return latitude; } void DataPoint::setLatitude(const char* l) { latitude[bsz - 1] = 0; strncpy(latitude, l, bsz - 1); } const char* DataPoint::getLongitude() { return longitude; } void DataPoint::setLongitude(const char* l) { longitude[bsz - 1] = 0; strncpy(longitude, l, bsz - 1); } double DataPoint::getDepth() { return depth; } void DataPoint::setDepth(double d) { depth = d; } double DataPoint::getTemperature() { return temperature; } void DataPoint::setTemperature(double t) { temperature = t; } void DataPoint::print(ostream& os) { os.setf(ios::fixed, ios::floatfield); os.precision(4); os.fill('0'); // Pad on left with '0' os << setw(2) << getTime().tm_mon << '\\' << setw(2) << getTime().tm_mday << '\\' << setw(2) << getTime().tm_year << ' ' << setw(2) << getTime().tm_hour << ':' << setw(2) << getTime().tm_min << ':' << setw(2) << getTime().tm_sec; os.fill(' '); // Pad on left with ' ' os << " Lat:" << setw(9) << getLatitude() << ", Long:" << setw(9) << getLongitude() << ", depth:" << setw(9) << getDepth() << ", temp:" << setw(9) << getTemperature() << endl; } ///:~