aboutsummaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-09-05 19:02:50 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-13 22:40:53 +0100
commit5038f3c64d97c71d2d1048638fb4bc1a32ad6a31 (patch)
tree83e83adc72aa99835ac9cbf3b8a7c318a24f1f8b /src/base
parenta2697363631e3020ddc61d9970849166398383ec (diff)
downloadusdx-5038f3c64d97c71d2d1048638fb4bc1a32ad6a31.tar.gz
usdx-5038f3c64d97c71d2d1048638fb4bc1a32ad6a31.tar.xz
usdx-5038f3c64d97c71d2d1048638fb4bc1a32ad6a31.zip
base/config: add graphics.resolution config option
The resolution could controlled by the appropriate config option. The value from the config file is parsed/serialized with the DimensionTranslator.
Diffstat (limited to '')
-rw-r--r--src/base/config.cpp14
-rw-r--r--src/base/config.hpp12
2 files changed, 26 insertions, 0 deletions
diff --git a/src/base/config.cpp b/src/base/config.cpp
index d1824187..0bcac232 100644
--- a/src/base/config.cpp
+++ b/src/base/config.cpp
@@ -31,10 +31,13 @@ namespace usdx
log4cpp::Category::getInstance("usdx.base.config");
Config::Config()
+ : graphics_resolution(800,600)
{
try {
// TODO: handling different paths
read_ini("config.ini", this->pt);
+
+ graphics_resolution = pt.get("graphics.resolution", graphics_resolution);
}
catch(...) {
log << log4cpp::Priority::ERROR << "Loading of configuration failed.";
@@ -56,4 +59,15 @@ namespace usdx
log << log4cpp::Priority::ERROR << "Saving of configuration failed.";
}
}
+
+ void Config::set_graphics_resolution(Dimension<int> value)
+ {
+ graphics_resolution = value;
+ pt.put("graphics.resolution", value);
+ }
+
+ Dimension<int> Config::get_graphics_resolution(void) const
+ {
+ return graphics_resolution;
+ }
};
diff --git a/src/base/config.hpp b/src/base/config.hpp
index 49c2e53a..a71e26c7 100644
--- a/src/base/config.hpp
+++ b/src/base/config.hpp
@@ -27,6 +27,8 @@
#include <log4cpp/Category.hh>
#include <boost/property_tree/ptree.hpp>
+#include "utils/dimension.hpp"
+#include "utils/dimension_translator.hpp"
namespace usdx
{
@@ -40,12 +42,22 @@ namespace usdx
*/
boost::property_tree::ptree pt;
+ /* Following all the available configuration options. They get filled
+ * with default or saved values within the constructor. They should be
+ * only accessible via getter/setter and setting a new value sould
+ * update the apropriate entry in the property tree instance.
+ */
+ Dimension<int> graphics_resolution;
+
public:
Config();
virtual ~Config();
/* Save the current status of the configuration items. */
void save(void) const;
+
+ void set_graphics_resolution(Dimension<int> value);
+ Dimension<int> get_graphics_resolution(void) const;
};
};