{
DCP_ASSERT (!_file.empty ());
- if (_hash.empty ()) {
+ if (!_hash) {
_hash = make_digest (_file, progress);
}
- return _hash;
+ return _hash.get();
}
bool
Asset::set_file (boost::filesystem::path file) const
{
_file = boost::filesystem::absolute (file);
- _hash.clear ();
+ _hash = optional<string> ();
}
#include <boost/filesystem.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
+#include <boost/optional.hpp>
namespace xmlpp {
class Node;
std::string hash (boost::function<void (float)> progress = 0) const;
protected:
+
+ /** The most recent disk file used to read or write this asset; may be empty */
+ mutable boost::filesystem::path _file;
+
+private:
friend struct ::asset_test;
virtual std::string pkl_type (Standard standard) const = 0;
- /** The most recent disk file used to read or write this asset; may be empty */
- mutable boost::filesystem::path _file;
- /** Hash of _file, or empty if the hash has not yet been computed */
- mutable std::string _hash;
+ /** Hash of _file if it has been computed */
+ mutable boost::optional<std::string> _hash;
};
}