Moved DOM methods up the tree, add copy c'tors, KeyInfo sample
[shibboleth/cpp-xmltooling.git] / xmltooling / XMLObject.h
index 1624b35..09e72c9 100644 (file)
@@ -52,10 +52,19 @@ namespace xmltooling {
     {\r
         MAKE_NONCOPYABLE(MarshallingContext);\r
     public:\r
+        /**\r
+         * Default constructor.\r
+         */\r
         MarshallingContext() {}\r
         ~MarshallingContext() {}\r
 \r
 #ifndef XMLTOOLING_NO_XMLSEC\r
+        /**\r
+         * Builds a marshalling context with an initial signature/context pair.\r
+         * \r
+         * @param sig   a signature object\r
+         * @param ctx   the signing context to associate with the signature \r
+         */\r
         MarshallingContext(Signature* sig, const SigningContext* ctx) {\r
             m_signingContexts.push_back(std::make_pair(sig,ctx));\r
         }\r
@@ -70,7 +79,6 @@ namespace xmltooling {
      */\r
     class XMLTOOL_API XMLObject\r
     {\r
-        MAKE_NONCOPYABLE(XMLObject);\r
     public:\r
         virtual ~XMLObject() {}\r
         \r
@@ -172,6 +180,68 @@ namespace xmltooling {
         virtual const std::list<XMLObject*>& getOrderedChildren() const=0;\r
 \r
         /**\r
+         * Gets the DOM representation of this XMLObject, if one exists.\r
+         * \r
+         * @return the DOM representation of this XMLObject\r
+         */\r
+        virtual DOMElement* getDOM() const=0;\r
+        \r
+        /**\r
+         * Sets the DOM representation of this XMLObject.\r
+         * \r
+         * @param dom       DOM representation of this XMLObject\r
+         * @param bindDocument  true if the object should take ownership of the associated Document\r
+         */\r
+        virtual void setDOM(DOMElement* dom, bool bindDocument=false) const=0;\r
+    \r
+        /**\r
+         * Assigns ownership of a DOM document to the XMLObject.\r
+         * This binds the lifetime of the document to the lifetime of the object.\r
+         * \r
+         * @param doc DOM document bound to this object \r
+         */\r
+        virtual void setDocument(DOMDocument* doc) const=0;\r
+\r
+        /**\r
+         * Releases the DOM representation of this XMLObject, if there is one.\r
+         */\r
+        virtual void releaseDOM() const=0;\r
+        \r
+        /**\r
+         * Releases the DOM representation of this XMLObject's parent.\r
+         * \r
+         * @param propagateRelease true if all ancestors of this element should release their DOM\r
+         */\r
+        virtual void releaseParentDOM(bool propagateRelease=true) const=0;\r
+        \r
+        /**\r
+         * Releases the DOM representation of this XMLObject's children.\r
+         * \r
+         * @param propagateRelease true if all descendants of this element should release their DOM\r
+         */\r
+        virtual void releaseChildrenDOM(bool propagateRelease=true) const=0;\r
+\r
+        /**\r
+         * A convenience method that is equal to calling releaseDOM() then releaseParentDOM(true).\r
+         */\r
+        void releaseThisandParentDOM() const {\r
+            if (getDOM()) {\r
+                releaseDOM();\r
+                releaseParentDOM(true);\r
+            }\r
+        }\r
+    \r
+        /**\r
+         * A convenience method that is equal to calling releaseChildrenDOM(true) then releaseDOM().\r
+         */\r
+        void releaseThisAndChildrenDOM() const {\r
+            if (getDOM()) {\r
+                releaseChildrenDOM(true);\r
+                releaseDOM();\r
+            }\r
+        }\r
+\r
+        /**\r
          * Marshalls the XMLObject, and its children, into a DOM element.\r
          * If a document is supplied, then it will be used to create the resulting elements.\r
          * If the document does not have a Document Element set, then the resulting\r
@@ -219,6 +289,8 @@ namespace xmltooling {
 \r
     protected:\r
         XMLObject() {}\r
+    private:\r
+        XMLObject& operator=(const XMLObject& src);\r
     };\r
 \r
 #if defined (_MSC_VER)\r