1 |
#ifndef __READWRITE_H__ |
2 |
#define __READWRITE_H__ |
3 |
|
4 |
#define _FILE_OFFSET_BITS 64 |
5 |
|
6 |
#include <iostream> |
7 |
#include <fstream> |
8 |
|
9 |
#include <string.h> |
10 |
#include <stdio.h> |
11 |
#include <stdlib.h> |
12 |
#include <unistd.h> |
13 |
#include <sys/types.h> |
14 |
#include <sys/stat.h> |
15 |
|
16 |
|
17 |
#include "Atom.hpp" |
18 |
#include "SimInfo.hpp" |
19 |
#include "Thermo.hpp" |
20 |
|
21 |
using namespace std; |
22 |
|
23 |
class FilePos{ |
24 |
|
25 |
public: |
26 |
FilePos(){ |
27 |
myPos = NULL; |
28 |
next = NULL; |
29 |
} |
30 |
FilePos( fpos_t* thePos ) { |
31 |
myPos = thePos; |
32 |
next = NULL; |
33 |
} |
34 |
~FilePos(){ |
35 |
if( next != NULL ) delete next; |
36 |
if( myPos != NULL ) delete myPos; |
37 |
} |
38 |
|
39 |
void add( fpos_t *thePos ){ |
40 |
if( next != NULL ) |
41 |
next->add( thePos ); |
42 |
else |
43 |
next = new FilePos( thePos ); |
44 |
} |
45 |
|
46 |
FilePos &operator=(fpos_t *thePos){ myPos = thePos; return *this; } |
47 |
|
48 |
void setPos( fpos_t *thePos ){ myPos = thePos; } |
49 |
fpos_t *getPos( void ){ return myPos; } |
50 |
|
51 |
FilePos* getNext( void ) { return next; } |
52 |
private: |
53 |
|
54 |
fpos_t *myPos; |
55 |
FilePos* next; |
56 |
|
57 |
}; |
58 |
|
59 |
class DumpWriter{ |
60 |
|
61 |
public: |
62 |
DumpWriter( SimInfo* the_entry_plug ); |
63 |
~DumpWriter(); |
64 |
|
65 |
void writeDump( double currentTime ); |
66 |
void writeFinal( double finalTime ); |
67 |
|
68 |
private: |
69 |
SimInfo* entry_plug; |
70 |
ofstream outFile; |
71 |
char outName[500]; |
72 |
}; |
73 |
|
74 |
class StatWriter{ |
75 |
|
76 |
public: |
77 |
StatWriter( SimInfo* the_entry_plug ); |
78 |
~StatWriter(); |
79 |
|
80 |
void writeStat( double currentTime ); |
81 |
|
82 |
private: |
83 |
|
84 |
SimInfo* entry_plug; |
85 |
ofstream outFile; |
86 |
char outName[500]; |
87 |
Thermo* tStats; |
88 |
|
89 |
}; |
90 |
|
91 |
class InitializeFromFile{ |
92 |
|
93 |
public: |
94 |
InitializeFromFile( char *in_name ); |
95 |
~InitializeFromFile(); |
96 |
|
97 |
void readInit( SimInfo* the_entry_plug ); |
98 |
|
99 |
private: |
100 |
char* parseDumpLine(char* line, int atomIndex); |
101 |
char* parseBoxLine(char* line, double boxMat[9], double &time ); |
102 |
FILE *c_in_file; |
103 |
char c_in_name[500]; |
104 |
SimInfo* simnfo; |
105 |
}; |
106 |
|
107 |
class DumpReader{ |
108 |
|
109 |
public: |
110 |
DumpReader( char *in_name ); |
111 |
~DumpReader(); |
112 |
|
113 |
int getNframes(); |
114 |
void scanFile( void ); |
115 |
|
116 |
void getNextFrame() {} |
117 |
void readFrame(SimInfo* the_simnfo, int whichFrame); |
118 |
|
119 |
private: |
120 |
|
121 |
void readSet( int whichFrame ); |
122 |
char* parseDumpLine(char* line, int atomIndex); |
123 |
char* parseCommentLine(char* line, double &time, double boxMat[9] ); |
124 |
FILE *inFile; |
125 |
char inName[500]; |
126 |
bool isScanned; |
127 |
int nFrames; |
128 |
|
129 |
FilePos** frameStart; |
130 |
FilePos* headFP; |
131 |
|
132 |
SimInfo *simnfo; |
133 |
}; |
134 |
|
135 |
|
136 |
|
137 |
#endif |