OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ObjectCache.h
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>
20 #include <osgDB/DatabaseRevisions>
21 
22 #include <map>
23 
24 namespace osgDB {
25 
27 {
28  public:
29 
30  ObjectCache();
31 
38  void updateTimeStampOfObjectsInCacheWithExternalReferences(double referenceTime);
39 
44  void removeExpiredObjectsInCache(double expiryTime);
45 
47  void clear();
48 
50  void addObjectCache(ObjectCache* object);
51 
53  void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0);
54 
56  void removeFromObjectCache(const std::string& fileName);
57 
59  osg::Object* getFromObjectCache(const std::string& fileName);
60 
62  osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName);
63 
65  void releaseGLObjects(osg::State* state);
66 
67  protected:
68 
69  virtual ~ObjectCache();
70 
71  typedef std::pair<osg::ref_ptr<osg::Object>, double > ObjectTimeStampPair;
72  typedef std::map<std::string, ObjectTimeStampPair > ObjectCacheMap;
73 
74  ObjectCacheMap _objectCache;
76 
77 };
78 
79 }
80 
81 #endif
This class provides an object-oriented thread mutex interface.
Definition: Mutex.h:31
OpenThreads::Mutex _objectCacheMutex
Definition: ObjectCache.h:75
std::map< std::string, ObjectTimeStampPair > ObjectCacheMap
Definition: ObjectCache.h:72
ObjectCacheMap _objectCache
Definition: ObjectCache.h:74
Definition: Archive.h:24
#define OSGDB_EXPORT
Definition: Export.h:39
std::pair< osg::ref_ptr< osg::Object >, double > ObjectTimeStampPair
Definition: ObjectCache.h:71