mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2024-12-28 00:15:06 +00:00
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
#ifndef OPENMW_COMPONENTS_MULTIOBJECTCACHE_H
|
|
#define OPENMW_COMPONENTS_MULTIOBJECTCACHE_H
|
|
|
|
#include <map>
|
|
#include <mutex>
|
|
#include <string>
|
|
|
|
#include <osg/Referenced>
|
|
#include <osg/ref_ptr>
|
|
|
|
namespace osg
|
|
{
|
|
class Object;
|
|
class State;
|
|
}
|
|
|
|
namespace Resource
|
|
{
|
|
|
|
/// @brief Cache for "non reusable" objects.
|
|
class MultiObjectCache : public osg::Referenced
|
|
{
|
|
public:
|
|
MultiObjectCache();
|
|
~MultiObjectCache();
|
|
|
|
void removeUnreferencedObjectsInCache();
|
|
|
|
/** Remove all objects from the cache. */
|
|
void clear();
|
|
|
|
void addEntryToObjectCache(const std::string& filename, osg::Object* object);
|
|
|
|
/** Take an Object from cache. Return nullptr 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 std::mutex _objectCacheMutex;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|