VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <vrvOsg/DtOsgImageUtils.h>
21 #include <boost/thread/mutex.hpp>
22 #include <boost/unordered_set.hpp>
23 #include <boost/unordered_map.hpp>
24 #include <boost/thread.hpp>
25 #include <vector>
26 
27 namespace makVrv
28 {
32  template <typename OsgObject>
34  {
35  public:
36 
37  typedef boost::unordered_map<std::string,osg::ref_ptr<OsgObject> >
39  typedef std::vector<std::pair<std::string,OsgObject*> > ReferenceList;
40 
42  DtOsgReferencedCollection(unsigned int initialCapacity);
43 
47  inline void lock() { myMutex.lock(); }
48 
52 
55  inline InstanceMap& getUnsafeMap() { return myInstanceMap; }
56 
58  inline void unlock() { myMutex.unlock(); }
59 
65  bool find(const std::string& name, osg::ref_ptr<OsgObject>& object );
66 
68  void insert(const std::string& name,const osg::ref_ptr<OsgObject>& obj);
69 
71  void releaseGLObjects(osg::State* state);
72 
74  void clear();
75 
77  osg::ref_ptr<OsgObject> find(const std::string& filename);
78 
80  osg::ref_ptr<osg::Texture> findOrAddTexture(const std::string& filename,
81  osg::Texture::FilterMode minFilter,osg::Texture::FilterMode magFilter,
82  osg::Texture::WrapMode s, osg::Texture::WrapMode t);
83 
86  unsigned int flush();
87 
90  unsigned int partialFlush(unsigned int maxToCheck,unsigned int maxToFlush);
91 
94  unsigned int partialFlushTextures(unsigned int maxToCheck,unsigned int maxToFlush);
95 
96  protected:
97 
99  {
100  const std::string& myStr;
101  FindReference(const std::string& str) : myStr(str){}
102  bool operator()(const std::pair<std::string,OsgObject*>& ref)
103  {
104  return ref.first == myStr;
105  }
106  };
107 
108  typedef boost::unordered_set<std::string> PendingSet;
109  boost::mutex myMutex;
113  unsigned int myPartialFlushIndex;
114  };
115 
116 }
117 

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)