Changeset 891 – HoverRace

Changeset 891

Show
Ignore:
Timestamp:
03/04/10 01:05:27 (5 months ago)
Author:
zoogie
Message:

The configuration can now be now "unlinked", meaning that Save() will have no effect.

This will be useful for unit tests since we don't want the modified config to be persisted.

Location:
trunk/engine/Util
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/engine/Util/Config.cpp

    r828 r891  
    190190 
    191191/** 
     192 * Check if saving the config to disk is disabled. 
     193 * @return @c true if saving is disabled. 
     194 * @see #SetUnlinked(bool) 
     195 */ 
     196bool Config::IsUnlinked() const 
     197{ 
     198    return unlinked; 
     199} 
     200 
     201/** 
     202 * Enable or disable saving the configuration to disk. 
     203 * This is useful for testing, since it allows temporary changes 
     204 * without overwriting the config previously saved to disk. 
     205 * @param unlinked @c true to prevent saving config to disk. 
     206 */ 
     207void Config::SetUnlinked(bool unlinked) 
     208{ 
     209    this->unlinked = unlinked; 
     210} 
     211 
     212/** 
    192213 * Check if this build is a prerelease (development) version. 
    193214 * @return @c true if prerelease. 
     
    571592void Config::Save() 
    572593{ 
     594    if (unlinked) return; 
     595 
    573596    const std::string &cfgfile = GetConfigFilename(); 
    574597 
  • trunk/engine/Util/Config.h

    r880 r891  
    6767    private: 
    6868        static Config *instance; 
     69        bool unlinked;  ///< if @c true, will prevent saving config. 
    6970        std::string path; 
    7071        int verMajor; 
     
    8788            bool prerelease, const std::string &path=""); 
    8889        static void Shutdown(); 
     90 
     91        bool IsUnlinked() const; 
     92        void SetUnlinked(bool unlinked); 
    8993 
    9094        bool IsPrerelease() const;