OpenSceneGraph 3.6.5
ObjectCache
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGDB_OBJECTCACHE
15#define OSGDB_OBJECTCACHE 1
16
17#include <osg/Node>
18
19#include <osgDB/ReaderWriter>
21
22#include <map>
23
24namespace osgDB {
25
27{
28 public:
29
31
39
44 void removeExpiredObjectsInCache(double expiryTime);
45
47 void clear();
48
51
53 void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0, const Options *options = NULL);
54
56 void removeFromObjectCache(const std::string& fileName, const Options *options = NULL);
57
59 osg::Object* getFromObjectCache(const std::string& fileName, const Options *options = NULL);
60
62 osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName, const Options *options = NULL);
63
66
67 protected:
68
69 virtual ~ObjectCache();
70
71 typedef std::pair<std::string, osg::ref_ptr<const osgDB::Options> > FileNameOptionsPair;
72
73 struct ClassComp
74 {
75 bool operator() (const ObjectCache::FileNameOptionsPair& lhs, const ObjectCache::FileNameOptionsPair& rhs) const;
76 };
77
78
79 typedef std::pair<osg::ref_ptr<osg::Object>, double > ObjectTimeStampPair;
80 typedef std::map<FileNameOptionsPair, ObjectTimeStampPair, ClassComp> ObjectCacheMap;
81
82 ObjectCacheMap::iterator find(const std::string& fileName, const osgDB::Options* options);
83
85 OpenThreads::Mutex _objectCacheMutex;
86
87};
88
89}
90
91#endif
The osgDB library provides support for reading and writing scene graphs, providing a plugin framework...
Definition Archive:24
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
void clear()
Remove all objects in the cache regardless of having external references or expiry times.
void addObjectCache(ObjectCache *object)
Add contents of specified ObjectCache to this object cache.
void updateTimeStampOfObjectsInCacheWithExternalReferences(double referenceTime)
For each object in the cache which has an reference count greater than 1 (and therefore referenced by...
OpenThreads::Mutex _objectCacheMutex
Definition ObjectCache:85
void removeFromObjectCache(const std::string &fileName, const Options *options=NULL)
Remove Object from cache.
void removeExpiredObjectsInCache(double expiryTime)
Removed object in the cache which have a time stamp at or before the specified expiry time.
osg::Object * getFromObjectCache(const std::string &fileName, const Options *options=NULL)
Deprecated, the getFromObjectCache() returns a C pointer that is not thread safe when using database ...
ObjectCacheMap::iterator find(const std::string &fileName, const osgDB::Options *options)
virtual ~ObjectCache()
std::map< FileNameOptionsPair, ObjectTimeStampPair, ClassComp > ObjectCacheMap
Definition ObjectCache:80
osg::ref_ptr< osg::Object > getRefFromObjectCache(const std::string &fileName, const Options *options=NULL)
Get a thread safe ref_ptr<Object> from the object cache.
std::pair< osg::ref_ptr< osg::Object >, double > ObjectTimeStampPair
Definition ObjectCache:79
void addEntryToObjectCache(const std::string &filename, osg::Object *object, double timestamp=0.0, const Options *options=NULL)
Add a filename,object,timestamp triple to the Registry::ObjectCache.
void releaseGLObjects(osg::State *state)
call rleaseGLObjects on all objects attached to the object cache.
ObjectCacheMap _objectCache
Definition ObjectCache:84
std::pair< std::string, osg::ref_ptr< const osgDB::Options > > FileNameOptionsPair
Definition ObjectCache:71
Definition ObjectCache:74
Options base class used for passing options into plugins to control their operation.
Definition Options:30
#define NULL
Definition Export:55
#define OSGDB_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.