X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcinema.cc;h=11bc888da32127ef4a6e2cd917026496aaa206d9;hb=3d03159691a2a9a545f5d58831d245f01480d612;hp=ecd083f0aa1d0407cfd3c3adc5621b0a261c3d84;hpb=1ba7bca7f2950faa441ec83920d35b65016f3fa6;p=dcpomatic.git diff --git a/src/lib/cinema.cc b/src/lib/cinema.cc index ecd083f0a..11bc888da 100644 --- a/src/lib/cinema.cc +++ b/src/lib/cinema.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,21 +17,30 @@ */ -#include -#include #include "cinema.h" +#include "screen.h" +#include +#include using std::list; using boost::shared_ptr; -Cinema::Cinema (shared_ptr node) +Cinema::Cinema (cxml::ConstNodePtr node) + : name (node->string_child ("Name")) + , email (node->string_child ("Email")) { - name = node->string_child ("Name"); - email = node->string_child ("Email"); - list > s = node->node_children ("Screen"); - for (list >::iterator i = s.begin(); i != s.end(); ++i) { - _screens.push_back (shared_ptr (new Screen (*i))); +} + +/* This is necessary so that we can use shared_from_this in add_screen (which cannot be done from + a constructor) +*/ +void +Cinema::read_screens (cxml::ConstNodePtr node) +{ + list s = node->node_children ("Screen"); + for (list::iterator i = s.begin(); i != s.end(); ++i) { + add_screen (shared_ptr (new Screen (*i))); } } @@ -58,18 +67,3 @@ Cinema::remove_screen (shared_ptr s) { _screens.remove (s); } - -Screen::Screen (shared_ptr node) -{ - name = node->string_child ("Name"); - certificate = shared_ptr (new libdcp::Certificate (node->string_child ("Certificate"))); -} - -void -Screen::as_xml (xmlpp::Element* parent) const -{ - parent->add_child("Name")->add_child_text (name); - parent->add_child("Certificate")->add_child_text (certificate->certificate (true)); -} - -