Author: suokko
Date: Wed Aug 27 11:13:02 2008
New Revision: 29019
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29019&view=rev
Log:
Added support for passing config object as reference to config_cache
Modified:
trunk/src/config_cache.cpp
trunk/src/config_cache.hpp
Modified: trunk/src/config_cache.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/config_cache.cpp?rev=29019&r1=29018&r2=29019&view=diff
==============================================================================
--- trunk/src/config_cache.cpp (original)
+++ trunk/src/config_cache.cpp Wed Aug 27 11:13:02 2008
@@ -77,6 +77,11 @@
}
+ void config_cache::get_config(const std::string& path, config& cfg)
+ {
+ load_configs(path, cfg);
+ }
+
config_ptr config_cache::get_config(const std::string& path)
{
config_ptr ret(new config());
Modified: trunk/src/config_cache.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/config_cache.hpp?rev=29019&r1=29018&r2=29019&view=diff
==============================================================================
--- trunk/src/config_cache.hpp (original)
+++ trunk/src/config_cache.hpp Wed Aug 27 11:13:02 2008
@@ -22,96 +22,103 @@
namespace game_config {
-/**
- * Singleton object to manage game configs
- * and cache reading.
- * @TODO: Make smarter filetree checksum caching so only required parts
- * of tree are checked at startup. Trees are overlapping so have
- * to split trees to subtrees to only do check once per file.
- **/
-class config_cache : private boost::noncopyable {
- static config_cache cache_;
+ /**
+ * Singleton object to manage game configs
+ * and cache reading.
+ * @TODO: Make smarter filetree checksum caching so only required parts
+ * of tree are checked at startup. Trees are overlapping
so have
+ * to split trees to subtrees to only do check once per
file.
+ **/
+ class config_cache : private boost::noncopyable {
+ static config_cache cache_;
- bool force_valid_cache_, use_cache_;
- preproc_map defines_map_;
+ bool force_valid_cache_, use_cache_;
+ preproc_map defines_map_;
- void read_configs(config&, std::string&);
+ void read_configs(config&, std::string&);
- void read_file(const std::string& file, config& cfg);
- void write_file(std::string file, const config& cfg);
+ void read_file(const std::string& file, config& cfg);
+ void write_file(std::string file, const config& cfg);
- void read_cache(const std::string& path, config& cfg);
+ void read_cache(const std::string& path, config& cfg);
- void read_configs(const std::string& path, config& cfg);
+ void read_configs(const std::string& path, config& cfg);
- // Protected to let test code access
- protected:
- config_cache();
+ // Protected to let test code access
+ protected:
+ config_cache();
- const preproc_map& get_preproc_map() const;
- void load_configs(const std::string& path, config& cfg);
+ const preproc_map& get_preproc_map() const;
+ void load_configs(const std::string& path, config& cfg);
- public:
- /**
- * Get reference to the singleton object
- **/
- static config_cache& instance();
+ public:
+ /**
+ * Get reference to the singleton object
+ **/
+ static config_cache& instance();
+
+ /**
+ * get config object from given path
+ * @param path which to load. Should be _main.cfg.
+ * @param config object that is writen to, It should be empty
+ * because there is no quarentee how filled in
config is handled
+ **/
+ void get_config(const std::string& path, config& cfg);
+ /**
+ * get config_ptr from given path
+ * @return shread_ptr config object
+ * @param config object that is writen to
+ **/
+ config_ptr get_config(const std::string& path);
+
+ /**
+ * Clear stored defines map to default values
+ **/
+ void clear_defines();
+ /**
+ * Add a entry to preproc defines map
+ **/
+ void add_define(const std::string& define);
+ /**
+ * Remove a entry to preproc defines map
+ **/
+ void remove_define(const std::string& define);
+
+ /**
+ * Enable/disable caching
+ **/
+ void set_use_cache(bool use);
+ /**
+ * Enable/disable cache validation
+ **/
+ void set_force_valid_cache(bool force);
+ /**
+ * Force cache checksum validation.
+ **/
+ void recheck_filetree_checksum();
+ };
/**
- * get config object from given path
- * @param path which to load. Should be _main.cfg.
- * @return shread_ptr config object
+ * Used to set and unset scoped defines to preproc_map
+ * This is prefered form to set defines that aren't global
**/
- config_ptr get_config(const std::string& path);
-
- /**
- * Clear stored defines map to default values
- **/
- void clear_defines();
- /**
- * Add a entry to preproc defines map
- **/
- void add_define(const std::string& define);
- /**
- * Remove a entry to preproc defines map
- **/
- void remove_define(const std::string& define);
-
- /**
- * Enable/disable caching
- **/
- void set_use_cache(bool use);
- /**
- * Enable/disable cache validation
- **/
- void set_force_valid_cache(bool force);
- /**
- * Force cache checksum validation.
- **/
- void recheck_filetree_checksum();
-};
-
-/**
- * Used to set and unset scoped defines to preproc_map
- * This is prefered form to set defines that aren't global
- **/
-template <class T>
-class scoped_preproc_define_internal : private boost::noncopyable {
- // Protected to let test code access
- protected:
- std::string name_;
- public:
- scoped_preproc_define_internal(const std::string& name) : name_(name)
- {
- T::instance().add_define(name_);
- }
- ~scoped_preproc_define_internal()
- {
- T::instance().remove_define(name_);
- }
-};
-typedef scoped_preproc_define_internal<config_cache> scoped_preproc_define;
+ template <class T>
+ class scoped_preproc_define_internal : private
boost::noncopyable {
+ // Protected to let test code access
+ protected:
+ std::string name_;
+ public:
+ scoped_preproc_define_internal(const
std::string& name) : name_(name)
+ {
+ T::instance().add_define(name_);
+ }
+ ~scoped_preproc_define_internal()
+ {
+ T::instance().remove_define(name_);
+ }
+ };
+ typedef scoped_preproc_define_internal<config_cache>
scoped_preproc_define;
}
#endif
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits