VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgReferencedCollection.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2018 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <osg/ref_ptr>
13 #include <osg/Texture>
14 #include <boost/unordered_set.hpp>
15 #include <boost/unordered_map.hpp>
16 #include <boost/thread.hpp>
17 #include <string>
18 
19 namespace osg
20 {
21  class State;
22 }
23 
24 namespace makVrv
25 {
29  template <typename OsgObject>
31  {
32  public:
33 
34  typedef boost::unordered_map<std::string,osg::ref_ptr<OsgObject> >
36  typedef std::vector<std::pair<std::string,OsgObject*> > ReferenceList;
37 
39  DtOsgReferencedCollection(unsigned int initialCapacity);
40 
44  inline void lock() { myMutex.lock(); }
45 
49 
52  inline InstanceMap& getUnsafeMap() { return myInstanceMap; }
53 
55  inline void unlock() { myMutex.unlock(); }
56 
63  bool findOrBlockWhilePending(const std::string& name, osg::ref_ptr<OsgObject>& object );
64 
66  osg::ref_ptr<OsgObject> find(const std::string& filename);
67 
70  void insert(const std::string& name,const osg::ref_ptr<OsgObject>& obj);
71 
73  void releaseGLObjects(osg::State* state);
74 
76  void clear();
77 
78 
82  bool findOrAddTexture(const std::string& filename,
83  osg::Texture::FilterMode minFilter,osg::Texture::FilterMode magFilter,
84  osg::Texture::WrapMode s, osg::Texture::WrapMode t, osg::ref_ptr<osg::Texture>& texture,
85  bool unloadImageDataFlag, bool compressTexturesFlag, const std::string& alternateFilename = "");
86 
89  bool findTexture(const std::string& filename,
90  osg::Texture::FilterMode minFilter,osg::Texture::FilterMode magFilter,
91  osg::Texture::WrapMode s, osg::Texture::WrapMode t, bool compressedTexturesFlag, osg::ref_ptr<osg::Texture>& texture);
92 
95  void addTexture(const std::string& filename,
96  osg::ref_ptr<osg::Texture> texture, bool unloadImageDataFlag, bool compressTexturesFlag, std::string alternateFilename = "");
97 
98 
101  unsigned int flush();
102 
105  unsigned int partialFlush(unsigned int maxToCheck,unsigned int maxToFlush);
106 
109  unsigned int flushTextures();
110 
113  unsigned int partialFlushTextures(unsigned int maxToCheck,unsigned int maxToFlush);
114 
115  protected:
116 
118  {
119  const std::string& myStr;
120  FindReference(const std::string& str) : myStr(str){}
121  bool operator()(const std::pair<std::string,OsgObject*>& ref)
122  {
123  return ref.first == myStr;
124  }
125  };
126 
127  typedef boost::unordered_set<std::string> PendingSet;
128  boost::mutex myMutex;
129  //use this condition variable to wait for the instance that is pending to be loaded
130  boost::condition_variable myPendingInstanceDone;
135  unsigned int myPartialFlushIndex;
136  };
137 
138 }
139 

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)