-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.hh
94 lines (74 loc) · 2.35 KB
/
form.hh
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
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef FORM_HH
#define FORM_HH
#include <Wt/WContainerWidget>
#include <Wt/WTextArea>
#include <Wt/WPushButton>
#include <Wt/WComboBox>
#include <Wt/WLineEdit>
#include <Wt/WTimer>
#include <Wt/WTabWidget>
#include <vector>
#include <fstream>
#include <boost/thread.hpp>
class cruncher {
public:
enum cstate { NONE, COMPILING, RUNNING, COMPILE_ERROR, RUN_ERROR, SUCCESS };
private:
cstate crunch_state_;
std::string temp_dir_;
std::ofstream log;
bool compile(const std::string &src_name_, const std::string &prod,
const std::string &exe_name, const std::string &cache_dir);
void run(const std::string &prod, const std::string &exe_name,
const std::vector<std::string> &seqs);
public:
cruncher();
void crunch(const std::string &src_name,
const std::string &prod, const std::string &exe_name,
const std::vector<std::string> &seqs, const std::string &cache_dir);
cstate state() const { return crunch_state_; }
const std::string temp_dir() const { return temp_dir_; }
};
class form : public Wt::WContainerWidget {
private:
Wt::WTextArea *output_;
Wt::WContainerWidget *input_box_, *algebra_box_, *control_box_;
Wt::WText *status_;
Wt::WText *header_;
Wt::WContainerWidget *tabs_;
std::vector<std::string> algebras_;
std::vector<Wt::WComboBox*> combos_;
std::vector<Wt::WLineEdit*> lines_;
Wt::WTimer timer_;
unsigned algebra_count_;
unsigned tracks_;
std::vector<std::string> example_;
std::vector<std::string> files_;
void update();
void up_algebras();
void up_seqs();
void add_combo();
void rm_combo();
std::string src_name_;
boost::thread *thread_;
cruncher cruncher_;
static const unsigned start_interval_;
unsigned check_count_;
std::string mk_prod(const std::vector<std::string> &v);
std::string mk_exe_name(const std::vector<std::string> &v);
void mk_sel(std::vector<std::string> &sel);
void mk_input(std::vector<std::string> &seqs);
void cp_files(const std::string &dest);
void compute();
void check_finished();
void update_status();
void clean_thread();
void display_output();
void create_code(const std::string &filename);
void display_example();
public:
form(Wt::WContainerWidget *p = 0);
~form();
void read_file(const std::string &name);
};
#endif