]>
Commit | Line | Data |
---|---|---|
ead15931 RC |
1 | /* |
2 | * Copyright (c) 2003, Robert Collins | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by Robert Collins <rbtcollins@hotmail.com> | |
13 | * | |
14 | */ | |
15 | ||
16 | #if 0 | |
17 | static const char *cvsid = | |
18 | "\n%%% $Id$\n"; | |
19 | #endif | |
20 | ||
21 | #include "site.h" | |
22 | #include "win32.h" | |
23 | #include <stdio.h> | |
24 | #include <stdlib.h> | |
25 | #include <string.h> | |
26 | #include <process.h> | |
27 | #include <algorithm> | |
28 | ||
29 | #include "LogSingleton.h" | |
30 | #include "io_stream.h" | |
31 | ||
32 | #include "port.h" | |
33 | #include "Exception.h" | |
34 | #include "UserSettings.h" | |
35 | ||
36 | using namespace std; | |
37 | ||
38 | UserSettings & | |
39 | UserSettings::Instance() | |
40 | { | |
ead15931 RC |
41 | if (Instance_.inited != 42) |
42 | Instance_.init (); | |
43 | return Instance_; | |
44 | } | |
45 | ||
46 | void | |
47 | UserSettings::init () | |
48 | { | |
aaeee283 | 49 | *this = UserSettings(); |
ead15931 RC |
50 | inited = 42; |
51 | } | |
52 | ||
53 | UserSettings UserSettings::Instance_; | |
54 | ||
55 | void | |
56 | UserSettings::registerSetting(UserSetting &aSetting) | |
57 | { | |
58 | settings.push_back(&aSetting); | |
59 | } | |
60 | ||
61 | void | |
62 | UserSettings::deRegisterSetting(UserSetting &aSetting) | |
63 | { | |
64 | Settings::iterator i = find(settings.begin(), settings.end(), &aSetting); | |
65 | if (i == settings.end()) | |
66 | throw new Exception ("__LINE__ __FILE__", String ("Attempt to deregister non registered setting!"), APPERR_LOGIC_ERROR); | |
67 | settings.erase(i); | |
68 | } |