VR-Forces 4.6 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 
65  bool find(const std::string& name, osg::ref_ptr<OsgObject>& object );
66 
69  void insert(const std::string& name,const osg::ref_ptr<OsgObject>& obj);
70 
72  void releaseGLObjects(osg::State* state);
73 
75  void clear();
76 
78  osg::ref_ptr<OsgObject> find(const std::string& filename);
79 
83  bool findOrAddTexture(const std::string& filename,
84  osg::Texture::FilterMode minFilter,osg::Texture::FilterMode magFilter,
85  osg::Texture::WrapMode s, osg::Texture::WrapMode t, osg::ref_ptr<osg::Texture>& texture,
86  bool unloadImageDataFlag, bool compressTexturesFlag, const std::string& alternateFilename = "");
87 
90  bool findTexture(const std::string& filename,
91  osg::Texture::FilterMode minFilter,osg::Texture::FilterMode magFilter,
92  osg::Texture::WrapMode s, osg::Texture::WrapMode t, osg::ref_ptr<osg::Texture>& texture);
93 
96  void addTexture(const std::string& filename,
97  osg::ref_ptr<osg::Texture> texture, bool unloadImageDataFlag, bool compressTexturesFlag, std::string alternateFilename = "");
98 
99 
102  unsigned int flush();
103 
106  unsigned int partialFlush(unsigned int maxToCheck,unsigned int maxToFlush);
107 
110  unsigned int flushTextures();
111 
114  unsigned int partialFlushTextures(unsigned int maxToCheck,unsigned int maxToFlush);
115 
116  protected:
117 
119  {
120  const std::string& myStr;
121  FindReference(const std::string& str) : myStr(str){}
122  bool operator()(const std::pair<std::string,OsgObject*>& ref)
123  {
124  return ref.first == myStr;
125  }
126  };
127 
128  typedef boost::unordered_set<std::string> PendingSet;
129  boost::mutex myMutex;
130  //use this condition variable to wait for the instance that is pending to be loaded
131  boost::condition_variable myPendingInstanceDone;
136  unsigned int myPartialFlushIndex;
137  };
138 
139 }
140 

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)