forked from mirror/openmw-tes3mp
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.
50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
#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);
|
|
|
|
unsigned int getCacheSize() const;
|
|
|
|
protected:
|
|
|
|
typedef std::multimap<std::string, osg::ref_ptr<osg::Object> > ObjectCacheMap;
|
|
|
|
ObjectCacheMap _objectCache;
|
|
mutable OpenThreads::Mutex _objectCacheMutex;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|