Am 31.05.2016 um 17:42 schrieb Robert Osfield:
> Hi Ralf,
>
> I have just done a first pass review and understand the motivation
> behind the change but feel that it's not general purpose enough to be
> robust, so while an improvement on the current approach it doesn't
> full address the possibility of different Options object mapping to
> different loaded models.
>
> I think the right approach would be to use the filename string and
> Options object as a key rather than just attempting to reuse the
> filename to encode extra information
So you suggest to change addEntryToObjectCache() to
void addEntryToObjectCache(const std::string& filename, osg::Object*
object, double timestamp = 0.0, Options *options = NULL);
and to implement as
void ObjectCache::addEntryToObjectCache(const std::string& filename,
osg::Object* object, double timestamp, Options *options)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
if (options)
{
std::string key = filename + options->getContentHash();
_objectCache[key]=ObjectTimeStampPair(object,timestamp);
}
else
_objectCache[filename]=ObjectTimeStampPair(object,timestamp);
}
where Options::getContentHash() is a method to get a unique hash for the
content of the Options instance (may be the string representation of the
Options instance address) ?
and for searching to extend getRefFromObjectCache() to
osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string&
fileName, const Options *options = NULL);
with an optional options parameter and to implement it as
osg::ref_ptr<osg::Object> ObjectCache::getRefFromObjectCache(const
std::string& fileName, const Options *options)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
ObjectCacheMap::iterator itr;
if (options)
itr = _objectCache.find(fileName + options.getContentHash());
else
itr = _objectCache.find(fileName);
if (itr!=_objectCache.end())
{
// OSG_NOTICE<<"Found "<<fileName<<" in ObjectCache
"<<this<<std::endl;
return itr->second.first;
}
else return 0;
}
Ralf
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org