BufferSave.h 1.25 KB
Newer Older
1
2
#ifndef BUFFERSAVE_H
#define BUFFERSAVE_H
3
4

#include <stdio.h>
5
6
7
#include <string>
#include <fstream>
#include "FrameBuilder.h"
8
#include "HwFrameCallback.h"
9
10
11
12

namespace lima {


13
14
15
16
17
class BufferSave {
  public :
	enum FileFormat {
		Raw, EDF,
	};
18

19
	typedef std::string String;
20

21
22
23
24
25
	BufferSave( );
	BufferSave( FileFormat format, const String& prefix, 
		    int idx = 0, const String& suffix = "", 
		    bool overwrite = false , int tot_file_frames = 1);
	~BufferSave( );
26

27
	void writeFrame( const FrameInfoType& finfo );
28

29
30
	void setPrefix(const String& prefix);
	void getPrefix(String& prefix) const;
31

32
33
	void setFormat(FileFormat  format);
	void getFormat(FileFormat& format) const;
34

35
36
	void setIndex(int  idx);
	void getIndex(int& idx) const;
37

38
39
	void setTotFileFrames(int  tot_file_frames);
	void getTotFileFrames(int& tot_file_frames) const;
40

41
42
	void getOpenFileName(String& file_name) const;
	bool isFileOpen() const;
43
44

  private:
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
	String getDefSuffix() const;
	void openFile();
	void closeFile();

	void writeEdfHeader( const FrameInfoType& finfo );

	FileFormat m_format;
	String m_prefix;
	int m_idx;
	String m_suffix;
	String m_file_name;
	bool m_overwrite;
	int m_written_frames;
	int m_tot_file_frames;
	FrameInfoType m_last_frame;
	std::ofstream *m_fout;
61
62
63
64
65
66
};


}

#endif /* BUFFERSAVE_H */