aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Resource.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Resource.hh')
-rw-r--r--src/FbTk/Resource.hh19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh
index 55eeddc..20ce3ba 100644
--- a/src/FbTk/Resource.hh
+++ b/src/FbTk/Resource.hh
@@ -25,6 +25,7 @@
25#define FBTK_RESOURCE_HH 25#define FBTK_RESOURCE_HH
26 26
27#include "NotCopyable.hh" 27#include "NotCopyable.hh"
28#include "Accessor.hh"
28 29
29#include <string> 30#include <string>
30#include <list> 31#include <list>
@@ -160,23 +161,22 @@ private:
160 161
161/// Real resource class 162/// Real resource class
162/** 163/**
163 * usage: Resource<int> someresource(resourcemanager, 10, "someresourcename", "somealternativename"); \n 164 * usage: Resource<int> someresource(resourcemanager, 10, "someresourcename", "somealternativename");
164 * and then implement setFromString and getString \n 165 * and then implement setFromString and getString
165 * example: \n 166 * example:
166 * template <> \n 167 * template <>
167 * void Resource<int>::setFromString(const char *str) { \n 168 * void Resource<int>::setFromString(const char *str) {
168 * *(*this) = atoi(str); \n 169 * *(*this) = atoi(str);
169 * } 170 * }
170 */ 171 */
171template <typename T> 172template <typename T>
172class Resource:public Resource_base 173class Resource:public Resource_base, public Accessor<T> {
173{
174public: 174public:
175 typedef T Type; 175 typedef T Type;
176 Resource(ResourceManager &rm, T val, 176 Resource(ResourceManager &rm, T val,
177 const std::string &name, const std::string &altname): 177 const std::string &name, const std::string &altname):
178 Resource_base(name, altname), 178 Resource_base(name, altname),
179 m_value(val), m_defaultval(val), 179 m_value(val), m_defaultval(val),
180 m_rm(rm) { 180 m_rm(rm) {
181 m_rm.addResource(*this); // add this to resource handler 181 m_rm.addResource(*this); // add this to resource handler
182 } 182 }
@@ -192,6 +192,7 @@ public:
192 /// @return string value of resource 192 /// @return string value of resource
193 std::string getString() const; 193 std::string getString() const;
194 194
195 inline operator T() const { return m_value; }
195 inline T& get() { return m_value; } 196 inline T& get() { return m_value; }
196 inline T& operator*() { return m_value; } 197 inline T& operator*() { return m_value; }
197 inline const T& operator*() const { return m_value; } 198 inline const T& operator*() const { return m_value; }