1#ifndef SETTINGS_H
2#define SETTINGS_H
3
4
5/***************************************************
6	settings.h
7	Mechanisms for managing the settings setting/retireval for AutoRaise
8
9	2002 mmu_man
10	from Deskscope:
11	2000 Shamyl Zakariya
12***************************************************/
13#include "common.h"
14
15/****************************************
16	AutoRaiseSettings
17	Simple class for getting and setting prefs.
18	Instantiating will open up settings file
19	Destroying will write settings plus any changes
20	back into the file.
21
22	Settings file won't be updated until AutoRaiseSettings
23	destructor is called. Doens't matter if it's allocated off
24	heap or stack. I recommend stack, though, to keep likelyhood
25	of race conditions down.
26
27	File is defined in common.h as SETTINGS_FILE
28
29****************************************/
30
31// make adding configuration fields easier
32#define CONF_ADDPROP(_type, _name) \
33protected:\
34		_type _conf##_name;\
35public:\
36		void Set##_name(_type value);\
37		_type _name();
38
39class AutoRaiseSettings
40{
41	protected:
42		BFile _settingsFile;
43		BMessage _settingsMessage;
44
45
46
47		BMessage openSettingsFile();
48		void closeSettingsFile();
49
50	public:
51		AutoRaiseSettings();
52		~AutoRaiseSettings();
53
54CONF_ADDPROP(bool, Active)
55CONF_ADDPROP(bigtime_t, Delay)
56CONF_ADDPROP(int32, Mode)
57
58};
59
60#undef CONF_ADDPROP
61
62#endif
63