From 4cd4457d21744e8f4b39eed2e88b1ce45df3d711 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 6 Mar 2017 16:19:32 +0100 Subject: [PATCH] Add support for Functors to ObjectCache --- components/resource/objectcache.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/resource/objectcache.hpp b/components/resource/objectcache.hpp index e1caa4123..72db835e8 100644 --- a/components/resource/objectcache.hpp +++ b/components/resource/objectcache.hpp @@ -73,6 +73,15 @@ class ObjectCache : public osg::Referenced /** call node->accept(nv); for all nodes in the objectCache. */ void accept(osg::NodeVisitor& nv); + /** call operator()(osg::Object*) for each object in the cache. */ + template + void call(Functor& f) + { + OpenThreads::ScopedLock lock(_objectCacheMutex); + for (ObjectCacheMap::iterator it = _objectCache.begin(); it != _objectCache.end(); ++it) + f(it->second.first.get()); + } + /** Get the number of objects in the cache. */ unsigned int getCacheSize() const;