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

#include <stdio.h>
5
6
#include <string>
#include <fstream>
kirov's avatar
kirov committed
7
#include "HwFrameInfo.h"
8
9
10
11

namespace lima {


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

18
19
20
	BufferSave( FileFormat format = Raw, 
		    const std::string& prefix = "img", 
		    int idx = 0, const std::string& suffix = "", 
21
22
		    bool overwrite = false , int tot_file_frames = 1);
	~BufferSave( );
23

24
	void writeFrame( const HwFrameInfoType& finfo );
25

26
27
	void setPrefix(const std::string& prefix);
	void getPrefix(std::string& prefix) const;
28

29
30
	void setFormat(FileFormat  format);
	void getFormat(FileFormat& format) const;
31

32
33
	void setIndex(int  idx);
	void getIndex(int& idx) const;
34

35
36
	void setTotFileFrames(int  tot_file_frames);
	void getTotFileFrames(int& tot_file_frames) const;
37

38
	void getOpenFileName(std::string& file_name) const;
39
	bool isFileOpen() const;
40
41

  private:
42
	std::string getDefSuffix() const;
43
44
45
	void openFile();
	void closeFile();

46
	void writeEdfHeader( const HwFrameInfoType& finfo );
47
48

	FileFormat m_format;
49
	std::string m_prefix;
50
	int m_idx;
51
52
	std::string m_suffix;
	std::string m_file_name;
53
54
55
	bool m_overwrite;
	int m_written_frames;
	int m_tot_file_frames;
56
	HwFrameInfoType m_last_frame;
57
	std::ofstream *m_fout;
58
59
60
61
62
63
};


}

#endif /* BUFFERSAVE_H */