VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Protected Types | Protected Attributes
makVrv::DtOsgReferencedCollection< OsgObject > Class Template Reference

template<typename OsgObject>
class makVrv::DtOsgReferencedCollection< OsgObject >

A thread safe collection, used by the mult-threaded cache, of OSG referenced objects.

Inheritance diagram for makVrv::DtOsgReferencedCollection< OsgObject >:
Inheritance graph
[legend]

Classes

struct  FindReference
 

Public Types

typedef boost::unordered_map
< std::string, osg::ref_ptr
< OsgObject > > 
InstanceMap
 
typedef std::vector< std::pair
< std::string, OsgObject * > > 
ReferenceList
 

Public Member Functions

 DtOsgReferencedCollection (unsigned int initialCapacity)
 
void lock ()
 
ReferenceListgetUnsafeList ()
 
InstanceMapgetUnsafeMap ()
 
unsigned int unsafeListSize () const
 
void unlock ()
 
bool findOrBlockWhilePending (const std::string &name, osg::ref_ptr< OsgObject > &object)
 
osg::ref_ptr< OsgObject > find (const std::string &filename)
 
void insert (const std::string &name, const osg::ref_ptr< OsgObject > &obj)
 
void releaseGLObjects (osg::State *state)
 
void clear ()
 
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="")
 
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)
 
void addTexture (const std::string &filename, osg::ref_ptr< osg::Texture > texture, bool unloadImageDataFlag, bool compressTexturesFlag, std::string alternateFilename="")
 
unsigned int flush ()
 
unsigned int partialFlush (unsigned int maxToCheck, unsigned int maxToFlush)
 
unsigned int flushTextures ()
 
unsigned int partialFlushTextures (unsigned int maxToCheck, unsigned int maxToFlush)
 

Protected Types

typedef boost::unordered_set
< std::string > 
PendingSet
 

Protected Attributes

boost::mutex myMutex
 
boost::condition_variable myPendingInstanceDone
 
InstanceMap myInstanceMap
 
ReferenceList myRefInstanceList
 
PendingSet myPendingInstances
 
PendingSet myFailedInstances
 
unsigned int myPartialFlushIndex
 

Member Typedef Documentation

template<typename OsgObject>
typedef boost::unordered_map<std::string,osg::ref_ptr<OsgObject> > makVrv::DtOsgReferencedCollection< OsgObject >::InstanceMap
template<typename OsgObject>
typedef std::vector<std::pair<std::string,OsgObject*> > makVrv::DtOsgReferencedCollection< OsgObject >::ReferenceList
template<typename OsgObject>
typedef boost::unordered_set<std::string> makVrv::DtOsgReferencedCollection< OsgObject >::PendingSet
protected

Constructor & Destructor Documentation

template<typename OsgObject>
makVrv::DtOsgReferencedCollection< OsgObject >::DtOsgReferencedCollection ( unsigned int  initialCapacity)

Constructor.

Member Function Documentation

template<typename OsgObject>
void makVrv::DtOsgReferencedCollection< OsgObject >::lock ( )
inline

Lock the collection.

Warning
This WILL cause deadlock if you make any calls other than to the unsafe list and map.
template<typename OsgObject>
ReferenceList& makVrv::DtOsgReferencedCollection< OsgObject >::getUnsafeList ( )
inline

Get the unsafe list, to make this safe you MUST lock the collection first.

template<typename OsgObject>
InstanceMap& makVrv::DtOsgReferencedCollection< OsgObject >::getUnsafeMap ( )
inline

Get the unsafe map, to make this safe you MUST lock the collection first.

template<typename OsgObject>
unsigned int makVrv::DtOsgReferencedCollection< OsgObject >::unsafeListSize ( ) const

returns size of collection

template<typename OsgObject>
void makVrv::DtOsgReferencedCollection< OsgObject >::unlock ( )
inline

Unlock the collection.

template<typename OsgObject>
bool makVrv::DtOsgReferencedCollection< OsgObject >::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 name was already pending.

Returns
true if the object was found, and the value should be returned. A returned value may be NULL if there was a problem with the object pending.
template<typename OsgObject>
osg::ref_ptr<OsgObject> makVrv::DtOsgReferencedCollection< OsgObject >::find ( const std::string &  filename)

Look for an object and return a value (null or not).

template<typename OsgObject>
void makVrv::DtOsgReferencedCollection< OsgObject >::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 pending without adding anything)

template<typename OsgObject>
void makVrv::DtOsgReferencedCollection< OsgObject >::releaseGLObjects ( osg::State *  state)

Release GL objects on all objects in the cache.

template<typename OsgObject>
void makVrv::DtOsgReferencedCollection< OsgObject >::clear ( )

Clears all of the instances.

template<typename OsgObject>
bool makVrv::DtOsgReferencedCollection< OsgObject >::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 if it is not null.

Returns
whether or not the texture was found.
template<typename OsgObject>
bool makVrv::DtOsgReferencedCollection< OsgObject >::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.

Returns
whether or not the texture was found.
template<typename OsgObject>
void makVrv::DtOsgReferencedCollection< OsgObject >::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 when an openGL context is recreated.

template<typename OsgObject>
unsigned int makVrv::DtOsgReferencedCollection< OsgObject >::flush ( )

Do a partial flush of items.

Returns
the number of items flushed.
template<typename OsgObject>
unsigned int makVrv::DtOsgReferencedCollection< OsgObject >::partialFlush ( unsigned int  maxToCheck,
unsigned int  maxToFlush 
)

Do a partial flush of items.

Returns
the number of items flushed.
template<typename OsgObject>
unsigned int makVrv::DtOsgReferencedCollection< OsgObject >::flushTextures ( )

Do a flush of all textures.

Returns
the number of items flushed.
template<typename OsgObject>
unsigned int makVrv::DtOsgReferencedCollection< OsgObject >::partialFlushTextures ( unsigned int  maxToCheck,
unsigned int  maxToFlush 
)

Do a partial flush of items.

Returns
the number of items flushed.

Member Data Documentation

template<typename OsgObject>
boost::mutex makVrv::DtOsgReferencedCollection< OsgObject >::myMutex
protected
template<typename OsgObject>
boost::condition_variable makVrv::DtOsgReferencedCollection< OsgObject >::myPendingInstanceDone
protected
template<typename OsgObject>
InstanceMap makVrv::DtOsgReferencedCollection< OsgObject >::myInstanceMap
protected
template<typename OsgObject>
ReferenceList makVrv::DtOsgReferencedCollection< OsgObject >::myRefInstanceList
protected
template<typename OsgObject>
PendingSet makVrv::DtOsgReferencedCollection< OsgObject >::myPendingInstances
protected
template<typename OsgObject>
PendingSet makVrv::DtOsgReferencedCollection< OsgObject >::myFailedInstances
protected
template<typename OsgObject>
unsigned int makVrv::DtOsgReferencedCollection< OsgObject >::myPartialFlushIndex
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)