4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
22 * This class represents a particular LyX "module", which is a like a layout
23 * file, except that it does not stand alone. In that sense, it is more like
24 * a LaTeX package, where a layout file corresponds to a LaTeX class. Or, in
25 * LyX's own terms, a module is more like an included file that can be used
26 * with various document classes. The difference is that using a module only
27 * means selecting it in the Document>Settings dialog, whereas including a
28 * layout file means layout file editing.
30 * In general, a given module can be used with any document class. That said,
31 * one module may `require' another, or it may `exclude' some other module.
32 * The requires and excludes are given in comments within the module file,
33 * which must begin roughly so:
34 * #\DeclareLyXModule{Theorems (By Section)}
36 * #Numbers theorems and the like by section.
38 * #Requires: theorems-std | theorems-ams
39 * #Excludes: theorems-chap
41 * The description is used in the gui to give information to the user. The
42 * Requires, Excludes, and Category lines are read by the configuration script
43 * and written to a file lyxmodules.lst in the user configuration directory.
44 * That file is then read on startup to populate the ModuleList, below.
46 * Modules can also be "provided" or "excluded" by document classes, using
47 * the ProvidesModule and ExcludesModule tags.
53 LyXModule(std::string const & name, std::string const & id,
54 std::string const & description,
55 std::vector<std::string> const & packagelist,
56 std::vector<std::string> const & requires,
57 std::vector<std::string> const & excludes,
58 std::string const & catgy);
59 /// whether the required packages are available
60 bool isAvailable() const;
61 /// the missing prerequisites, if any
62 std::vector<std::string> prerequisites() const;
64 std::string const & getName() const { return name_; }
66 std::string const & getID() const { return id_; }
68 std::string const & getFilename() const { return filename_; }
70 std::string const & getDescription() const { return description_; }
72 std::vector<std::string> const & getPackageList() const
73 { return package_list_; }
75 std::vector<std::string> const & getRequiredModules() const
76 { return required_modules_; }
77 /// Modules this one excludes: the list should be treated disjunctively
78 std::vector<std::string> const & getExcludedModules() const
79 { return excluded_modules_; }
81 std::string category() const { return category_; }
82 /// \return true if the module is compatible with this one, i.e.,
83 /// it does not exclude us and we do not exclude it.
84 /// this will also return true if modname is unknown and we do not
85 /// exclude it, since in that case we cannot check its exclusions.
86 bool isCompatible(std::string const & modname) const;
88 static bool areCompatible(std::string const & mod1, std::string const & mod2);
90 /// what appears in the ui
92 /// the module's unique identifier
93 /// at present, this is the filename, without the extension
96 std::string filename_;
97 /// a short description for use in the ui
98 std::string description_;
99 /// the LaTeX packages on which this depends, if any
100 std::vector<std::string> package_list_;
101 /// Modules this one requires: at least one
102 std::vector<std::string> required_modules_;
103 /// Modules this one excludes: none of these
104 std::vector<std::string> excluded_modules_;
105 /// Category, also used in the UI
106 std::string category_;
107 // these are mutable because they are used to cache the results
108 // or an otherwise const operation.
110 mutable bool checked_;
112 mutable bool available_;
114 mutable std::vector<std::string> prerequisites_;
117 typedef std::vector<LyXModule> LyXModuleList;
120 * The ModuleList represents the various LyXModule's that are available at
127 /// reads the modules from a file generated by configure.py
130 LyXModuleList::const_iterator begin() const;
132 LyXModuleList::iterator begin();
134 LyXModuleList::const_iterator end() const;
136 LyXModuleList::iterator end();
138 bool empty() const { return modlist_.empty(); }
139 /// Returns a pointer to the LyXModule with filename str.
140 /// Returns a null pointer if no such module is found.
141 LyXModule const * operator[](std::string const & str) const;
143 LyXModule * operator[](std::string const & str);
146 ModuleList(ModuleList const &);
148 void operator=(ModuleList const &);
149 /// add a module to the list
150 void addLayoutModule(std::string const &, std::string const &,
151 std::string const &, std::vector<std::string> const &,
152 std::vector<std::string> const &, std::vector<std::string> const &,
153 std::string const &);
155 std::vector<LyXModule> modlist_;
158 extern ModuleList theModuleList;