OutputFileHandler.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef OUTPUTFILEHANDLER_HPP_
00037 #define OUTPUTFILEHANDLER_HPP_
00038
00039 #include <string>
00040 #include <fstream>
00041 #include <sstream>
00042 #include <memory>
00043
00044 class FileFinder;
00045
00047 typedef std::auto_ptr<std::ofstream> out_stream;
00048
00054 class OutputFileHandler
00055 {
00056 public:
00070 OutputFileHandler(const std::string& rDirectory,
00071 bool cleanOutputDirectory = true);
00072
00085 OutputFileHandler(const FileFinder& rDirectory,
00086 bool cleanOutputDirectory = true);
00087
00099 static std::string GetChasteTestOutputDirectory();
00100
00105 std::string GetOutputDirectoryFullPath() const;
00106
00110 void SetArchiveDirectory() const;
00111
00121 out_stream OpenOutputFile(const std::string& rFileName,
00122 std::ios_base::openmode mode=std::ios::out | std::ios::trunc) const;
00123
00137 out_stream OpenOutputFile(const std::string& rFileName,
00138 unsigned number,
00139 const std::string& rFileFormat,
00140 std::ios_base::openmode mode=std::ios::out | std::ios::trunc) const;
00141
00150 FileFinder CopyFileTo(const FileFinder& rSourceFile) const;
00151
00157 FileFinder FindFile(std::string leafName) const;
00158
00160 static const std::string SIG_FILE_NAME;
00161
00162 private:
00163
00164 std::string mDirectory;
00165
00172 void CommonConstructor(const std::string& rDirectory,
00173 bool cleanOutputDirectory);
00174
00180 static void AddTrailingSlash(std::string& rDirectory);
00181
00197 std::string MakeFoldersAndReturnFullPath(const std::string& rDirectory) const;
00198 };
00199
00200 #endif