VR-Forces 4.6.1 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 /******************************************************************************
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 
66  bool findOrBlockWhilePending(const std::string& name, osg::ref_ptr<OsgObject>& object );
67 
69  osg::ref_ptr<OsgObject> find(const std::string& filename);
70 
73  void insert(const std::string& name,const osg::ref_ptr<OsgObject>& obj);
74 
76  void releaseGLObjects(osg::State* state);
77 
79  void clear();
80 
81 
85  bool findOrAddTexture(const std::string& filename,
86  osg::Texture::FilterMode minFilter,osg::Texture::FilterMode magFilter,
87  osg::Texture::WrapMode s, osg::Texture::WrapMode t, osg::ref_ptr<osg::Texture>& texture,
88  bool unloadImageDataFlag, bool compressTexturesFlag, const std::string& alternateFilename = "");
89 
92  bool findTexture(const std::string& filename,
93  osg::Texture::FilterMode minFilter,osg::Texture::FilterMode magFilter,
94  osg::Texture::WrapMode s, osg::Texture::WrapMode t, osg::ref_ptr<osg::Texture>& texture);
95 
98  void addTexture(const std::string& filename,
99  osg::ref_ptr<osg::Texture> texture, bool unloadImageDataFlag, bool compressTexturesFlag, std::string alternateFilename = "");
100 
101 
104  unsigned int flush();
105 
108  unsigned int partialFlush(unsigned int maxToCheck,unsigned int maxToFlush);
109 
112  unsigned int flushTextures();
113 
116  unsigned int partialFlushTextures(unsigned int maxToCheck,unsigned int maxToFlush);
117 
118  protected:
119 
121  {
122  const std::string& myStr;
123  FindReference(const std::string& str) : myStr(str){}
124  bool operator()(const std::pair<std::string,OsgObject*>& ref)
125  {
126  return ref.first == myStr;
127  }
128  };
129 
130  typedef boost::unordered_set<std::string> PendingSet;
131  boost::mutex myMutex;
132  //use this condition variable to wait for the instance that is pending to be loaded
133  boost::condition_variable myPendingInstanceDone;
138  unsigned int myPartialFlushIndex;
139  };
140 
141 }
142 

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)