You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
9 years ago
|
#ifndef OPENMW_COMPONENTS_MULTIOBJECTCACHE_H
|
||
|
#define OPENMW_COMPONENTS_MULTIOBJECTCACHE_H
|
||
|
|
||
|
#include <map>
|
||
|
#include <string>
|
||
|
|
||
|
#include <osg/ref_ptr>
|
||
|
#include <osg/Referenced>
|
||
|
|
||
|
namespace osg
|
||
|
{
|
||
|
class Object;
|
||
|
class State;
|
||
|
}
|
||
|
|
||
|
namespace Resource
|
||
|
{
|
||
|
|
||
|
/// @brief Cache for "non reusable" objects.
|
||
|
class MultiObjectCache : public osg::Referenced
|
||
|
{
|
||
|
public:
|
||
|
MultiObjectCache();
|
||
|
~MultiObjectCache();
|
||
|
|
||
|
void removeUnreferencedObjectsInCache();
|
||
|
|
||
|
void addEntryToObjectCache(const std::string& filename, osg::Object* object);
|
||
|
|
||
|
/** Take an Object from cache. Return NULL if no object found. */
|
||
|
osg::ref_ptr<osg::Object> takeFromObjectCache(const std::string& fileName);
|
||
|
|
||
|
/** call releaseGLObjects on all objects attached to the object cache.*/
|
||
|
void releaseGLObjects(osg::State* state);
|
||
|
|
||
|
protected:
|
||
|
|
||
|
typedef std::multimap<std::string, osg::ref_ptr<osg::Object> > ObjectCacheMap;
|
||
|
|
||
|
ObjectCacheMap _objectCache;
|
||
|
OpenThreads::Mutex _objectCacheMutex;
|
||
|
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|