other versions
- wheezy-backports 3.1.4~abc9f50-3~bpo70+1
- jessie 3.1.4~abc9f50-7
SoCache(3) | Coin | SoCache(3) |
NAME¶
SoCache - The SoCache class is the superclass for all internal cache classes. It organizes reference counting to make it possible to share cache instances. It also organizes a list of elements that will affect the cache. If any of the elements have changed since the cache was created, the cache is invalid.SYNOPSIS¶
#include <Inventor/caches/SoCache.h> Inherited by SoBoundingBoxCache, SoConvexDataCache, SoGLRenderCache, SoNormalCache, SoPrimitiveVertexCache, and SoTextureCoordinateCache.Public Member Functions¶
SoCache (SoState *const state)
Protected Member Functions¶
virtual void destroy (SoState *state)
Detailed Description¶
The SoCache class is the superclass for all internal cache classes. It organizes reference counting to make it possible to share cache instances. It also organizes a list of elements that will affect the cache. If any of the elements have changed since the cache was created, the cache is invalid.SbBool storedinvalid = SoCacheElement::setInvalid(FALSE); state->push(); SoMyCache * cache = new SoMyCache(state); cache->ref(); SoCacheElement::set(state, cache); buildMyCache(); state->pop(); SoCacheElement::setInvalid(storedinvalid);First you reset and store the old value of the cache invalid-flag. Then you push the state so that the cache can detect when something outside the cache is changed (and to be able to change the cache element). Next, you create the cache - don't forget to ref it. Finally, set the current cache in the cache element and build the cache. After building the cache, you pop the state and restore the invalid-cache flag. When building the cache, all elements that are read will be copied into the cache (using SoElement::copyMatchInfo()), and these copied elements are used to test the validity of the cache (in SoCache::isValid()). You don't have to manually add element dependencies. They will automatically be picked up when creating the cache. This is handled in SoElement::getConstElement(). If you want the cache to be invalidated when some field inside your node is changed, it's common to overload the notify()-method, and call SoCache::invalidate() whenever the notify()-method for your node is called. See for instance SoShape::notify(). Also, don't delete the cache in your notify() method. Wait until the next time the cache is needed before unref-ing the old cache.
Constructor & Destructor Documentation¶
SoCache::SoCache (SoState *conststate)¶
Constructor with state being the current state.SoCache::~SoCache () [protected], [virtual]¶
DestructorMember Function Documentation¶
void SoCache::ref (void)¶
Increases the reference count by one.void SoCache::unref (SoState *state = NULL)¶
Decreases the reference count by one. When the reference count reaches zero, the cache is deleted. The SoCache::destroy() method is called before the destructor is called.void SoCache::addElement (const SoElement *constelem)¶
Adds elem to the list of elements this cache depends on.void SoCache::addCacheDependency (const SoState *state, SoCache *cache) [virtual]¶
Adds dependencies from cache to this cache.SbBool SoCache::isValid (const SoState *state) const [virtual]¶
Return TRUE if this cache is valid, FALSE otherwise. Reimplemented in SoPrimitiveVertexCache, and SoGLRenderCache.const SoElement * SoCache::getInvalidElement (const SoState *conststate) const¶
Returns the element that caused the invalidation. Returns NULL if the cache is valid, or if the cache was not invalidated bacause of an element.void SoCache::invalidate (void)¶
Forces a cache to be invalid.void SoCache::destroy (SoState *state) [protected], [virtual]¶
Can be overridden by subclasses to clean up before they are deleted. Default method does nothing. Reimplemented in SoGLRenderCache.Author¶
Generated automatically by Doxygen for Coin from the source code.Sat Oct 12 2013 | Version 4.0.0a |