+
+void
+Config::read_cinemas (cxml::Document const & f)
+{
+ _cinemas.clear ();
+ list<cxml::NodePtr> cin = f.node_children ("Cinema");
+ for (list<cxml::NodePtr>::iterator i = cin.begin(); i != cin.end(); ++i) {
+ /* Slightly grotty two-part construction of Cinema here so that we can use
+ shared_from_this.
+ */
+ shared_ptr<Cinema> cinema (new Cinema (*i));
+ cinema->read_screens (*i);
+ _cinemas.push_back (cinema);
+ }
+}
+
+void
+Config::set_cinemas_file (boost::filesystem::path file)
+{
+ _cinemas_file = file;
+
+ if (boost::filesystem::exists (_cinemas_file)) {
+ /* Existing file; read it in */
+ cxml::Document f ("Cinemas");
+ f.read_file (_cinemas_file);
+ read_cinemas (f);
+ }
+
+ changed (OTHER);
+}
+
+void
+Config::save_template (shared_ptr<const Film> film, string name) const
+{
+ film->write_template (template_path (name));
+}
+
+list<string>
+Config::templates () const
+{
+ list<string> n;
+ for (boost::filesystem::directory_iterator i (path("templates")); i != boost::filesystem::directory_iterator(); ++i) {
+ n.push_back (i->path().filename().string());
+ }
+ return n;
+}
+
+bool
+Config::existing_template (string name) const
+{
+ return boost::filesystem::exists (template_path (name));
+}
+
+boost::filesystem::path
+Config::template_path (string name) const
+{
+ return path("templates") / tidy_for_filename (name);
+}
+
+void
+Config::rename_template (string old_name, string new_name) const
+{
+ boost::filesystem::rename (template_path (old_name), template_path (new_name));
+}
+
+void
+Config::delete_template (string name) const
+{
+ boost::filesystem::remove (template_path (name));
+}