Use get_pixel_size rather than get_size which is slightly nicer as we then don't...
[dcpomatic.git] / src / lib / cinema.cc
index 43a4322396144417041ec801c380895f170079bf..ebd7160098df67d6657016427e09ca6037b47451 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
     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
 
 */
 
-#include <libxml++/libxml++.h>
-#include <libcxml/cxml.h>
 #include "cinema.h"
+#include "screen.h"
+#include <libcxml/cxml.h>
+#include <libxml++/libxml++.h>
+#include <boost/foreach.hpp>
 
 using std::list;
+using std::string;
 using boost::shared_ptr;
 
-Cinema::Cinema (shared_ptr<const cxml::Node> node)
+Cinema::Cinema (cxml::ConstNodePtr node)
        : name (node->string_child ("Name"))
-       , email (node->string_child ("Email"))
 {
-
+       BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Email")) {
+               emails.push_back (i->content ());
+       }
 }
 
 /* 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 (shared_ptr<const cxml::Node> node)
+Cinema::read_screens (cxml::ConstNodePtr node)
 {
        list<cxml::NodePtr> s = node->node_children ("Screen");
        for (list<cxml::NodePtr>::iterator i = s.begin(); i != s.end(); ++i) {
@@ -47,10 +51,13 @@ void
 Cinema::as_xml (xmlpp::Element* parent) const
 {
        parent->add_child("Name")->add_child_text (name);
-       parent->add_child("Email")->add_child_text (email);
 
-       for (list<shared_ptr<Screen> >::const_iterator i = _screens.begin(); i != _screens.end(); ++i) {
-               (*i)->as_xml (parent->add_child ("Screen"));
+       BOOST_FOREACH (string i, emails) {
+               parent->add_child("Email")->add_child_text (i);
+       }
+
+       BOOST_FOREACH (shared_ptr<Screen> i, _screens) {
+               i->as_xml (parent->add_child ("Screen"));
        }
 }
 
@@ -66,18 +73,3 @@ Cinema::remove_screen (shared_ptr<Screen> s)
 {
        _screens.remove (s);
 }
-
-Screen::Screen (shared_ptr<const cxml::Node> node)
-{
-       name = node->string_child ("Name");
-       certificate = shared_ptr<dcp::Certificate> (new dcp::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));
-}
-
-