~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to lib/prefs.h

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
struct GLOBAL_PREFS_MASK {
38
38
    bool run_on_batteries;
39
39
    bool run_if_user_active;
 
40
    bool run_gpu_if_user_active;
40
41
    bool idle_time_to_run;
41
42
    bool suspend_if_no_recent_input;
 
43
    bool suspend_cpu_usage;
42
44
    bool start_hour;
43
45
    bool end_hour;
44
46
    bool net_start_hour;
62
64
    bool max_bytes_sec_up;
63
65
    bool max_bytes_sec_down;
64
66
    bool cpu_usage_limit;
 
67
    bool daily_xfer_limit_mb;
 
68
    bool daily_xfer_period_days;
65
69
 
66
70
    GLOBAL_PREFS_MASK();
67
71
    void clear();
74
78
// 0..24
75
79
// run always if start==end or start==0, end=24
76
80
// don't run at all if start=24, end=0
77
 
class TIME_SPAN {
78
 
public:
 
81
//
 
82
struct TIME_SPAN {
 
83
    bool present;
 
84
    double start_hour;
 
85
    double end_hour;
 
86
 
79
87
    enum TimeMode {
80
88
        Always = 7000,
81
89
        Never,
82
90
        Between
83
91
    };
84
 
    TIME_SPAN()
85
 
        : start_hour(0), end_hour(0) {}
86
 
    TIME_SPAN(double start, double end)
87
 
        : start_hour(start), end_hour(end) {}
88
 
 
89
 
    bool        suspended(double hour) const;
90
 
    TimeMode    mode() const;
91
 
 
92
 
    double      start_hour;
93
 
    double      end_hour;
94
 
    
 
92
    TIME_SPAN() : start_hour(0), end_hour(0) {}
 
93
    TIME_SPAN(double start, double end) : start_hour(start), end_hour(end) {}
 
94
 
 
95
    bool suspended(double hour) const;
 
96
    TimeMode mode() const;
95
97
};
96
98
 
97
99
 
98
 
class WEEK_PREFS {
99
 
public:
100
 
    WEEK_PREFS();
101
 
    WEEK_PREFS(const WEEK_PREFS& original);
102
 
    ~WEEK_PREFS();
103
 
 
104
 
    TIME_SPAN* get(int day) const;
 
100
struct WEEK_PREFS {
 
101
    TIME_SPAN days[7];
 
102
 
 
103
    void clear() {
 
104
        memset(this, 0, sizeof(WEEK_PREFS));
 
105
    }
 
106
    WEEK_PREFS() {
 
107
        clear();
 
108
    }
 
109
 
105
110
    void set(int day, double start, double end);
106
111
    void set(int day, TIME_SPAN* time);
107
112
    void unset(int day);
108
 
    void clear();
109
 
    WEEK_PREFS& operator=(const WEEK_PREFS& rhs);
110
113
 
111
114
protected:
112
115
    void copy(const WEEK_PREFS& original);
113
 
    TIME_SPAN* days[7];
114
 
 
115
116
};
116
117
 
117
118
 
118
 
class TIME_PREFS : public TIME_SPAN {
119
 
public:
120
 
    TIME_PREFS() : TIME_SPAN() {}
121
 
    TIME_PREFS(double start, double end)
122
 
        : TIME_SPAN(start, end) {}
123
 
    
124
 
    void        clear();
125
 
    bool        suspended() const;
126
 
    
127
 
    WEEK_PREFS  week;
 
119
struct TIME_PREFS : public TIME_SPAN {
 
120
    WEEK_PREFS week;
 
121
 
 
122
    TIME_PREFS() {}
 
123
    TIME_PREFS(double start, double end) {
 
124
        start_hour = start;
 
125
        end_hour = end;
 
126
    }
 
127
    
 
128
    void clear();
 
129
    bool suspended() const;
 
130
    
128
131
};
129
132
 
130
133
 
134
137
        // poorly named; what it really means is:
135
138
        // if false, suspend while on batteries
136
139
    bool run_if_user_active;
 
140
    bool run_gpu_if_user_active;
137
141
    double idle_time_to_run;
138
142
    double suspend_if_no_recent_input;
 
143
    double suspend_cpu_usage;
139
144
    bool leave_apps_in_memory;
140
145
    bool confirm_before_connecting;
141
146
    bool hangup_if_dialed;
147
152
    double max_ncpus_pct;
148
153
    int max_ncpus;
149
154
    double cpu_scheduling_period_minutes;
 
155
        // length of a time slice.
 
156
        // scheduling happens more often.
150
157
    double disk_interval;
151
158
    double disk_max_used_gb;
152
159
    double disk_max_used_pct;
157
164
    double max_bytes_sec_up;
158
165
    double max_bytes_sec_down;
159
166
    double cpu_usage_limit;
 
167
    double daily_xfer_limit_mb;
 
168
    int daily_xfer_period_days;
160
169
    char source_project[256];
161
170
    char source_scheduler[256];
162
171
    bool host_specific;
171
180
    int parse_file(const char* filename, const char* venue, bool& found_venue);
172
181
    int write(MIOFILE&);
173
182
    int write_subset(MIOFILE&, GLOBAL_PREFS_MASK&);
 
183
    void write_day_prefs(MIOFILE&);
174
184
    inline double cpu_scheduling_period() {
175
185
        return cpu_scheduling_period_minutes*60;
176
186
    }