X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FModuleList.h;h=e2d4a28f02dcf955aa7095d3a37ec9c688a0135a;hb=a6e3c59b94589c9043cd55ceaa3700849b4484dc;hp=fef293bbcc6b3c220c30d4f1985752732f053d07;hpb=5537e8a6b578aeda7c9119e8a2ed216a0267a941;p=lyx.git diff --git a/src/ModuleList.h b/src/ModuleList.h index fef293bbcc..e2d4a28f02 100644 --- a/src/ModuleList.h +++ b/src/ModuleList.h @@ -12,19 +12,18 @@ #ifndef MODULELIST_H #define MODULELIST_H -#include #include #include namespace lyx { - + /** - * This struct represents a particular LyX "module", which is a 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 a 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, @@ -37,64 +36,81 @@ namespace lyx { * #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 and Excludes lines are read by the configuration script and - * written to a file lyxmodules.lst in the user configuration directory. + * 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. + * + * Modules can also be "provided" or "excluded" by document classes, using + * the ProvidesModule and ExcludesModule tags. */ class LyXModule { public: /// - LyXModule(std::string const & n, std::string const & i, - std::string const & d, std::vector const & p, - std::vector const & r, - std::vector const & e); + LyXModule(std::string const & name, std::string const & id, + std::string const & description, + std::vector const & packagelist, + std::vector const & requires, + std::vector const & excludes, + std::string const & catgy); /// whether the required packages are available - bool isAvailable(); + bool isAvailable() const; + /// the missing prerequisites, if any + std::vector prerequisites() const; /// - std::string const & getName() const { return name; } + std::string const & getName() const { return name_; } /// - std::string const & getID() const { return id; } + std::string const & getID() const { return id_; } /// - std::string const & getFilename() const { return filename; } + std::string const & getFilename() const { return filename_; } /// - std::string const & getDescription() const { return description; } + std::string const & getDescription() const { return description_; } /// std::vector const & getPackageList() const - { return packageList; } + { return package_list_; } /// - std::vector const & getRequiredModules() const - { return requiredModules; } + std::vector const & getRequiredModules() const + { return required_modules_; } /// Modules this one excludes: the list should be treated disjunctively - std::vector const & getExcludedModules() const - { return excludedModules; } + std::vector const & getExcludedModules() const + { return excluded_modules_; } + /// + std::string category() const { return category_; } /// \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 + /// this will also return true if modname is unknown and we do not /// exclude it, since in that case we cannot check its exclusions. - bool isCompatible(std::string const & modName) const; + bool isCompatible(std::string const & modname) const; /// static bool areCompatible(std::string const & mod1, std::string const & mod2); private: /// what appears in the ui - std::string name; + std::string name_; /// the module's unique identifier /// at present, this is the filename, without the extension - std::string id; + std::string id_; /// the filename - std::string filename; + std::string filename_; /// a short description for use in the ui - std::string description; + std::string description_; /// the LaTeX packages on which this depends, if any - std::vector packageList; + std::vector package_list_; /// Modules this one requires: at least one - std::vector requiredModules; + std::vector required_modules_; /// Modules this one excludes: none of these - std::vector excludedModules; + std::vector 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. /// - bool checked; + mutable bool checked_; /// - bool available; + mutable bool available_; + /// + mutable std::vector prerequisites_; }; typedef std::vector LyXModuleList; @@ -108,7 +124,7 @@ public: /// ModuleList() {} /// reads the modules from a file generated by configure.py - bool load(); + bool read(); /// LyXModuleList::const_iterator begin() const; /// @@ -121,20 +137,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 const &, - std::vector const &, std::vector const &); + std::vector const &, std::vector const &, + std::string const &); /// std::vector modlist_; }; -extern ModuleList moduleList; -} +extern ModuleList theModuleList; +} // namespace lyx #endif