xref: /haiku/src/apps/autoraise/settings.h (revision 107712bf01c9777592fd24f7c06c455d1110df0a)
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) \
33 protected:\
34 		_type _conf##_name;\
35 public:\
36 		void Set##_name(_type value);\
37 		_type _name();
38 
39 class 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 
54 CONF_ADDPROP(bool, Active)
55 CONF_ADDPROP(bigtime_t, Delay)
56 CONF_ADDPROP(int32, Mode)
57 
58 };
59 
60 #undef CONF_ADDPROP
61 
62 #endif
63