X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fspl.h;h=f55a9fe1fd89c1405b2ff7887eec914f6d25d34d;hp=b19ef7e7a1c9f9d7e267a2aab9a9e1ad18a87b93;hb=a733da8088152a2487691629753fe8a2addfa5a3;hpb=ed227b4fdba9b4fc7f06f6db4830219f14bad358 diff --git a/src/lib/spl.h b/src/lib/spl.h index b19ef7e7a..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,14 +18,20 @@ */ + #ifndef DCPOMATIC_SPL_H #define DCPOMATIC_SPL_H + #include "spl_entry.h" #include +#include +#include + class ContentStore; + class SPL { public: @@ -34,6 +40,13 @@ public: , _missing (false) {} + SPL (std::string name) + : _id (dcp::make_uuid()) + , _name (name) + , _missing (false) + {} + + void add (SPLEntry e) { _spl.push_back (e); } @@ -46,12 +59,12 @@ public: return _spl; } - SPLEntry & operator[] (std::size_t index) { + SPLEntry const & operator[] (std::size_t index) const { return _spl[index]; } - 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); @@ -65,6 +78,10 @@ public: return _name; } + void set_name (std::string name) { + _name = name; + } + bool missing () const { return _missing; } @@ -77,4 +94,42 @@ private: 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 swap(size_t a, size_t b) { + SPL::swap(a, b); + Changed(Change::CONTENT); + } + + boost::signals2::signal Changed; +}; + #endif