|
1 | 1 | package eu.mihosoft.vrl.v3d.parametrics; |
2 | 2 |
|
3 | 3 | import java.io.File; |
| 4 | +import java.io.IOException; |
| 5 | +import java.nio.file.Files; |
| 6 | +import java.util.HashMap; |
4 | 7 | import java.util.concurrent.CopyOnWriteArrayList; |
5 | 8 |
|
6 | | -public class CSGDatabase { |
7 | | - private static CSGDatabaseInstance instance = new CSGDatabaseInstance(new File("CSGdatabase.json")); |
8 | | - |
9 | | - public static void set(String key, Parameter value) { |
10 | | - getInstance().set(key, value); |
11 | | - } |
12 | | - |
13 | | - public static Parameter get(String key) { |
14 | | - return getInstance().get(key); |
15 | | - } |
16 | | - |
17 | | - public static void clear() { |
18 | | - getInstance().clear(); |
19 | | - } |
20 | | - |
21 | | - public static void addParameterListener(String key, IParameterChanged l) { |
22 | | - getInstance().addParameterListener(key, l); |
23 | | - } |
24 | | - |
25 | | - public static void clearParameterListeners(String key) { |
26 | | - getInstance().clearParameterListeners(key); |
27 | | - } |
28 | | - |
29 | | - public static void removeParameterListener(String key, IParameterChanged l) { |
30 | | - getInstance().removeParameterListener(key, l); |
31 | | - } |
32 | | - |
33 | | - public static CopyOnWriteArrayList<IParameterChanged> getParamListeners(String key) { |
34 | | - return getInstance().getParamListeners(key); |
35 | | - } |
36 | | - |
37 | | - public static void delete(String key) { |
38 | | - getInstance().delete(key); |
39 | | - } |
40 | | - |
41 | | - public static void loadDatabaseFromFile(File f) { |
42 | | - getInstance().loadDatabaseFromFile(f); |
43 | | - } |
44 | | - |
45 | | - public static String getDataBaseString() { |
46 | | - return getInstance().getDataBaseString(); |
47 | | - } |
48 | 9 |
|
49 | | - public static void saveDatabase() { |
50 | | - getInstance().saveDatabase(); |
51 | | - } |
52 | | - |
53 | | - |
54 | | - public static File getDbFile() { |
55 | | - return getInstance().getDbFile(); |
56 | | - } |
| 10 | +import eu.mihosoft.vrl.v3d.CSG; |
57 | 11 |
|
58 | | - public static void reLoadDbFile() { |
59 | | - getInstance().reLoadDbFile(); |
60 | | - } |
| 12 | +public class CSGDatabase { |
| 13 | + private static CSGDatabaseInstance instance ; |
| 14 | +// public static void set(String key, Parameter value) { |
| 15 | +// getInstance().set(key, value); |
| 16 | +// } |
| 17 | +// |
| 18 | +// public static Parameter get(String key) { |
| 19 | +// return getInstance().get(key); |
| 20 | +// } |
| 21 | +// |
| 22 | +// public static void clear() { |
| 23 | +// getInstance().clear(); |
| 24 | +// } |
| 25 | +// |
| 26 | +// public static void addParameterListener(String key, IParameterChanged l) { |
| 27 | +// getInstance().addParameterListener(key, l); |
| 28 | +// } |
| 29 | +// |
| 30 | +// public static void clearParameterListeners(String key) { |
| 31 | +// getInstance().clearParameterListeners(key); |
| 32 | +// } |
| 33 | +// |
| 34 | +// public static void removeParameterListener(String key, IParameterChanged l) { |
| 35 | +// getInstance().removeParameterListener(key, l); |
| 36 | +// } |
| 37 | +// |
| 38 | +// public static CopyOnWriteArrayList<IParameterChanged> getParamListeners(String key) { |
| 39 | +// return getInstance().getParamListeners(key); |
| 40 | +// } |
| 41 | +// |
| 42 | +// public static void delete(String key) { |
| 43 | +// getInstance().delete(key); |
| 44 | +// } |
| 45 | +// |
| 46 | +// public static void loadDatabaseFromFile(File f) { |
| 47 | +// getInstance().loadDatabaseFromFile(f); |
| 48 | +// } |
| 49 | +// |
| 50 | +// public static String getDataBaseString() { |
| 51 | +// return getInstance().getDataBaseString(); |
| 52 | +// } |
| 53 | +// |
| 54 | +// public static void saveDatabase() { |
| 55 | +// getInstance().saveDatabase(); |
| 56 | +// } |
| 57 | +// |
| 58 | +// |
| 59 | +// public static File getDbFile() { |
| 60 | +// return getInstance().getDbFile(); |
| 61 | +// } |
| 62 | +// |
| 63 | +// public static void reLoadDbFile() { |
| 64 | +// getInstance().reLoadDbFile(); |
| 65 | +// } |
61 | 66 |
|
62 | 67 | public static CSGDatabaseInstance getInstance() { |
| 68 | + new Exception("Depricated database access!").printStackTrace(); |
| 69 | + if(instance==null) { |
| 70 | + try { |
| 71 | + instance = new CSGDatabaseInstance( Files.createTempFile("CSGDatabase", ".json").toFile()); |
| 72 | + } catch (IOException e) { |
| 73 | + throw new RuntimeException(e); |
| 74 | + } |
| 75 | + |
| 76 | + } |
63 | 77 | return instance; |
64 | 78 | } |
65 | | - |
66 | 79 | public static void setInstance(CSGDatabaseInstance instance) { |
67 | 80 | System.out.println("\n\nCSG Instance Set here to "+instance.getDbFile().getAbsolutePath()+"\n\n"); |
68 | 81 | CSGDatabase.instance = instance; |
|
0 commit comments