]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsCacheItem.h
Remove obsolete (and false) comment.
[lyx.git] / src / graphics / GraphicsCacheItem.h
index b3ccf7d8e282e52ff5d079f826e461558cda0037..6f7f968bc6a44086af831849470043faa4053c0e 100644 (file)
 // -*- C++ -*-
-/*
+/**
  * \file GraphicsCacheItem.h
- * 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
  *
- * The graphics cache is a container of GCacheItems. Each GCacheItem, defined
- * here represents a separate image file. The routines here can be used to
- * load the graphics file into memory at which point (status() == grfx::Loaded).
- * The user is then free to access image() in order to transform the image
- * (rotate, scale, clip) and to generate the pixmap.
+ * Full author contact details are available in file CREDITS.
+ *
+ * The graphics cache is a container of graphics::CacheItems.
+ * Each graphics::CacheItem, defined here represents a separate image file.
+ *
+ * The routines here can be used to load the graphics file into memory at
+ * which point (status() == graphics::Loaded).
+ * The user is then free to access image() in order to copy it and to then
+ * transform the copy (rotate, scale, clip) and to generate the pixmap.
  *
  * The graphics cache supports fully asynchronous:
  * file conversion to a loadable format;
  * file loading.
  *
- * Whether you get that, of course, depends on grfx::GConverter and on the
- * grfx::GImage-derived image class.
+ * Whether you get that, of course, depends on graphics::Converter and
+ * on the graphics::Image-derived image class.
  */
 
 #ifndef GRAPHICSCACHEITEM_H
 #define GRAPHICSCACHEITEM_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
-
 #include "GraphicsTypes.h"
-#include "LString.h"
 
-#include <boost/utility.hpp>
-#include <boost/shared_ptr.hpp>
+#include "support/signals.h"
 
-#include <boost/signals/signal0.hpp>
-#include <boost/signals/signal1.hpp>
-#include <boost/signals/connection.hpp>
-#include <boost/signals/trackable.hpp>
 
-class InsetGraphics;
+namespace lyx {
 
-namespace grfx {
+namespace support { class FileName; }
 
-/// A grfx::GCache item holder.
-class GCacheItem : boost::noncopyable, public boost::signals::trackable {
-public:
-       ///
-       GCacheItem(string const & file);
+namespace graphics {
 
-       /// It's in the cache. Now start the loading process.
-       void startLoading();
-
-       /** Get the image associated with filename_.
-           If the image is not yet loaded, return a null pointer.
-        */
-       ImagePtr const image() const { return image_; }
-
-       /// How far have we got in loading the image?
-       ImageStatus status() const { return status_; }
-
-       /// This signal is emitted when the image loading status changes.
-       boost::signal0<void> statusChanged;
+class Image;
+class Converter;
 
+/// A graphics::Cache item holder.
+class CacheItem {
+public:
        ///
-       string const & filename() const { return filename_; }
+       CacheItem(support::FileName const & file, support::FileName const & doc_file);
+       /// Needed for the pimpl
+       ~CacheItem();
 
-private:
-       /** Start the image conversion process, checking first that it is
-        *  necessary. If it is necessary, then a conversion task is started.
-        *  GCacheItem asumes that the conversion is asynchronous and so
-        *  passes a Signal to the converting routine. When the conversion
-        *  is finished, this Signal is emitted, returning the converted
-        *  file to this->imageConverted.
-        *
-        *  If no file conversion is needed, then convertToDisplayFormat() calls
-        *  loadImage() directly.
-        *
-        *  convertToDisplayFormat() will set the loading status flag as
-        *  approriate through calls to setStatus().
-        */
-       void convertToDisplayFormat();
-
-       /** Load the image into memory. This is called either from
-        *  convertToDisplayFormat() direct or from imageConverted().
-        */
-       void loadImage();
+       ///
+       support::FileName const & filename() const;
 
-       /** Get a notification when the image conversion is done.
-        *  Connected to a signal on_finish_ which is passed to
-        *  GConverter::convert.
-        */
-       void imageConverted(string const & file_to_load);
+       /// Try to load a display format.
+       bool tryDisplayFormat() const;
 
-       /** Get a notification when the image loading is done.
-        *  Connected to a signal on_finish_ which is passed to
-        *  GImage::loadImage.
-        */
-       void imageLoaded(bool);
+       /// It's in the cache. Now start the loading process.
+       void startLoading() const;
 
-       /** Sets the status of the loading process. Also notifies
-        *  listeners that the status has chacnged.
-        */
-       void setStatus(ImageStatus new_status);
-
-       /// The filename we refer too.
-       string filename_;
-       /// Is the file compressed?
-       bool zipped_;
-       /// If so, store the uncompressed file in this temporary file.
-       string unzipped_filename_;
-       /// What file are we trying to load?
-       string file_to_load_;
-       /** Should we delete the file after loading? True if the file is
-        *  the result of a conversion process.
+       /** Monitor any changes to the file.
+        *  There is no point monitoring the file before startLoading() is
+        *  invoked.
         */
-       bool remove_loaded_file_;
-
-       /// The image and its loading status.
-       ImagePtr image_;
+       void startMonitoring() const;
        ///
-       ImageStatus status_;
-
-       /** A SignalLoadTypePtr is connected to this->imageLoaded and
-        *  then passed to ImagePtr::load.
-        *  When the image has been loaded, the signal is emitted.
-        *
-        *  We pass a shared_ptr because it is eminently possible for the
-        *  GCacheItem to be destructed before the loading is complete and
-        *  the signal must remain in scope. It doesn't matter if the slot
-        *  disappears, SigC takes care of that.
+       bool monitoring() const;
+       /// perform a modification check asynchronously
+       void checkModifiedAsync() const;
+
+       /** Get the image associated with filename().
+        *  If the image is not yet loaded, returns 0.
+        *  This routine returns a pointer to const; if you want to modify it,
+        *  create a copy and modify that.
         */
-       typedef boost::signal1<void, bool> SignalLoadType;
-       ///
-       typedef boost::shared_ptr<SignalLoadType> SignalLoadTypePtr;
+       Image const * image() const;
 
-       /// The connection of the signal passed to ImagePtr::loadImage.
-       boost::signals::connection cl_;
+       /// How far have we got in loading the image?
+       ImageStatus status() const;
 
-       /** A SignalConvertTypePtr is connected to this->imageConverted and
-        *  then passed to GConverter::convert.
-        *  When the image has been converted to a loadable format, the signal
-        *  is emitted, returning the name of the loadable file to
-        *  imageConverted.
+       /** Connect and you'll be informed when the loading status of the image
+        *  changes.
         */
-       typedef boost::signal1<void, string const &> SignalConvertType;
+       typedef signals2::signal<void()>::slot_type slot_type;
        ///
-       typedef boost::shared_ptr<SignalConvertType> SignalConvertTypePtr;
+       signals2::connection connect(slot_type const &) const;
 
-       /// The connection of the signal passed to GConverter::convert.
-       boost::signals::connection cc_;
+private:
+       /// noncopyable
+       CacheItem(CacheItem const &);
+       void operator=(CacheItem const &);
+
+       /// Use the Pimpl idiom to hide the internals.
+       class Impl;
+       /// The pointer never changes although *pimpl_'s contents may.
+       Impl * const pimpl_;
 };
 
-} // namespace grfx
+} // namespace graphics
+} // namespace lyx
 
 #endif // GRAPHICSCACHEITEM_H