+LyXModule::LyXModule(string const & n, string const & i,
+ string const & d, vector<string> const & p,
+ vector<string> const & r, vector<string> const & e,
+ string const & c):
+ name_(n), id_(i), description_(d), package_list_(p),
+ required_modules_(r), excluded_modules_(e), category_(c),
+ checked_(false)
+{
+ filename_ = id_ + ".module";
+}
+
+
+bool LyXModule::isAvailable() const {
+#ifdef TEX2LYX
+ return true;
+#else
+ if (package_list_.empty())
+ return true;
+ if (checked_)
+ return available_;
+ checked_ = true;
+ //check whether all of the required packages are available
+ vector<string>::const_iterator it = package_list_.begin();
+ vector<string>::const_iterator end = package_list_.end();
+ for (; it != end; ++it) {
+ if (!LaTeXFeatures::isAvailable(*it)) {
+ available_ = false;
+ return available_;
+ }
+ }
+ available_ = true;
+ return available_;
+#endif
+}
+
+
+bool LyXModule::isCompatible(string const & modname) const
+{
+ // do we exclude it?
+ if (find(excluded_modules_.begin(), excluded_modules_.end(), modname) !=
+ excluded_modules_.end())
+ return false;
+
+ LyXModule const * const lm = theModuleList[modname];
+ if (!lm)
+ return true;
+
+ // does it exclude us?
+ vector<string> const excmods = lm->getExcludedModules();
+ if (find(excmods.begin(), excmods.end(), id_) != excmods.end())
+ return false;
+
+ return true;
+}
+
+
+bool LyXModule::areCompatible(string const & mod1, string const & mod2)
+{
+ LyXModule const * const lm1 = theModuleList[mod1];
+ if (lm1)
+ return lm1->isCompatible(mod2);
+ LyXModule const * const lm2 = theModuleList[mod2];
+ if (lm2)
+ return lm2->isCompatible(mod1);
+ // Can't check it either way.
+ return true;
+}
+