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.
21 * This class represents a particular LyX "module", which is a like a layout
22 * file, except that it does not stand alone. In that sense, it is more like
23 * a LaTeX package, where a layout file corresponds to a LaTeX class. Or, in
24 * LyX's own terms, a module is more like an included file that can be used
25 * with various document classes. The difference is that using a module only
26 * means selecting it in the Document>Settings dialog, whereas including a
27 * layout file means layout file editing.
29 * In general, a given module can be used with any document class. That said,
30 * one module may `require' another, or it may `exclude' some other module.
31 * The requires and excludes are given in comments within the module file,
32 * which must begin roughly so:
33 * #\DeclareLyXModule{Theorems (By Section)}
35 * #Numbers theorems and the like by section.
37 * #Requires: theorems-std | theorems-ams
38 * #Excludes: theorems-chap
40 * The description is used in the gui to give information to the user. The
41 * Requires, Excludes, and Category lines are read by the configuration script
42 * and written to a file lyxmodules.lst in the user configuration directory.
43 * That file is then read on startup to populate the ModuleList, below.
45 * Modules can also be "provided" or "excluded" by document classes, using
46 * the ProvidesModule and ExcludesModule tags.
52 LyXModule(std::string const & name, std::string const & id,
53 std::string const & description,
54 std::vector<std::string> const & packagelist,
55 std::vector<std::string> const & requires,
56 std::vector<std::string> const & excludes,
57 std::string const & catgy);
58 /// whether the required packages are available
59 bool isAvailable() const;
60 /// the missing prerequisites, if any
61 std::vector<std::string> prerequisites() const;
63 std::string const & getName() const { return name_; }
65 std::string const & getID() const { return id_; }
67 std::string const & getFilename() const { return filename_; }
69 std::string const & getDescription() const { return description_; }
71 std::vector<std::string> const & getPackageList() const
72 { return package_list_; }
74 std::vector<std::string> const & getRequiredModules() const
75 { return required_modules_; }
76 /// Modules this one excludes: the list should be treated disjunctively
77 std::vector<std::string> const & getExcludedModules() const
78 { return excluded_modules_; }
80 std::string category() const { return category_; }
81 /// \return true if the module is compatible with this one, i.e.,
82 /// it does not exclude us and we do not exclude it.
83 /// this will also return true if modname is unknown and we do not
84 /// exclude it, since in that case we cannot check its exclusions.
85 bool isCompatible(std::string const & modname) const;
87 static bool areCompatible(std::string const & mod1, std::string const & mod2);
89 /// what appears in the ui
91 /// the module's unique identifier
92 /// at present, this is the filename, without the extension
95 std::string filename_;
96 /// a short description for use in the ui
97 std::string description_;
98 /// the LaTeX packages on which this depends, if any
99 std::vector<std::string> package_list_;
100 /// Modules this one requires: at least one
101 std::vector<std::string> required_modules_;
102 /// Modules this one excludes: none of these
103 std::vector<std::string> excluded_modules_;
104 /// Category, also used in the UI
105 std::string category_;
106 // these are mutable because they are used to cache the results
107 // or an otherwise const operation.
109 mutable bool checked_;
111 mutable bool available_;
113 mutable std::vector<std::string> prerequisites_;
116 typedef std::vector<LyXModule> LyXModuleList;
119 * The ModuleList represents the various LyXModule's that are available at
126 /// reads the modules from a file generated by configure.py
129 LyXModuleList::const_iterator begin() const;
131 LyXModuleList::iterator begin();
133 LyXModuleList::const_iterator end() const;
135 LyXModuleList::iterator end();
137 bool empty() const { return modlist_.empty(); }
138 /// Returns a pointer to the LyXModule with filename str.
139 /// Returns a null pointer if no such module is found.
140 LyXModule const * operator[](std::string const & str) const;
142 LyXModule * operator[](std::string const & str);
145 ModuleList(ModuleList const &);
147 void operator=(ModuleList const &);
148 /// add a module to the list
149 void addLayoutModule(std::string const &, std::string const &,
150 std::string const &, std::vector<std::string> const &,
151 std::vector<std::string> const &, std::vector<std::string> const &,
152 std::string const &);
154 std::vector<LyXModule> modlist_;
157 extern ModuleList theModuleList;