/[usata]/usata2/src/texture-manager.cpp
ViewVC logotype

Diff of /usata2/src/texture-manager.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by Descender, Sun Dec 26 18:36:42 2004 UTC revision 1.6 by skunix, Tue Jan 18 00:12:08 2005 UTC
# Line 12  Line 12 
12  //  //
13  // $Id$  // $Id$
14    
 #include "texture.hpp"  
15  #include <ext/hash_map>  #include <ext/hash_map>
16  #include <string>  #include <string>
17  #include <functional>  #include <functional>
18  #include <utility>  #include <utility>
19    
20    #include <boost/thread/mutex.hpp>
21  #include <boost/shared_ptr.hpp>  #include <boost/shared_ptr.hpp>
22  #include <boost/filesystem/operations.hpp>  #include <boost/filesystem/operations.hpp>
23  #include <boost/bind.hpp>  #include <boost/bind.hpp>
24  #include <boost/format.hpp>  #include <boost/format.hpp>
25  #include <iostream>  
26    #include "texture.hpp"
27  #include "texture-meta.hpp"  #include "texture-meta.hpp"
28  #include "log.hpp"  #include "log.hpp"
29    
# Line 54  struct TextureManagerImpl Line 56  struct TextureManagerImpl
56                                                    > TextureCache;                                                    > TextureCache;
57    
58          typedef TextureCache::value_type TextureCache_vt;          typedef TextureCache::value_type TextureCache_vt;
59            
60    
61            boost::mutex mutex;
62    
63          MetaMap meta;          MetaMap meta;
64          TextureCache texture_cache;          TextureCache texture_cache;
# Line 62  struct TextureManagerImpl Line 67  struct TextureManagerImpl
67          TextureMeta TextureManagerImpl::get_meta(const std::string& textureAlias);          TextureMeta TextureManagerImpl::get_meta(const std::string& textureAlias);
68          void            cache(Texture_sp& texture, const std::string& alias);          void            cache(Texture_sp& texture, const std::string& alias);
69    
70    
71  };  };
72    
73  void  void
74  TextureManagerImpl :: cache(Texture_sp& texture,  TextureManagerImpl :: cache(Texture_sp& texture,
75                                                          const std::string& alias)                                                          const std::string& alias)
76  {  {
77            boost::mutex::scoped_lock L(mutex);
78          texture_cache.insert(TextureCache_vt(alias, texture));          texture_cache.insert(TextureCache_vt(alias, texture));
79          return;          return;
80  }  }
81  Texture_sp  Texture_sp
82  TextureManagerImpl::check_cache(const std::string& textureAlias)  TextureManagerImpl::check_cache(const std::string& textureAlias)
83  {  {
84            boost::mutex::scoped_lock L(mutex);
85          TextureCache::iterator tc_it = texture_cache.find(textureAlias);          TextureCache::iterator tc_it = texture_cache.find(textureAlias);
86          if (tc_it == texture_cache.end())          if (tc_it == texture_cache.end())
87          {          {
# Line 86  TextureManagerImpl::check_cache(const st Line 94  TextureManagerImpl::check_cache(const st
94  TextureMeta  TextureMeta
95  TextureManagerImpl::get_meta(const std::string& textureAlias)  TextureManagerImpl::get_meta(const std::string& textureAlias)
96  {  {
97            boost::mutex::scoped_lock L(mutex);
98          MetaMap::iterator mm_it = meta.find(textureAlias);          MetaMap::iterator mm_it = meta.find(textureAlias);
99          if (mm_it == meta.end())          if (mm_it == meta.end())
100          {          {
# Line 109  TextureManager::add_meta(const TextureMe Line 118  TextureManager::add_meta(const TextureMe
118  {  {
119          impl->meta.insert(TextureManagerImpl::MetaMap::value_type(m->alias, *m));          impl->meta.insert(TextureManagerImpl::MetaMap::value_type(m->alias, *m));
120  }  }
 /*  
 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;  
 }  
 */  
121    
122  Texture_sp  Texture_sp
123  TextureManager::get(const std::string& texAlias)  TextureManager::get(const std::string& texAlias)
# Line 145  void Line 138  void
138  TextureManager::load_path(const boost::filesystem::path& p)  TextureManager::load_path(const boost::filesystem::path& p)
139  {  {
140          using boost::filesystem::path;          using boost::filesystem::path;
141          log::BufferedStream logstream; //(&log::server, log::Level::INFO);          log::BufferedStream logstream;
142          path mf = p / "textures" / "meta";          path mf = p / "textures" / "meta";
143          logstream << (boost::format("Loading texture metadata from '%1%'")%mf.native_file_string()).str() << log::commit;          logstream << (boost::format("Loading texture metadata from '%1%'")%mf.native_file_string()).str() << log::commit;
144                    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26