MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Files.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 
27 #ifndef OUTPUTFILES_H_
28 #define OUTPUTFILES_H_
29 #include "File.h"
30 #include "GeneralDefine.h"
31 
42 class Files
43 {
44 public:
45 
46 //Constructors
50  Files();
51 
55  virtual ~Files();
56 
60  Files(const Files& other);
61 
62  //setters and getters
63 
70  File& getDataFile();
71 
78  File& getEneFile();
79 
86  File& getFStatFile();
87 
95 
102  File& getStatFile();
103 
110  const File& getDataFile() const;
111 
118  const File& getEneFile() const;
119 
126  const File& getFStatFile() const;
127 
134  const File& getRestartFile() const;
135 
142  const File& getStatFile() const;
143 
147  const std::string& getName() const;
148 
152  void setName(const std::string& name);
153 
157  void setName(const char* name);
158 
162  void setSaveCount(unsigned int saveCount);
163 
167  void setFileType(FileType fileType);
168 
172  void setOpenMode(std::fstream::openmode openMode);
173 
174  //other member functions
175 
179  void resetFileCounter();
183  void read(std::istream& is);
187  void write(std::ostream& os) const;
191  void openFiles();
195  void closeFiles();
199  void setNextSavedTimeStep(unsigned int nextSavedTimeStep);
200 
205 
210 
215 
220 
225 
226 private:
230  std::string name_;
231 
232 };
233 
234 #endif /* OUTPUTFILES_H_ */
Every simulation requires data files to store all the information necessary for visualisation and ana...
Definition: Files.h:42
void setNextSavedTimeStep(unsigned int nextSavedTimeStep)
Sets the next time step for all the files (ene, data, fstat, restart, stat) at which the data is to b...
Definition: Files.cc:263
MERCURY_DEPRECATED File & getDataFile()
The non const version. Allows one to edit the File::dataFile.
Definition: Files.cc:61
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: Files.h:219
void closeFiles()
Closes all files (ene, data, fstat, restart, stat) that were opened to read or write.
Definition: Files.cc:252
Files()
A constructor.
Definition: Files.cc:33
MERCURY_DEPRECATED File & getStatFile()
The non const version. Allows to edit the File::statFile.
Definition: Files.cc:89
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:170
#define MERCURY_DEPRECATED
Definition: GeneralDefine.h:37
FileType
With FileType options, one is able to choose if data is to be read/written from/into no or single or ...
Definition: File.h:35
void setOpenMode(std::fstream::openmode openMode)
Sets File::openMode_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:201
MERCURY_DEPRECATED File & getFStatFile()
The non const version. Allows to edit the File::fStatFile.
Definition: Files.cc:75
virtual ~Files()
A destructor, watch out its a virtual destructor.
Definition: Files.cc:45
std::string name_
the name of the problem, used, e.g., for the files
Definition: Files.h:230
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: Files.h:214
void openFiles()
Opens all the files (ene, data, fstat, restart, stat) for reading and writing purposes.
Definition: Files.cc:241
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: Files.cc:150
void resetFileCounter()
Resets the file counter for each file i.e. for ene, data, fstat, restart, stat)
Definition: Files.cc:190
MERCURY_DEPRECATED File & getEneFile()
The non const version. Allows to edit the File::eneFile.
Definition: Files.cc:68
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: Files.h:209
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:139
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: Files.h:204
void write(std::ostream &os) const
Writes data into a file from the member variables name_, restartFile, dataFile etc.
Definition: Files.cc:229
void read(std::istream &is)
Extracts data from the input stream (which is basically a file you want to read from) into name_...
Definition: Files.cc:212
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: Files.h:224
Definition: File.h:78
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: Files.cc:132
MERCURY_DEPRECATED File & getRestartFile()
The non const version. Allows to edit the File::restartFile.
Definition: Files.cc:82