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>
29 template <
typename OsgObject>
34 typedef boost::unordered_map<std::string,osg::ref_ptr<OsgObject> >
86 osg::Texture::FilterMode minFilter,osg::Texture::FilterMode magFilter,
88 bool unloadImageDataFlag,
bool compressTexturesFlag,
const std::string& alternateFilename =
"");
93 osg::Texture::FilterMode minFilter,osg::Texture::FilterMode magFilter,
104 unsigned int flush();
108 unsigned int partialFlush(
unsigned int maxToCheck,
unsigned int maxToFlush);
125 bool operator()(
const std::pair<std::string,OsgObject*>& ref)
127 return ref.first ==
myStr;
bool findOrBlockWhilePending(const std::string &name, osg::ref_ptr< OsgObject > &object)
Find an object with a given name or save the name as pending. This function will block if the object ...
ReferenceList myRefInstanceList
Definition: DtOsgReferencedCollection.h:136
const std::string & myStr
Definition: DtOsgReferencedCollection.h:123
boost::unordered_set< std::string > PendingSet
Definition: DtOsgReferencedCollection.h:131
Definition: featureContext.h:37
osg::ref_ptr< OsgObject > find(const std::string &filename)
Look for an object and return a value (null or not).
boost::mutex myMutex
Definition: DtOsgReferencedCollection.h:132
bool findTexture(const std::string &filename, osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter, osg::Texture::WrapMode s, osg::Texture::WrapMode t, bool compressedTexturesFlag, osg::ref_ptr< osg::Texture > &texture)
Find a texture with the given image name.
unsigned int flush()
Do a partial flush of items.
bool findOrAddTexture(const std::string &filename, osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter, osg::Texture::WrapMode s, osg::Texture::WrapMode t, osg::ref_ptr< osg::Texture > &texture, bool unloadImageDataFlag, bool compressTexturesFlag, const std::string &alternateFilename="")
Find a texture with the given image name. If it is not found the texture input is added to the cache ...
std::vector< std::pair< std::string, OsgObject * > > ReferenceList
Definition: DtOsgReferencedCollection.h:36
DtOsgReferencedCollection(unsigned int initialCapacity)
Constructor.
void lock()
Lock the collection.
Definition: DtOsgReferencedCollection.h:44
A thread safe collection, used by the mult-threaded cache, of OSG referenced objects.
Definition: DtOsgReferencedCollection.h:30
unsigned int myPartialFlushIndex
Definition: DtOsgReferencedCollection.h:139
void releaseGLObjects(osg::State *state)
Release GL objects on all objects in the cache.
PendingSet myPendingInstances
Definition: DtOsgReferencedCollection.h:137
PendingSet myFailedInstances
Definition: DtOsgReferencedCollection.h:138
Definition: DtOsgReferencedCollection.h:121
void unlock()
Unlock the collection.
Definition: DtOsgReferencedCollection.h:58
void addTexture(const std::string &filename, osg::ref_ptr< osg::Texture > texture, bool unloadImageDataFlag, bool compressTexturesFlag, std::string alternateFilename="")
add a texture for the given image name. also processes the texture to put on a callback for handling ...
unsigned int flushTextures()
Do a flush of all textures.
InstanceMap myInstanceMap
Definition: DtOsgReferencedCollection.h:135
FindReference(const std::string &str)
Definition: DtOsgReferencedCollection.h:124
boost::unordered_map< std::string, osg::ref_ptr< OsgObject > > InstanceMap
Definition: DtOsgReferencedCollection.h:35
InstanceMap & getUnsafeMap()
Get the unsafe map, to make this safe you MUST lock the collection first.
Definition: DtOsgReferencedCollection.h:52
unsigned int unsafeListSize() const
returns size of collection
boost::condition_variable myPendingInstanceDone
Definition: DtOsgReferencedCollection.h:134
void clear()
Clears all of the instances.
bool operator()(const std::pair< std::string, OsgObject * > &ref)
Definition: DtOsgReferencedCollection.h:125
unsigned int partialFlushTextures(unsigned int maxToCheck, unsigned int maxToFlush)
Do a partial flush of items.
void insert(const std::string &name, const osg::ref_ptr< OsgObject > &obj)
Insert an instance into the cache Needs to be called if an object is pending (pass 0 to remove from p...
unsigned int partialFlush(unsigned int maxToCheck, unsigned int maxToFlush)
Do a partial flush of items.
ReferenceList & getUnsafeList()
Get the unsafe list, to make this safe you MUST lock the collection first.
Definition: DtOsgReferencedCollection.h:48