annotate src/OutputDataWriter.cpp @ 56:4394c9490716 tip

minor changes
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Mon, 24 Dec 2012 18:58:39 +0000
parents e359b9bad811
children
rev   line source
andrew@43 1 /*
andrew@43 2 * outputDataWriter.cpp
andrew@43 3 * MultipleAudioMathcher
andrew@43 4 *
andrew@43 5 * Created by Andrew on 25/04/2012.
andrew@43 6 * Copyright 2012 QMUL. All rights reserved.
andrew@43 7 *
andrew@43 8 */
andrew@43 9
andrew@43 10 #include "OutputDataWriter.h"
andrew@43 11
andrew@43 12 OutputDataWriter::OutputDataWriter(){
andrew@43 13 filepath = "../../../data/output.txt";
andrew@52 14 //openFile();
andrew@52 15 }
andrew@52 16
andrew@52 17 OutputDataWriter::~OutputDataWriter(){
andrew@52 18 closeFile();
andrew@43 19 }
andrew@43 20
andrew@43 21 void OutputDataWriter::writeOutput(const int& liveTime, const int& rehearsalTime, const int& playedRehearsalTime){
andrew@43 22
andrew@43 23 if (outputFile.is_open()){
andrew@43 24 outputFile << liveTime/1000.0 << "\t" << rehearsalTime/1000.0 << "\t" << playedRehearsalTime/1000.0 << endl;
andrew@43 25 }
andrew@43 26 }
andrew@43 27
andrew@52 28 void OutputDataWriter::writeValue(const double& valueOne, const double& valueTwo){
andrew@52 29
andrew@52 30 if (outputFile.is_open()){
andrew@52 31 outputFile << valueOne << "\t" << valueTwo << endl;
andrew@52 32 printf("write value %f %f\n", valueOne, valueTwo);
andrew@52 33 } else{
andrew@52 34 printf("trying to write value but file closed\n");
andrew@52 35 }
andrew@52 36 }
andrew@52 37
andrew@52 38
andrew@52 39 void OutputDataWriter::openFile(std::string pathname){
andrew@52 40 // closeFile();
andrew@52 41 filepath = pathname;
andrew@52 42 printf("opening file '%s'\n", pathname.c_str());
andrew@52 43 openFile();
andrew@52 44 }
andrew@52 45
andrew@43 46 void OutputDataWriter::openFile(){
andrew@52 47 if (!outputFile.is_open()){
andrew@52 48 outputFile.open(filepath.c_str());
andrew@52 49 //printf("opening file %s\n", filepath.c_str());
andrew@52 50 }else{
andrew@52 51 printf("file already open! %s\n", filepath.c_str());
andrew@52 52 }
andrew@43 53 }
andrew@43 54
andrew@43 55 void OutputDataWriter::closeFile(){
andrew@52 56 if (outputFile.is_open()){
andrew@43 57 outputFile.close();
andrew@52 58 printf("closing file '%s'\n", filepath.c_str());
andrew@52 59 }else {
andrew@52 60 printf("but file is not open to be closed\n");
andrew@52 61 }
andrew@43 62 }