Don't add DKDMs twice (#2545).
[dcpomatic.git] / src / lib / dkdm_wrapper.h
index d828ffac2536a4298563764ae58a4c390321aa03..d15f017c513320710bad7081b26620a4566d535b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 */
 
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-#include "encrypted_ecinema_kdm.h"
-#endif
+
 #include <dcp/encrypted_kdm.h>
 #include <libcxml/cxml.h>
-#include <boost/enable_shared_from_this.hpp>
+#include <memory>
+
 
 namespace xmlpp {
        class Element;
 }
 
+
 class DKDMGroup;
 
-class DKDMBase : public boost::enable_shared_from_this<DKDMBase>
+
+class DKDMBase : public std::enable_shared_from_this<DKDMBase>
 {
 public:
        virtual ~DKDMBase () {}
        virtual std::string name () const = 0;
        virtual void as_xml (xmlpp::Element *) const = 0;
 
-       static boost::shared_ptr<DKDMBase> read (cxml::ConstNodePtr node);
+       static std::shared_ptr<DKDMBase> read (cxml::ConstNodePtr node);
 
-       boost::shared_ptr<DKDMGroup> parent () const {
+       std::shared_ptr<DKDMGroup> parent () const {
                return _parent;
        }
 
-       void set_parent (boost::shared_ptr<DKDMGroup> parent) {
+       void set_parent (std::shared_ptr<DKDMGroup> parent) {
                _parent = parent;
        }
 
 private:
-       boost::shared_ptr<DKDMGroup> _parent;
+       std::shared_ptr<DKDMGroup> _parent;
 };
 
+
 class DKDM : public DKDMBase
 {
 public:
@@ -59,8 +61,8 @@ public:
                : _dkdm (k)
        {}
 
-       std::string name () const;
-       void as_xml (xmlpp::Element *) const;
+       std::string name () const override;
+       void as_xml (xmlpp::Element *) const override;
 
        dcp::EncryptedKDM dkdm () const {
                return _dkdm;
@@ -70,25 +72,6 @@ private:
        dcp::EncryptedKDM _dkdm;
 };
 
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-class ECinemaDKDM : public DKDMBase
-{
-public:
-       explicit ECinemaDKDM (EncryptedECinemaKDM k)
-               : _dkdm (k)
-       {}
-
-       std::string name () const;
-       void as_xml (xmlpp::Element *) const;
-
-       EncryptedECinemaKDM dkdm () const {
-               return _dkdm;
-       }
-
-private:
-       EncryptedECinemaKDM _dkdm;
-};
-#endif
 
 class DKDMGroup : public DKDMBase
 {
@@ -97,20 +80,22 @@ public:
                : _name (name)
        {}
 
-       std::string name () const {
+       std::string name () const override {
                return _name;
        }
 
-       void as_xml (xmlpp::Element *) const;
+       void as_xml (xmlpp::Element *) const override;
 
-       std::list<boost::shared_ptr<DKDMBase> > children () const {
+       std::list<std::shared_ptr<DKDMBase>> children () const {
                return _children;
        }
 
-       void add (boost::shared_ptr<DKDMBase> child, boost::shared_ptr<DKDM> previous = boost::shared_ptr<DKDM> ());
-        void remove (boost::shared_ptr<DKDMBase> child);
+       void add (std::shared_ptr<DKDMBase> child, std::shared_ptr<DKDM> previous = std::shared_ptr<DKDM>());
+        void remove (std::shared_ptr<DKDMBase> child);
+
+       bool contains(std::string dkdm_id) const;
 
 private:
        std::string _name;
-       std::list<boost::shared_ptr<DKDMBase> > _children;
+       std::list<std::shared_ptr<DKDMBase>> _children;
 };