aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Resource.hh
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-12 12:16:32 (GMT)
committerPaul Tagliamonte <paultag@fluxbox.org>2012-04-07 02:11:31 (GMT)
commit137d2edaa8cb5f4f41e2ef85de3b4316b32daf79 (patch)
treef3d8eafb1931745eea005b901f8c9a491a637365 /src/FbTk/Resource.hh
parent56b0a9c4c7677c8d03341bc52694c45845700ea0 (diff)
downloadfluxbox_paul-137d2edaa8cb5f4f41e2ef85de3b4316b32daf79.zip
fluxbox_paul-137d2edaa8cb5f4f41e2ef85de3b4316b32daf79.tar.bz2
Enable the resource traits classes to hold non-static members
ps: the Resource class inherits from the Traits class instead of holding it as a member because it's more size-efficient (base classes can have zero size, members cannot).
Diffstat (limited to 'src/FbTk/Resource.hh')
-rw-r--r--src/FbTk/Resource.hh12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh
index 32d24b6..c6f12d6 100644
--- a/src/FbTk/Resource.hh
+++ b/src/FbTk/Resource.hh
@@ -188,19 +188,21 @@ private:
188 * If there is no traits class for your type, you have to implement one. 188 * If there is no traits class for your type, you have to implement one.
189 */ 189 */
190template <typename T, typename Traits> 190template <typename T, typename Traits>
191class Resource:public Resource_base, public Accessor<T> { 191class Resource:public Resource_base, public Accessor<T>, private Traits {
192public: 192public:
193 typedef T Type; 193 typedef T Type;
194 194
195 Resource(ResourceManager_base &rm, T val, const std::string &name, const std::string &altname): 195 Resource(ResourceManager_base &rm, T val, const std::string &name,
196 Resource_base(name, altname), m_value(val), m_defaultval(val), m_rm(rm) { 196 const std::string &altname, const Traits &traits = Traits() ):
197 Resource_base(name, altname), Traits(traits), m_value(val), m_defaultval(val), m_rm(rm) {
197 m_rm.addResource(*this); // add this to resource handler 198 m_rm.addResource(*this); // add this to resource handler
198 } 199 }
199 200
200 // LResourceManager does not use altname, so we provide a constructor which initializes 201 // LResourceManager does not use altname, so we provide a constructor which initializes
201 // altname to name 202 // altname to name
202 Resource(ResourceManager_base &rm, T val, const std::string &name): 203 Resource(ResourceManager_base &rm, T val, const std::string &name,
203 Resource_base(name, name), m_value(val), m_defaultval(val), m_rm(rm) { 204 const Traits &traits = Traits() ):
205 Resource_base(name, name), Traits(traits), m_value(val), m_defaultval(val), m_rm(rm) {
204 m_rm.addResource(*this); // add this to resource handler 206 m_rm.addResource(*this); // add this to resource handler
205 } 207 }
206 virtual ~Resource() { 208 virtual ~Resource() {