VR-Forces 4.1.1 Class Documentation
DtOsgReferencedCollection.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: $ $Revision: $ $State: $
7 ******************************************************************************/
8 
12 
13 #pragma once
14 #include <string>
15 #include <osg/ref_ptr>
16 #include <osg/Referenced>
17 #include <osg/Texture2D>
18 #include <osgDB/Registry>
19 #include <vrvOsg/DtOsgFileCache.h>
20 #include <boost/thread/mutex.hpp>
21 #include <boost/unordered_set.hpp>
22 #include <boost/unordered_map.hpp>
23 #include <boost/thread.hpp>
24 #include <vector>
25 
26 namespace makVrv
27 {
31  template <typename OsgObject>
33  {
34  public:
35 
36  typedef boost::unordered_map<std::string,osg::ref_ptr<OsgObject> >
38  typedef std::vector<std::pair<std::string,OsgObject*> > ReferenceList;
39 
41  DtOsgReferencedCollection(unsigned int initialCapacity);
42 
46  inline void lock() { myMutex.lock(); }
47 
51 
54  inline InstanceMap& getUnsafeMap() { return myInstanceMap; }
55 
57  inline void unlock() { myMutex.unlock(); }
58 
64  bool find(const std::string& name, osg::ref_ptr<OsgObject>& object );
65 
67  void insert(const std::string& name,const osg::ref_ptr<OsgObject>& obj);
68 
70  void releaseGLObjects(osg::State* state);
71 
73  void clear();
74 
76  osg::ref_ptr<OsgObject> find(const std::string& filename);
77 
79  osg::ref_ptr<osg::Texture> findOrAddTexture(const std::string& filename,
80  osg::Texture::FilterMode minFilter,osg::Texture::FilterMode magFilter,
81  osg::Texture::WrapMode s, osg::Texture::WrapMode t);
82 
85  unsigned int flush();
86 
89  unsigned int partialFlush(unsigned int maxToCheck,unsigned int maxToFlush);
90 
93  unsigned int partialFlushTextures(unsigned int maxToCheck,unsigned int maxToFlush);
94 
95  protected:
96 
98  {
99  const std::string& myStr;
100  FindReference(const std::string& str) : myStr(str){}
101  bool operator()(const std::pair<std::string,OsgObject*>& ref)
102  {
103  return ref.first == myStr;
104  }
105  };
106 
107  typedef boost::unordered_set<std::string> PendingSet;
108  boost::mutex myMutex;
112  unsigned int myPartialFlushIndex;
113  };
114 
115 }
116 

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)