diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-08-04 09:02:04 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2011-08-04 09:02:04 (GMT) |
commit | cf11e9c960636434f8b398f47b1e55d27ad18e4e (patch) | |
tree | d4df04e8b5a7aa26633f3a5474264931cccce23f /src/FbTk/Resource.hh | |
parent | 707df7d81b6df25fa98f3a867485cb7bbbbf74b8 (diff) | |
download | fluxbox_pavel-cf11e9c960636434f8b398f47b1e55d27ad18e4e.zip fluxbox_pavel-cf11e9c960636434f8b398f47b1e55d27ad18e4e.tar.bz2 |
Move most of the resource loading code into ResourceManager_base
I mostly do this to avoid code duplication between fluxbox and fluxbox-update_configs.
Diffstat (limited to 'src/FbTk/Resource.hh')
-rw-r--r-- | src/FbTk/Resource.hh | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh index c4a7951..700fe70 100644 --- a/src/FbTk/Resource.hh +++ b/src/FbTk/Resource.hh | |||
@@ -92,6 +92,11 @@ public: | |||
92 | 92 | ||
93 | virtual ~ResourceManager_base() {} | 93 | virtual ~ResourceManager_base() {} |
94 | 94 | ||
95 | /// Load all resources registered to this class | ||
96 | /// if loading of filename fails, it tries to load fallback | ||
97 | /// if that fails, it throws an exception | ||
98 | void load(const std::string &filename, const std::string &fallback); | ||
99 | |||
95 | /// Save all resouces registered to this class | 100 | /// Save all resouces registered to this class |
96 | /// @return true on success | 101 | /// @return true on success |
97 | virtual bool save(const char *filename, const char *mergefilename=0) = 0; | 102 | virtual bool save(const char *filename, const char *mergefilename=0) = 0; |
@@ -130,8 +135,12 @@ public: | |||
130 | ResourceList::const_iterator end() { return m_resourcelist.end(); } | 135 | ResourceList::const_iterator end() { return m_resourcelist.end(); } |
131 | 136 | ||
132 | protected: | 137 | protected: |
138 | /// does the actual loading | ||
139 | virtual void doLoad(const std::string &filename) = 0; | ||
140 | |||
133 | ResourceList m_resourcelist; | 141 | ResourceList m_resourcelist; |
134 | const std::string m_root; | 142 | const std::string m_root; |
143 | std::string m_filename; | ||
135 | }; | 144 | }; |
136 | 145 | ||
137 | class ResourceManager: public ResourceManager_base | 146 | class ResourceManager: public ResourceManager_base |
@@ -143,10 +152,6 @@ public: | |||
143 | const char *filename, bool lock_db); | 152 | const char *filename, bool lock_db); |
144 | virtual ~ResourceManager(); | 153 | virtual ~ResourceManager(); |
145 | 154 | ||
146 | /// Load all resources registered to this class | ||
147 | /// @return true on success | ||
148 | virtual bool load(const char *filename); | ||
149 | |||
150 | /// Save all resouces registered to this class | 155 | /// Save all resouces registered to this class |
151 | /// @return true on success | 156 | /// @return true on success |
152 | virtual bool save(const char *filename, const char *mergefilename=0); | 157 | virtual bool save(const char *filename, const char *mergefilename=0); |
@@ -173,6 +178,7 @@ public: | |||
173 | } | 178 | } |
174 | } | 179 | } |
175 | protected: | 180 | protected: |
181 | virtual void doLoad(const std::string &filename); | ||
176 | 182 | ||
177 | int m_db_lock; | 183 | int m_db_lock; |
178 | 184 | ||
@@ -180,7 +186,6 @@ private: | |||
180 | 186 | ||
181 | XrmDatabaseHelper *m_database; | 187 | XrmDatabaseHelper *m_database; |
182 | 188 | ||
183 | std::string m_filename; | ||
184 | std::string m_alt_root; | 189 | std::string m_alt_root; |
185 | }; | 190 | }; |
186 | 191 | ||