1 /* This file is part of
2 * =================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich.
6 * Copyright 1995-2001 The LyX Team.
8 * This file Copyright 2000 Baruch Even
9 * ================================================= */
14 #pragma implementation
17 #include "GraphicsCache.h"
18 #include "GraphicsCacheItem.h"
20 #include "support/LAssert.h"
23 GraphicsCache::getInstance()
25 static GraphicsCache singleton;
30 GraphicsCache::~GraphicsCache()
32 // All elements are destroyed by the shared_ptr's in the map.
36 GraphicsCache::shared_ptr_item
37 GraphicsCache::addFile(string const & filename)
39 CacheType::iterator it = cache.find(filename);
41 if (it != cache.end()) {
45 shared_ptr_item cacheItem(new GraphicsCacheItem(filename));
46 if (cacheItem.get() == 0)
49 cache[filename] = cacheItem;
51 // GraphicsCacheItem_ptr is a shared_ptr and thus reference counted,
52 // it is safe to return it directly.
58 GraphicsCache::removeFile(string const & filename)
60 // We do not destroy the GraphicsCacheItem since we are here because
61 // the last copy of it is being erased.
63 CacheType::iterator it = cache.find(filename);
64 if (it != cache.end())