CacheItem * item = pimpl_->find(orig_from, to_format);
time_t const timestamp = fs::last_write_time(orig_from.toFilesystemEncoding());
- Mover const & mover = movers(to_format);
+ Mover const & mover = getMover(to_format);
if (item) {
lyxerr[Debug::FILES] << "ConverterCache::add(" << orig_from << "):\n"
"The file is already in the cache."
CacheItem * const item = pimpl_->find(orig_from, to_format);
BOOST_ASSERT(item);
- Mover const & mover = movers(to_format);
+ Mover const & mover = getMover(to_format);
return mover.copy(item->cache_name, dest);
}
res = one.startscript(type, command);
if (!real_outfile.empty()) {
- Mover const & mover = movers(conv.to);
+ Mover const & mover = getMover(conv.to);
if (!mover.rename(outfile, real_outfile))
res = -1;
else
token_base, from_base);
string const to = subst(conv.result_dir,
token_base, to_base);
- Mover const & mover = movers(conv.from);
+ Mover const & mover = getMover(conv.from);
if (!mover.rename(FileName(from), FileName(to))) {
Alert::error(_("Cannot convert file"),
bformat(_("Could not move a temporary directory from %1$s to %2$s."),
lyxerr[Debug::FILES] << "moving " << from2
<< " to " << to2 << endl;
- Mover const & mover = movers(fmt);
+ Mover const & mover = getMover(fmt);
bool const moved = copy
? mover.copy(*it, FileName(to2))
: mover.rename(*it, FileName(to2));
}
}
- Mover const & mover = movers(format);
+ Mover const & mover = getMover(format);
if (!mover.copy(sourceFile, destFile, latexFile))
Alert::error(_("Couldn't copy file"),
bformat(_("Copying %1$s to %2$s failed."),
formats_ = lyx::formats;
converters_ = theConverters();
converters_.update(formats_);
- movers_ = lyx::movers;
+ movers_ = theMovers();
colors_.clear();
update_screen_font_ = false;
theConverters().update(lyx::formats);
theConverters().buildGraph();
- lyx::movers = movers_;
+ theMovers() = movers_;
vector<string>::const_iterator it = colors_.begin();
vector<string>::const_iterator const end = colors_.end();
// The browser widget
AllCopiersLW->clear();
- for (Movers::iterator it = form_->movers().begin(),
+ for (Movers::const_iterator it = form_->movers().begin(),
end = form_->movers().end();
it != end; ++it) {
std::string const & command = it->second.command();
unsigned long const temp_checksum = support::sum(temp_file);
if (from_checksum != temp_checksum) {
- Mover const & mover = movers(from_format);
+ Mover const & mover = getMover(from_format);
if (!mover.copy(params.filename, temp_file)) {
lyxerr[Debug::EXTERNAL]
<< "external::updateExternal. "
// Nothing to do...
return std::make_pair(IDENTICAL_CONTENTS, file_out);
- Mover const & mover = movers(formats.getFormatFromFile(file_in));
+ Mover const & mover = getMover(formats.getFormatFromFile(file_in));
bool const success = mover.copy(file_in, file_out);
if (!success) {
// FIXME UNICODE
// The system converters copy after reading lyxrc.defaults.
Converters system_converters_;
+
+ ///
+ Movers movers_;
+
+ ///
+ Movers system_movers_;
};
///
system_lyxrc = lyxrc;
system_formats = formats;
pimpl_->system_converters_ = pimpl_->converters_;
- system_movers = movers;
+ pimpl_->system_movers_ = pimpl_->movers_;
system_lcolor = lcolor;
// This one is edited through the preferences dialog.
}
+Movers & theMovers()
+{
+ return LyX::ref().pimpl_->movers_;
+}
+
+
+Mover const & getMover(std::string const & fmt)
+{
+ return LyX::ref().pimpl_->movers_(fmt);
+}
+
+
+void setMover(std::string const & fmt, std::string const & command)
+{
+ LyX::ref().pimpl_->movers_.set(fmt, command);
+}
+
+
+Movers & theSystemMovers()
+{
+ return LyX::ref().pimpl_->system_movers_;
+}
+
+
IconvProcessor & utf8ToUcs4()
{
return LyX::ref().iconvProcessor();
class LyXServerSocket;
class LyXView;
class Messages;
+class Mover;
+class Movers;
class Session;
class kb_keymap;
/// Use the Pimpl idiom to hide the internals.
struct Singletons;
boost::scoped_ptr<Singletons> pimpl_;
+
+ friend Movers & theMovers();
+ friend Mover const & getMover(std::string const & fmt);
+ friend void setMover(std::string const & fmt, std::string const & command);
+ friend Movers & theSystemMovers();
};
} // namespace lyx
if (lexrc.next()) {
command = lexrc.getString();
}
- movers.set(fmt, command);
+ setMover(fmt, command);
break;
}
<< "#\n\n";
// Look for new movers
- Movers::iterator const sysbegin = system_movers.begin();
- Movers::iterator const sysend = system_movers.end();
+ Movers::const_iterator const sysbegin = theSystemMovers().begin();
+ Movers::const_iterator const sysend = theSystemMovers().end();
+ Movers::const_iterator it = theMovers().begin();
+ Movers::const_iterator end = theMovers().end();
- for (Movers::iterator it = movers.begin(), end = movers.end();
- it != end; ++it) {
- Movers::iterator const sysit =
+ for (; it != end; ++it) {
+ Movers::const_iterator const sysit =
std::find_if(sysbegin, sysend, SameMover(*it));
if (sysit == sysend) {
std::string const & fmt = it->first;
#include <fstream>
#include <sstream>
-
-namespace lyx {
-
using std::ios;
using std::string;
-Movers movers;
-Movers system_movers;
-
+namespace lyx {
bool Mover::copy(support::FileName const & from, support::FileName const & to,
unsigned long int mode) const
Mover const & Movers::operator()(string const & fmt) const
{
SpecialsMap::const_iterator const it = specials_.find(fmt);
- return (it == specials_.end()) ? default_ : it->second;
+ if (it == specials_.end())
+ return default_;
+ return it->second;
}
public:
SpecialisedMover() {}
+ virtual ~SpecialisedMover() {}
+
/** @c command should be of the form
* <code>
* python $$s/scripts/fig_copy.py $$i $$o $$l
typedef std::map<std::string, SpecialisedMover> SpecialsMap;
public:
- typedef SpecialsMap::const_iterator iterator;
- iterator begin() const { return specials_.begin(); }
- iterator end() const { return specials_.end(); }
+ typedef SpecialsMap::const_iterator const_iterator;
+ const_iterator begin() const { return specials_.begin(); }
+ const_iterator end() const { return specials_.end(); }
private:
Mover default_;
};
-extern Movers movers;
-extern Movers system_movers;
+extern Movers & theMovers();
+/// @c returns the Mover registered for format @c fmt.
+extern Mover const & getMover(std::string const & fmt);
+/** Register a specialised @c command to be used to copy a file
+ * of format @c fmt.
+ */
+extern void setMover(std::string const & fmt, std::string const & command);
+extern Movers & theSystemMovers();
} // namespace lyx