Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
DefectiveCrystalBaseIO.h
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MoDELib is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_DefectiveCrystalBaseIO_H_
9#define model_DefectiveCrystalBaseIO_H_
10
11#include <iostream> // std::cout
12#include <fstream> // std::ifstream
13#include <string> // std::ifstream
14
15
16namespace model
17{
18
20 {
21
22 const std::string outFolderName;
23 const std::string fileNamePrefix;
24 const std::string outFolderSuffix;
25
26 DefectiveCrystalBaseIO(const std::string& outFolderName_in,
27 const std::string& fileNamePrefix_in,
28 const std::string& outFolderSuffix_in="");
29
30 std::string getBinFilename(const size_t& runID);
31 std::string getTxtFilename(const size_t& runID);
32 std::string getTxtSegmentFilename(const size_t& runID);
33 bool isBinGood(const size_t& frameID);
34 bool isTxtGood(const size_t& frameID);
35
36 template<typename T>
37 static void binWrite(std::ofstream& of,const T& o)
38 {
39 of.write((char *) &o, (sizeof o));
40 }
41
42 template<typename T>
43 static void binRead(std::ifstream& file,
44 T*& memblock,
45 const size_t& arraySize)
46 {
47 memblock = new T [arraySize];
48 file.read (reinterpret_cast<char*>(memblock), arraySize*sizeof (T));
49 }
50
51 };
52
53}
54#endif
55
bool isBinGood(const size_t &frameID)
static void binWrite(std::ofstream &of, const T &o)
bool isTxtGood(const size_t &frameID)
std::string getTxtSegmentFilename(const size_t &runID)
DefectiveCrystalBaseIO(const std::string &outFolderName_in, const std::string &fileNamePrefix_in, const std::string &outFolderSuffix_in="")
static void binRead(std::ifstream &file, T *&memblock, const size_t &arraySize)
std::string getBinFilename(const size_t &runID)
std::string getTxtFilename(const size_t &runID)