VR-Forces Development_Version 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 
15 #include <osg/ref_ptr>
16 #include <osg/Texture>
17 #include <boost/unordered_set.hpp>
18 #include <boost/unordered_map.hpp>
19 #include <boost/thread.hpp>
20 #include <string>
21 
22 namespace osg
23 {
24  class State;
25 }
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 
81  bool findTexture(const std::string& filename,
82  osg::Texture::FilterMode minFilter,osg::Texture::FilterMode magFilter,
83  osg::Texture::WrapMode s, osg::Texture::WrapMode t, osg::ref_ptr<osg::Texture>& texture);
84 
87  void addTexture(const std::string& filename,
88  osg::ref_ptr<osg::Texture> texture, bool unloadImageDataFlag, bool compressTexturesFlag, std::string alternateFilename = "");
89 
90 
93  unsigned int flush();
94 
97  unsigned int partialFlush(unsigned int maxToCheck,unsigned int maxToFlush);
98 
101  unsigned int partialFlushTextures(unsigned int maxToCheck,unsigned int maxToFlush);
102 
103  protected:
104 
106  {
107  const std::string& myStr;
108  FindReference(const std::string& str) : myStr(str){}
109  bool operator()(const std::pair<std::string,OsgObject*>& ref)
110  {
111  return ref.first == myStr;
112  }
113  };
114 
115  typedef boost::unordered_set<std::string> PendingSet;
116  boost::mutex myMutex;
120  unsigned int myPartialFlushIndex;
121  };
122 
123 }
124 

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)