Refactored simple content and child-handling into mixin classes.
[shibboleth/cpp-xmltooling.git] / xmltooling / AbstractDOMCachingXMLObject.h
index edfc1bf..fc740f3 100644 (file)
 /**\r
  * @file AbstractDOMCachingXMLObject.h\r
  * \r
- * Extension of AbstractXMLObject that implements a DOMCachingXMLObject. \r
+ * AbstractXMLObject mixin that implements DOM caching\r
  */\r
 \r
 #if !defined(__xmltooling_abstractdomxmlobj_h__)\r
 #define __xmltooling_abstractdomxmlobj_h__\r
 \r
 #include <xmltooling/AbstractXMLObject.h>\r
-#include <xmltooling/DOMCachingXMLObject.h>\r
 \r
 #if defined (_MSC_VER)\r
     #pragma warning( push )\r
 namespace xmltooling {\r
 \r
     /**\r
-     * Extension of AbstractXMLObject that implements a DOMCachingXMLObject.\r
+     * AbstractXMLObject mixin that implements DOM caching.\r
+     * Inherit from this class to implement standard DOM caching behavior.\r
      */\r
-    class XMLTOOL_API AbstractDOMCachingXMLObject : public virtual AbstractXMLObject, public virtual DOMCachingXMLObject\r
+    class XMLTOOL_API AbstractDOMCachingXMLObject : public virtual AbstractXMLObject\r
     {\r
     public:\r
         virtual ~AbstractDOMCachingXMLObject();\r
         \r
-        /**\r
-         * @see DOMCachingXMLObject::getDOM()\r
-         */\r
         DOMElement* getDOM() const {\r
             return m_dom;\r
         }\r
         \r
-        /**\r
-         * @see DOMCachingXMLObject::setDOM()\r
-         */\r
         void setDOM(DOMElement* dom, bool bindDocument=false) const;\r
         \r
-        /**\r
-         * @see DOMCachingXMLObject::setDocument()\r
-         */\r
         void setDocument(DOMDocument* doc) const {\r
             if (m_document)\r
                 m_document->release();\r
             m_document=doc;\r
         }\r
     \r
-        /**\r
-         * @see DOMCachingXMLObject::releaseDOM()\r
-         */\r
         virtual void releaseDOM() const;\r
         \r
-        /**\r
-         * @see DOMCachingXMLObject::releaseParentDOM()\r
-         */\r
         virtual void releaseParentDOM(bool propagateRelease=true) const;\r
         \r
-        /**\r
-         * @see DOMCachingXMLObject::releaseChildrenDOM()\r
-         */\r
         virtual void releaseChildrenDOM(bool propagateRelease=true) const;\r
     \r
-        /**\r
-         * A convenience method that is equal to calling releaseDOM() then releaseParentDOM(true).\r
-         */\r
-        void releaseThisandParentDOM() const {\r
-            if (m_dom) {\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 (m_dom) {\r
-                releaseChildrenDOM(true);\r
-                releaseDOM();\r
-            }\r
-        }\r
-    \r
-        /**\r
-         * @see XMLObject::clone()\r
-         */\r
         XMLObject* clone() const;\r
 \r
      protected:\r
         AbstractDOMCachingXMLObject() : m_dom(NULL), m_document(NULL) {}\r
 \r
+        /** Copy constructor. */\r
+        AbstractDOMCachingXMLObject(const AbstractDOMCachingXMLObject& src)\r
+            : AbstractXMLObject(src), m_dom(NULL), m_document(NULL) {}\r
+\r
         /**\r
          * If a DOM representation exists, this clones it into a new document.\r
          * \r
@@ -113,43 +76,6 @@ namespace xmltooling {
          */\r
         DOMElement* cloneDOM(DOMDocument* doc=NULL) const;\r
 \r
-        /**\r
-         * A helper function for derived classes.\r
-         * This 'normalizes' newString, and then if it is different from oldString,\r
-         * it invalidates the DOM, frees the old string, and return the new.\r
-         * If not different, it frees the new string and just returns the old value.\r
-         * \r
-         * @param oldValue - the current value\r
-         * @param newValue - the new value\r
-         * \r
-         * @return the value that should be assigned\r
-         */\r
-        XMLCh* prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue) {\r
-            XMLCh* newString = XMLString::replicate(newValue);\r
-            XMLString::trim(newString);\r
-            if (!XMLString::equals(oldValue,newValue)) {\r
-                releaseThisandParentDOM();\r
-                XMLString::release(&oldValue);\r
-                return newString;\r
-            }\r
-            XMLString::release(&newString);\r
-            return oldValue;            \r
-        }\r
-\r
-        /**\r
-         * A helper function for derived classes, for assignment of (singleton) XML objects.\r
-         * \r
-         * It is indifferent to whether either the old or the new version of the value is null. \r
-         * This method will do a safe compare of the objects and will also invalidate the DOM if appropriate\r
-         * \r
-         * @param oldValue - current value\r
-         * @param newValue - proposed new value\r
-         * @return the value to assign \r
-         * \r
-         * @throws XMLObjectException if the new child already has a parent.\r
-         */\r
-        XMLObject* prepareForAssignment(XMLObject* oldValue, XMLObject* newValue);\r
-\r
     private:\r
         mutable DOMElement* m_dom;\r
         mutable DOMDocument* m_document;\r