2 /* This file is part of
3 * =================================================
5 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich.
7 * Copyright 1995-2001 The LyX Team.
9 * This file Copyright 2000 Baruch Even
10 * ================================================= */
15 #pragma implementation
18 #include "GraphicsCache.h"
19 #include "GraphicsCacheItem.h"
21 #include "support/LAssert.h"
24 GraphicsCache::getInstance()
26 static GraphicsCache singleton;
31 GraphicsCache::~GraphicsCache()
33 // All elements are destroyed by the shared_ptr's in the map.
37 GraphicsCache::shared_ptr_item
38 GraphicsCache::addFile(string const & filename)
40 CacheType::iterator it = cache.find(filename);
42 if (it != cache.end()) {
46 shared_ptr_item cacheItem(new GraphicsCacheItem(filename));
47 if (cacheItem.get() == 0)
50 cache[filename] = cacheItem;
52 // GraphicsCacheItem_ptr is a shared_ptr and thus reference counted,
53 // it is safe to return it directly.
59 GraphicsCache::removeFile(string const & filename)
61 // We do not destroy the GraphicsCacheItem since we are here because
62 // the last copy of it is being erased.
64 CacheType::iterator it = cache.find(filename);
65 if (it != cache.end())