]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsCache.C
* src/LaTeX.C
[lyx.git] / src / graphics / GraphicsCache.C
index f56c3ae4ee123caea8c570755db1fe3a85177b1d..7201c7bfbfb6295429ae6f6b503b2273b7d2b572 100644 (file)
@@ -1,18 +1,16 @@
-/*
+/**
  * \file GraphicsCache.C
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Baruch Even <baruch.even@writeme.com>
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * \author Baruch Even
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "GraphicsCache.h"
 #include "GraphicsCacheItem.h"
 #include "GraphicsImage.h"
 
 #include "support/filetools.h"
 
-#include "frontends/lyx_gui.h"
-
 #include <map>
 
-namespace grfx {
+using std::string;
+
+
+namespace lyx {
+
+using support::FileName;
+
+namespace graphics {
 
 /** The cache contains one item per file, so use a map to find the
  *  cache item quickly by filename.
  */
-typedef std::map<string, Cache::ItemPtr> CacheType;
+typedef std::map<FileName, Cache::ItemPtr> CacheType;
 
-struct Cache::Impl {
+class Cache::Impl {
+public:
        ///
        CacheType cache;
 };
 
-       
+
 Cache & Cache::get()
 {
-       static bool start = true;
-       if (start) {
-               start = false;
-               lyx_gui::init_graphics();
-       }
-
        // Now return the cache
        static Cache singleton;
        return singleton;
@@ -53,7 +51,7 @@ Cache & Cache::get()
 
 
 Cache::Cache()
-       : pimpl_(new Impl())
+       : pimpl_(new Impl)
 {}
 
 
@@ -67,15 +65,8 @@ std::vector<string> Cache::loadableFormats() const
 }
 
 
-void Cache::add(string const & file)
+void Cache::add(FileName const & file) const
 {
-       if (!AbsolutePath(file)) {
-               lyxerr << "Cache::add(" << file << "):\n"
-                      << "The file must be have an absolute path."
-                      << std::endl;
-               return;
-       }
-
        // Is the file in the cache already?
        if (inCache(file)) {
                lyxerr[Debug::GRAPHICS] << "Cache::add(" << file << "):\n"
@@ -88,7 +79,7 @@ void Cache::add(string const & file)
 }
 
 
-void Cache::remove(string const & file)
+void Cache::remove(FileName const & file) const
 {
        CacheType::iterator it = pimpl_->cache.find(file);
        if (it == pimpl_->cache.end())
@@ -104,13 +95,13 @@ void Cache::remove(string const & file)
 }
 
 
-bool Cache::inCache(string const & file) const
+bool Cache::inCache(FileName const & file) const
 {
        return pimpl_->cache.find(file) != pimpl_->cache.end();
 }
 
 
-Cache::ItemPtr const Cache::item(string const & file) const
+Cache::ItemPtr const Cache::item(FileName const & file) const
 {
        CacheType::const_iterator it = pimpl_->cache.find(file);
        if (it == pimpl_->cache.end())
@@ -119,4 +110,5 @@ Cache::ItemPtr const Cache::item(string const & file) const
        return it->second;
 }
 
-} // namespace grfx
+} // namespace graphics
+} // namespace lyx