XML metadata and some other bits.
[dcpomatic.git] / src / lib / content.cc
1 #include <boost/thread/mutex.hpp>
2 #include <libxml++/libxml++.h>
3 #include <libcxml/cxml.h>
4 #include "content.h"
5 #include "util.h"
6
7 using std::string;
8 using boost::shared_ptr;
9
10 Content::Content (boost::filesystem::path f)
11         : _file (f)
12 {
13
14 }
15
16 Content::Content (shared_ptr<const cxml::Node> node)
17 {
18         _file = node->string_child ("File");
19         _digest = node->string_child ("Digest");
20 }
21
22 void
23 Content::as_xml (xmlpp::Node* node) const
24 {
25         boost::mutex::scoped_lock lm (_mutex);
26         node->add_child("File")->add_child_text (_file.string());
27         node->add_child("Digest")->add_child_text (_digest);
28 }
29
30 void
31 Content::examine (shared_ptr<Film>, shared_ptr<Job>, bool)
32 {
33         string const d = md5_digest (_file);
34         boost::mutex::scoped_lock lm (_mutex);
35         _digest = d;
36 }