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 
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, 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 partialFlushTextures(unsigned int maxToCheck,unsigned int maxToFlush);
110 
111  protected:
112 
114  {
115  const std::string& myStr;
116  FindReference(const std::string& str) : myStr(str){}
117  bool operator()(const std::pair<std::string,OsgObject*>& ref)
118  {
119  return ref.first == myStr;
120  }
121  };
122 
123  typedef boost::unordered_set<std::string> PendingSet;
124  boost::mutex myMutex;
128  unsigned int myPartialFlushIndex;
129  };
130 
131 }
132 

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)