openscenegraph
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
86
87};
88
89}
90
91#endif
This class provides an object-oriented thread mutex interface.
Definition Mutex:31
Definition ObjectCache:27
void addObjectCache(ObjectCache *object)
void updateTimeStampOfObjectsInCacheWithExternalReferences(double referenceTime)
OpenThreads::Mutex _objectCacheMutex
Definition ObjectCache:85
void removeFromObjectCache(const std::string &fileName, const Options *options=NULL)
void removeExpiredObjectsInCache(double expiryTime)
osg::Object * getFromObjectCache(const std::string &fileName, const Options *options=NULL)
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)
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)
void releaseGLObjects(osg::State *state)
ObjectCacheMap _objectCache
Definition ObjectCache:84
std::pair< std::string, osg::ref_ptr< const osgDB::Options > > FileNameOptionsPair
Definition ObjectCache:71
Definition Options:30
Definition Object:61
Definition Referenced:44
Definition State:80
Definition ref_ptr:32
Definition Archive:24
#define OSGDB_EXPORT
Definition osgDB/Export:39
#define NULL
Definition osg/Export:55
Definition ObjectCache:74