SPH
Project.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "gui/Settings.h"
4 #include "gui/objects/Palette.h"
5 #include "run/Config.h"
6 #include "thread/CheckFunction.h"
7 
9 
10 
12 inline std::string getIdentifier(const std::string& name) {
13  std::string escaped = replaceAll(name, " ", "-");
14  return lowercase(escaped);
15 }
16 
17 class Project {
18 private:
19  GuiSettings gui;
21 
22  Project();
23 
24 public:
25  static Project& getInstance() {
26  static Project project;
27  return project;
28  }
29 
30  Project clone() const {
31  Project cloned;
32  cloned.gui = gui;
33  cloned.palettes = palettes.clone();
34  return cloned;
35  }
36 
37  void setPalette(const std::string& name, const Palette& palette) {
38  palettes.insert(name, palette);
39  }
40 
41  bool getPalette(const std::string& name, Palette& palette) const {
42  if (palettes.contains(name)) {
43  palette = palettes[name];
44  return true;
45  } else {
46  return false;
47  }
48  }
49 
52  return gui;
53  }
54 
55  const GuiSettings& getGuiSettings() const {
56  return gui;
57  }
58 
59  void save(Config& config);
60 
61  void load(Config& config);
62 
63 private:
64  void savePalettes(Config& config);
65  void saveGui(Config& config);
66 
67  void loadPalettes(Config& config);
68  void loadGui(Config& config);
69 };
70 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Helper functions to check the internal consistency of the code.
Interface for the configuration files storing job data.
#define NAMESPACE_SPH_END
Definition: Object.h:12
NAMESPACE_SPH_BEGIN std::string getIdentifier(const std::string &name)
Definition: Project.h:12
std::string replaceAll(const std::string &source, const std::string &old, const std::string &s)
Replaces all occurences of string with a new string.
std::string lowercase(const std::string &s)
Converts all uppercase characters to their lowercase variants. Other characters are unchanged.
Definition: StringUtils.cpp:94
Provides functionality for reading and writing configuration files.
Definition: Config.h:272
FlatMap clone() const
Definition: FlatMap.h:182
INLINE bool contains(const TKey &key) const
Returns true if the map contains element of given key.
Definition: FlatMap.h:140
INLINE TValue & insert(const TKey &key, const TValue &value)
Adds a new element into the map or sets new value of element with the same key.
Definition: FlatMap.h:65
Represents a color palette, used for mapping arbitrary number to a color.
Definition: Palette.h:25
Project clone() const
Definition: Project.h:30
bool getPalette(const std::string &name, Palette &palette) const
Definition: Project.h:41
const GuiSettings & getGuiSettings() const
Definition: Project.h:55
void load(Config &config)
Definition: Project.cpp:40
GuiSettings & getGuiSettings()
Definition: Project.h:51
static Project & getInstance()
Definition: Project.h:25
void save(Config &config)
Definition: Project.cpp:35
void setPalette(const std::string &name, const Palette &palette)
Definition: Project.h:37