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.
12 #ifndef LAYOUTMODULELIST_H
13 #define LAYOUTMODULELIST_H
22 class LayoutModuleList
{
25 typedef std::list
<std::string
>::const_iterator const_iterator
;
27 typedef std::list
<std::string
>::iterator iterator
;
29 iterator
begin() { return lml_
.begin(); }
31 iterator
end() { return lml_
.end(); }
33 const_iterator
begin() const { return lml_
.begin(); }
35 const_iterator
end() const { return lml_
.end(); }
37 void clear() { lml_
.clear(); }
39 bool empty() const { return lml_
.empty(); }
41 iterator
erase(iterator pos
) { return lml_
.erase(pos
); }
43 iterator
insert(iterator pos
, std::string
const & str
)
44 { return lml_
.insert(pos
, str
); }
46 void push_back(std::string
const & str
) { lml_
.push_back(str
); }
48 size_t size() const { return lml_
.size(); }
49 /// This is needed in GuiDocument. It seems better than an
50 /// implicit conversion.
51 std::list
<std::string
> const & list() const { return lml_
; }
52 /// Checks to make sure module's requriements are satisfied, that it does
53 /// not conflict with already-present modules, isn't already loaded, etc.
54 bool moduleCanBeAdded(std::string
const & modName
,
55 LayoutFile
const * const lay
) const;
56 /// If the user changes the base class for a given document, then the
57 /// associated module list has to be updated. This just calls
58 /// (i) removeBadModules()
59 /// (ii) addDefaultModules()
60 /// (iii) checkModuleConsistency()
61 /// in that order, for which see below.
62 /// \param lay The new base class.
63 /// \param removedModules Modules the user explicitly removed and so
64 /// which should not be included.
65 /// \return true if no changes had to be made, false if some did have
67 bool adaptToBaseClass(LayoutFile
const * const lay
,
68 std::list
<std::string
> const & removedModules
);
70 /// Removes modules excluded by, provided by, etc, the base class.
71 /// \param lay The document class against which to check.
72 /// \return true, if modules were consistent, false if changes had
74 bool removeBadModules(LayoutFile
const * const lay
);
75 /// Adds default modules, if they're addable.
76 /// \param lay The base class from which to get default modules.
77 /// \param removedModules Modules the user has explicitly removed.
78 void addDefaultModules(LayoutFile
const * const lay
,
79 std::list
<std::string
> removedModules
);
80 /// Checks for consistency among modules: makes sure requirements
81 /// are met, no modules exclude one another, etc, and resolves any
82 /// such conflicts, leaving us with a consistent collection.
83 /// \param lay The base class against which to check.
84 /// \return true if modules were consistent, false if changes had
86 bool checkModuleConsistency(LayoutFile
const * const lay
);
88 std::list
<std::string
> lml_
;