Identify files in object cache by filename and optional provided options.
Objects with the same filename may be different from others based on the provided plugin options. Using filename *and* the provided options as object cache key helps to avoid fetching the wrong object.
This commit is contained in:
committed by
Robert Osfield
parent
3816e4c76e
commit
85cd1c456f
@@ -50,16 +50,16 @@ class OSGDB_EXPORT ObjectCache : public osg::Referenced
|
||||
void addObjectCache(ObjectCache* object);
|
||||
|
||||
/** Add a filename,object,timestamp triple to the Registry::ObjectCache.*/
|
||||
void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0);
|
||||
void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0, const Options *options = NULL);
|
||||
|
||||
/** Remove Object from cache.*/
|
||||
void removeFromObjectCache(const std::string& fileName);
|
||||
void removeFromObjectCache(const std::string& fileName, const Options *options = NULL);
|
||||
|
||||
/** Get an Object from the object cache*/
|
||||
osg::Object* getFromObjectCache(const std::string& fileName);
|
||||
osg::Object* getFromObjectCache(const std::string& fileName, const Options *options = NULL);
|
||||
|
||||
/** Get an ref_ptr<Object> from the object cache*/
|
||||
osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName);
|
||||
osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName, const Options *options = NULL);
|
||||
|
||||
/** call rleaseGLObjects on all objects attached to the object cache.*/
|
||||
void releaseGLObjects(osg::State* state);
|
||||
@@ -69,7 +69,8 @@ class OSGDB_EXPORT ObjectCache : public osg::Referenced
|
||||
virtual ~ObjectCache();
|
||||
|
||||
typedef std::pair<osg::ref_ptr<osg::Object>, double > ObjectTimeStampPair;
|
||||
typedef std::map<std::string, ObjectTimeStampPair > ObjectCacheMap;
|
||||
typedef std::pair<std::string, osg::ref_ptr<const osgDB::Options> > FileNameOptionsPair;
|
||||
typedef std::map<FileNameOptionsPair, ObjectTimeStampPair > ObjectCacheMap;
|
||||
|
||||
ObjectCacheMap _objectCache;
|
||||
OpenThreads::Mutex _objectCacheMutex;
|
||||
|
||||
@@ -255,10 +255,12 @@ class OSGDB_EXPORT Options : public osg::Object
|
||||
/** Get the parentGroup observer_ptr, where the loaded model is intended to be added */
|
||||
const osg::observer_ptr<osg::Group>& getParentGroup() const { return _parentGroup; }
|
||||
|
||||
protected:
|
||||
|
||||
bool operator < (const Options &rhs) const;
|
||||
bool operator == (const Options &rhs) const;
|
||||
virtual ~Options() {}
|
||||
|
||||
protected:
|
||||
|
||||
std::string _str;
|
||||
FilePathList _databasePaths;
|
||||
|
||||
|
||||
@@ -452,16 +452,16 @@ class OSGDB_EXPORT Registry : public osg::Referenced
|
||||
void clearObjectCache();
|
||||
|
||||
/** Add a filename,object,timestamp triple to the Registry::ObjectCache.*/
|
||||
void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0);
|
||||
void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0, Options *options = NULL);
|
||||
|
||||
/** Remove Object from cache.*/
|
||||
void removeFromObjectCache(const std::string& fileName);
|
||||
void removeFromObjectCache(const std::string& fileName, Options *options = NULL);
|
||||
|
||||
/** Get an Object from the object cache*/
|
||||
osg::Object* getFromObjectCache(const std::string& fileName);
|
||||
osg::Object* getFromObjectCache(const std::string& fileName, Options *options = NULL);
|
||||
|
||||
/** Get an ref_ptr<Object> from the object cache*/
|
||||
osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName);
|
||||
osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName, Options *options = NULL);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user