forked from GCUROBOT-Visual-Group/littletest_jun
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetting.hpp
More file actions
82 lines (70 loc) · 1.63 KB
/
setting.hpp
File metadata and controls
82 lines (70 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// #pragma once
#ifndef _SETTING_HPP
#define _SETTING_HPP
#include <iostream>
#include <string>
#include <memory>
#include <opencv4/opencv2/opencv.hpp>
using namespace std;
using namespace cv;
//数据结构体
struct RuneParam
{
int test_int;
float test_float;
double test_double;
RuneParam()
{
test_float = 0.f;
test_int = 0;
test_double =0.0;
}
};
class Settings {
public:
//构造函数
Settings(const string& filename)
{
//显示参数文件是否读取正确
FileStorage setting_fs(filename, FileStorage::READ);
read(setting_fs);
setting_fs.release();
// cout<<"file:"<<file<<endl;
}
//读取数据
void readData(const string& filename)
{
FileStorage read_fs(filename, FileStorage::READ);
read(read_fs);
read_fs.release();
}
//写入数据
void writeData(string& filename) const
{
FileStorage write_fs(filename, FileStorage::WRITE);
write(write_fs);
write_fs.release();
}
private:
void read(const FileStorage& fs)
{
//TODO:for debug image
//TODO:for flag
//TODO:for armor value
//TODO:for buff value
fs["show_int"] >> this->rune->test_int;
fs["show_float"] >>this->rune->test_float;
fs["show_double"]>>this->rune->test_double;
}
void write(FileStorage& fs) const
{
fs << "show_int" << this->rune->test_int;
//TODO:for debug image
//TODO:for flag
//TODO:for armor value
//TODO:for buff value
}
RuneParam *rune;
string file;
};
#endif