]> git.lyx.org Git - lyx.git/blobdiff - src/ModuleList.h
DocBook: simplify code to handle abstracts.
[lyx.git] / src / ModuleList.h
index d79138f213196121683b8d77192955e1e7970f2e..1095f9ee64c7beed9eba565d01926c0fe0914f98 100644 (file)
 #ifndef MODULELIST_H
 #define MODULELIST_H
 
-#include <map>
 #include <string>
 #include <vector>
 
 namespace lyx {
-       
+
 /**
- *  This class represents a particular LyX "module", which is like a layout
- *  file, except that it does not stand alone. In that sense, it is more like 
- *  a LaTeX package, where a layout file corresponds to a LaTeX class. Or, in 
+ *  This class represents a particular LyX "module", which is like a layout
+ *  file, except that it does not stand alone. In that sense, it is more like
+ *  a LaTeX package, where a layout file corresponds to a LaTeX class. Or, in
  *  LyX's own terms, a module is more like an included file that can be used
  *  with various document classes. The difference is that using a module only
- *  means selecting it in the Document>Settings dialog, whereas including a 
+ *  means selecting it in the Document>Settings dialog, whereas including a
  *  layout file means layout file editing.
  *
  *  In general, a given module can be used with any document class. That said,
@@ -32,14 +31,14 @@ namespace lyx {
  *  The requires and excludes are given in comments within the module file,
  *  which must begin roughly so:
  *   #\DeclareLyXModule{Theorems (By Section)}
+ *   #\DeclateCategory{Theorems}
  *   #DescriptionBegin
  *   #Numbers theorems and the like by section.
  *   #DescriptionEnd
  *   #Requires: theorems-std | theorems-ams
  *   #Excludes: theorems-chap
- *   #Category: theorems
  *  The description is used in the gui to give information to the user. The
- *  Requires, Excludes, and Categofy lines are read by the configuration script 
+ *  Requires, Excludes, and Category lines are read by the configuration script
  *  and written to a file lyxmodules.lst in the user configuration directory.
  *  That file is then read on startup to populate the ModuleList, below.
  *
@@ -50,14 +49,16 @@ namespace lyx {
 class LyXModule {
 public:
        ///
-       LyXModule(std::string const & name, std::string const & id, 
-                 std::string const & description, 
+       LyXModule(std::string const & name, std::string const & id,
+                 std::string const & description,
                  std::vector<std::string> const & packagelist,
-                 std::vector<std::string> const & requires, 
+                         std::vector<std::string> const & required,
                  std::vector<std::string> const & excludes,
-                 std::string const & catgy);
+                 std::string const & catgy, bool const local);
        /// whether the required packages are available
-       bool isAvailable();
+       bool isAvailable() const;
+       /// the missing prerequisites, if any
+       std::vector<std::string> prerequisites() const;
        ///
        std::string const & getName() const { return name_; }
        ///
@@ -70,13 +71,15 @@ public:
        std::vector<std::string> const & getPackageList() const
                { return package_list_; }
        ///
-       std::vector<std::string> const & getRequiredModules() const 
+       std::vector<std::string> const & getRequiredModules() const
                { return required_modules_; }
        /// Modules this one excludes: the list should be treated disjunctively
-       std::vector<std::string> const & getExcludedModules() const 
+       std::vector<std::string> const & getExcludedModules() const
                { return excluded_modules_; }
        ///
        std::string category() const { return category_; }
+       /// Is this a local module (from the user directory)?
+       bool isLocal() const { return local_; }
        /// \return true if the module is compatible with this one, i.e.,
        /// it does not exclude us and we do not exclude it.
        /// this will also return true if modname is unknown and we do not
@@ -102,10 +105,16 @@ private:
        std::vector<std::string> excluded_modules_;
        /// Category, also used in the UI
        std::string category_;
+       // these are mutable because they are used to cache the results
+       // or an otherwise const operation.
+       ///
+       mutable bool checked_;
+       ///
+       mutable bool available_;
        ///
-       bool checked_;
+       mutable bool local_;
        ///
-       bool available_;
+       mutable std::vector<std::string> prerequisites_;
 };
 
 typedef std::vector<LyXModule> LyXModuleList;
@@ -132,21 +141,23 @@ public:
        bool empty() const { return modlist_.empty(); }
        /// Returns a pointer to the LyXModule with filename str.
        /// Returns a null pointer if no such module is found.
+       LyXModule const * operator[](std::string const & str) const;
+       ///
        LyXModule * operator[](std::string const & str);
-private:
+       private:
        /// noncopyable
        ModuleList(ModuleList const &);
        ///
        void operator=(ModuleList const &);
        /// add a module to the list
-       void addLayoutModule(std::string const &, std::string const &, 
+       void addLayoutModule(std::string const &, std::string const &,
                std::string const &, std::vector<std::string> const &,
                std::vector<std::string> const &, std::vector<std::string> const &,
-               std::string const &);
+               std::string const &, bool const);
        ///
        std::vector<LyXModule> modlist_;
 };
 
 extern ModuleList theModuleList;
-}
+} // namespace lyx
 #endif