2 /* This file is part of
3 * =================================================
5 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich.
7 * Copyright 1995-2000 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 // The map elements should have already been eliminated.
34 Assert(cache.empty());
38 GraphicsCache::shared_ptr_item
39 GraphicsCache::addFile(string const & filename)
41 CacheType::iterator it = cache.find(filename);
43 if (it != cache.end()) {
47 shared_ptr_item cacheItem(new GraphicsCacheItem(filename));
48 if (cacheItem.get() == 0)
51 cache[filename] = cacheItem;
53 // GraphicsCacheItem_ptr is a shared_ptr and thus reference counted,
54 // it is safe to return it directly.
60 GraphicsCache::removeFile(string const & filename)
62 // We do not destroy the GraphicsCacheItem since we are here because
63 // the last copy of it is being erased.
65 CacheType::iterator it = cache.find(filename);
66 if (it != cache.end())