Slight hack to reduce the chance of config files looking different
[dcpomatic.git] / src / lib / dkdm_wrapper.h
index b877722d91732eb103a42bee80e86b81ca11e44b..261cdc76751e112b511b49e8b390d8cb21aaa858 100644 (file)
 
 #include <dcp/encrypted_kdm.h>
 #include <libcxml/cxml.h>
+#include <memory>
+
 
 namespace xmlpp {
        class Element;
 }
 
-class DKDMBase
+class DKDMGroup;
+
+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);
+
+       std::shared_ptr<DKDMGroup> parent () const {
+               return _parent;
+       }
+
+       void set_parent (std::shared_ptr<DKDMGroup> parent) {
+               _parent = parent;
+       }
+
+private:
+       std::shared_ptr<DKDMGroup> _parent;
 };
 
 class DKDM : public DKDMBase
 {
 public:
-       DKDM (dcp::EncryptedKDM k)
+       explicit DKDM (dcp::EncryptedKDM k)
                : _dkdm (k)
        {}
 
@@ -55,7 +71,7 @@ private:
 class DKDMGroup : public DKDMBase
 {
 public:
-       DKDMGroup (std::string name)
+       explicit DKDMGroup (std::string name)
                : _name (name)
        {}
 
@@ -65,14 +81,14 @@ public:
 
        void as_xml (xmlpp::Element *) const;
 
-       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);
-        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);
 
 private:
        std::string _name;
-       std::list<boost::shared_ptr<DKDMBase> > _children;
+       std::list<std::shared_ptr<DKDMBase> > _children;
 };