X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fspl.h;h=f55a9fe1fd89c1405b2ff7887eec914f6d25d34d;hp=5e1bd47b2acdeaf5a6a35d3fe5ec887f73ec2c62;hb=a733da8088152a2487691629753fe8a2addfa5a3;hpb=f598e06928af82fee1d2b25bc4cf25f560478ad4 diff --git a/src/lib/spl.h b/src/lib/spl.h index 5e1bd47b2..f55a9fe1f 100644 --- a/src/lib/spl.h +++ b/src/lib/spl.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -18,23 +18,118 @@ */ + #ifndef DCPOMATIC_SPL_H #define DCPOMATIC_SPL_H -#include -class SPLEntry; +#include "spl_entry.h" +#include +#include +#include + + +class ContentStore; + class SPL { public: - SPL () {} - SPL (boost::filesystem::path file); + SPL () + : _id (dcp::make_uuid()) + , _missing (false) + {} + + SPL (std::string name) + : _id (dcp::make_uuid()) + , _name (name) + , _missing (false) + {} + + + void add (SPLEntry e) { + _spl.push_back (e); + } + + void remove (std::size_t index) { + _spl.erase (_spl.begin() + index); + } + + std::vector const & get () const { + return _spl; + } + + SPLEntry const & operator[] (std::size_t index) const { + return _spl[index]; + } + + void swap(size_t a, size_t b) { + std::iter_swap(_spl.begin() + a, _spl.begin() + b); + } + + void read (boost::filesystem::path path, ContentStore* store); + void write (boost::filesystem::path path) const; + + std::string id () const { + return _id; + } + + std::string name () const { + return _name; + } + + void set_name (std::string name) { + _name = name; + } + + bool missing () const { + return _missing; + } + +private: + std::string _id; + std::string _name; + std::vector _spl; + /** true if any content was missing when read() was last called on this SPL */ + bool _missing; +}; + + +class SignalSPL : public SPL +{ +public: + enum class Change { + NAME, + CONTENT, + }; + + SignalSPL () {} + + SignalSPL (std::string name) + : SPL (name) + {} + + void set_name (std::string name) { + SPL::set_name (name); + Changed(Change::NAME); + } + + void add(SPLEntry e) { + SPL::add(e); + Changed(Change::CONTENT); + } + + void remove(std::size_t index) { + SPL::remove(index); + Changed(Change::CONTENT); + } - void as_xml (boost::filesystem::path file) const; + void swap(size_t a, size_t b) { + SPL::swap(a, b); + Changed(Change::CONTENT); + } - std::string name; - std::list playlist; + boost::signals2::signal Changed; }; #endif