/* Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with DCP-o-matic. If not, see . */ #include #include #include namespace xmlpp { class Element; } class DKDMGroup; class DKDMBase : public std::enable_shared_from_this { public: virtual ~DKDMBase () {} virtual std::string name () const = 0; virtual void as_xml (xmlpp::Element *) const = 0; static std::shared_ptr read (cxml::ConstNodePtr node); std::shared_ptr parent () const { return _parent; } void set_parent (std::shared_ptr parent) { _parent = parent; } private: std::shared_ptr _parent; }; class DKDM : public DKDMBase { public: explicit DKDM (dcp::EncryptedKDM k) : _dkdm (k) {} std::string name () const override; void as_xml (xmlpp::Element *) const override; dcp::EncryptedKDM dkdm () const { return _dkdm; } private: dcp::EncryptedKDM _dkdm; }; class DKDMGroup : public DKDMBase { public: explicit DKDMGroup (std::string name) : _name (name) {} std::string name () const override { return _name; } void as_xml (xmlpp::Element *) const override; std::list> children () const { return _children; } void add (std::shared_ptr child, std::shared_ptr previous = std::shared_ptr()); void remove (std::shared_ptr child); private: std::string _name; std::list> _children; };