ObjectCache
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGDB_OBJECTCACHE
#define OSGDB_OBJECTCACHE 1
#include <osg/Node>
#include <osgDB/ReaderWriter>
#include <osgDB/DatabaseRevisions>
#include <map>
namespace osgDB {
class OSGDB_EXPORT ObjectCache : public osg::Referenced
{
public:
ObjectCache();
void updateTimeStampOfObjectsInCacheWithExternalReferences(double referenceTime);
void removeExpiredObjectsInCache(double expiryTime);
void clear();
void addObjectCache(ObjectCache* object);
void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0, const Options *options = NULL);
void removeFromObjectCache(const std::string& fileName, const Options *options = NULL);
osg::Object* getFromObjectCache(const std::string& fileName, const Options *options = NULL);
osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName, const Options *options = NULL);
void releaseGLObjects(osg::State* state);
protected:
virtual ~ObjectCache();
typedef std::pair<std::string, osg::ref_ptr<const osgDB::Options> > FileNameOptionsPair;
struct ClassComp
{
bool operator() (const ObjectCache::FileNameOptionsPair& lhs, const ObjectCache::FileNameOptionsPair& rhs) const;
};
typedef std::pair<osg::ref_ptr<osg::Object>, double > ObjectTimeStampPair;
typedef std::map<FileNameOptionsPair, ObjectTimeStampPair, ClassComp> ObjectCacheMap;
ObjectCacheMap::iterator find(const std::string& fileName, const osgDB::Options* options);
ObjectCacheMap _objectCache;
OpenThreads::Mutex _objectCacheMutex;
};
}
#endif
DatabaseRevisions
Node
ReaderWriter
OpenThreads::Mutex
This class provides an object-oriented thread mutex interface.
Definition Mutex:31
osgDB::ObjectCache::clear
void clear()
osgDB::ObjectCache::addObjectCache
void addObjectCache(ObjectCache *object)
osgDB::ObjectCache::updateTimeStampOfObjectsInCacheWithExternalReferences
void updateTimeStampOfObjectsInCacheWithExternalReferences(double referenceTime)
osgDB::ObjectCache::_objectCacheMutex
OpenThreads::Mutex _objectCacheMutex
Definition ObjectCache:85
osgDB::ObjectCache::removeFromObjectCache
void removeFromObjectCache(const std::string &fileName, const Options *options=NULL)
osgDB::ObjectCache::removeExpiredObjectsInCache
void removeExpiredObjectsInCache(double expiryTime)
osgDB::ObjectCache::getFromObjectCache
osg::Object * getFromObjectCache(const std::string &fileName, const Options *options=NULL)
osgDB::ObjectCache::find
ObjectCacheMap::iterator find(const std::string &fileName, const osgDB::Options *options)
osgDB::ObjectCache::~ObjectCache
virtual ~ObjectCache()
osgDB::ObjectCache::ObjectCacheMap
std::map< FileNameOptionsPair, ObjectTimeStampPair, ClassComp > ObjectCacheMap
Definition ObjectCache:80
osgDB::ObjectCache::getRefFromObjectCache
osg::ref_ptr< osg::Object > getRefFromObjectCache(const std::string &fileName, const Options *options=NULL)
osgDB::ObjectCache::ObjectTimeStampPair
std::pair< osg::ref_ptr< osg::Object >, double > ObjectTimeStampPair
Definition ObjectCache:79
osgDB::ObjectCache::addEntryToObjectCache
void addEntryToObjectCache(const std::string &filename, osg::Object *object, double timestamp=0.0, const Options *options=NULL)
osgDB::ObjectCache::releaseGLObjects
void releaseGLObjects(osg::State *state)
osgDB::ObjectCache::_objectCache
ObjectCacheMap _objectCache
Definition ObjectCache:84
osgDB::ObjectCache::FileNameOptionsPair
std::pair< std::string, osg::ref_ptr< const osgDB::Options > > FileNameOptionsPair
Definition ObjectCache:71
osgDB::ObjectCache::ObjectCache
ObjectCache()
osgDB::Options
Definition Options:30
osg::Object
Definition Object:61
osg::Referenced
Definition Referenced:44
osg::State
Definition State:80
osg::ref_ptr
Definition ref_ptr:32
osgDB
Definition Archive:24
OSGDB_EXPORT
#define OSGDB_EXPORT
Definition osgDB/Export:39
NULL
#define NULL
Definition osg/Export:55
osgDB::ObjectCache::ClassComp
Definition ObjectCache:74