[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Usata-commits] Changes to usata2/src/texture-manager.cpp
From: |
David Lau |
Subject: |
[Usata-commits] Changes to usata2/src/texture-manager.cpp |
Date: |
Mon, 17 Jan 2005 19:12:08 -0500 |
Index: usata2/src/texture-manager.cpp
diff -u usata2/src/texture-manager.cpp:1.5 usata2/src/texture-manager.cpp:1.6
--- usata2/src/texture-manager.cpp:1.5 Sun Dec 26 18:36:42 2004
+++ usata2/src/texture-manager.cpp Tue Jan 18 00:12:08 2005
@@ -10,18 +10,20 @@
// included in the software distribution, or visit
// http://www.fsf.org/licenses/gpl.html.
//
-// $Id: texture-manager.cpp,v 1.5 2004/12/26 18:36:42 Descender Exp $
+// $Id: texture-manager.cpp,v 1.6 2005/01/18 00:12:08 skunix Exp $
-#include "texture.hpp"
#include <ext/hash_map>
#include <string>
#include <functional>
#include <utility>
+
+#include <boost/thread/mutex.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/bind.hpp>
#include <boost/format.hpp>
-#include <iostream>
+
+#include "texture.hpp"
#include "texture-meta.hpp"
#include "log.hpp"
@@ -54,6 +56,9 @@
> TextureCache;
typedef TextureCache::value_type TextureCache_vt;
+
+
+ boost::mutex mutex;
MetaMap meta;
TextureCache texture_cache;
@@ -62,18 +67,21 @@
TextureMeta TextureManagerImpl::get_meta(const std::string&
textureAlias);
void cache(Texture_sp& texture, const std::string& alias);
+
};
void
TextureManagerImpl :: cache(Texture_sp& texture,
const std::string&
alias)
{
+ boost::mutex::scoped_lock L(mutex);
texture_cache.insert(TextureCache_vt(alias, texture));
return;
}
Texture_sp
TextureManagerImpl::check_cache(const std::string& textureAlias)
{
+ boost::mutex::scoped_lock L(mutex);
TextureCache::iterator tc_it = texture_cache.find(textureAlias);
if (tc_it == texture_cache.end())
{
@@ -86,6 +94,7 @@
TextureMeta
TextureManagerImpl::get_meta(const std::string& textureAlias)
{
+ boost::mutex::scoped_lock L(mutex);
MetaMap::iterator mm_it = meta.find(textureAlias);
if (mm_it == meta.end())
{
@@ -109,22 +118,6 @@
{
impl->meta.insert(TextureManagerImpl::MetaMap::value_type(m->alias,
*m));
}
-/*
-void
-adjust_add_meta(boost::filesystem::path p, TextureManager*tm, const
TextureMeta*m)
-{
- // adjust filename
-
- boost::filesystem::path fullpath = p / m->filename;
-
-// std::cout << m->filename << " becomes " <<
fullpath.native_file_string() << std::endl;
- TextureMeta adjusted(*m);
-
- adjusted.filename=fullpath.native_file_string();
- tm->add_meta(&adjusted);
- return;
-}
-*/
Texture_sp
TextureManager::get(const std::string& texAlias)
@@ -145,7 +138,7 @@
TextureManager::load_path(const boost::filesystem::path& p)
{
using boost::filesystem::path;
- log::BufferedStream logstream; //(&log::server, log::Level::INFO);
+ log::BufferedStream logstream;
path mf = p / "textures" / "meta";
logstream << (boost::format("Loading texture metadata from
'%1%'")%mf.native_file_string()).str() << log::commit;
- [Usata-commits] Changes to usata2/src/texture-manager.cpp,
David Lau <=