Began to implement collection handling.
[shibboleth/cpp-xmltooling.git] / xmltooling / AbstractXMLObject.h
index 0eeae30..c3aa289 100644 (file)
@@ -23,6 +23,7 @@
 #if !defined(__xmltooling_abstractxmlobj_h__)\r
 #define __xmltooling_abstractxmlobj_h__\r
 \r
+#include <algorithm>\r
 #include <xmltooling/XMLObject.h>\r
 \r
 #if defined (_MSC_VER)\r
@@ -40,6 +41,7 @@ namespace xmltooling {
     public:\r
         virtual ~AbstractXMLObject() {\r
             delete m_typeQname;\r
+            std::for_each(m_children.begin(), m_children.end(), cleanup<XMLObject>());\r
         }\r
 \r
         /**\r
@@ -118,7 +120,21 @@ namespace xmltooling {
         void setParent(XMLObject* parent) {\r
             m_parent = parent;\r
         }\r
-    \r
+\r
+        /**\r
+         * @see XMLObject::hasChildren()\r
+         */\r
+        bool hasChildren() const {\r
+            return !m_children.empty();\r
+        }\r
+\r
+        /**\r
+         * @see XMLObject::getOrderedChildren()\r
+         */\r
+        const std::list<XMLObject*>& getOrderedChildren() const {\r
+            return m_children;\r
+        }\r
+\r
      protected:\r
         /**\r
          * Constructor\r
@@ -130,6 +146,12 @@ namespace xmltooling {
             : m_elementQname(namespaceURI,elementLocalName, namespacePrefix), m_typeQname(NULL), m_parent(NULL) {\r
             addNamespace(Namespace(namespaceURI, namespacePrefix));\r
         }\r
+\r
+        /**\r
+         * Underlying list of child objects.\r
+         * Manages the lifetime of the children.\r
+         */\r
+        std::list<XMLObject*> m_children;\r
         \r
     private:\r
         XMLObject* m_parent;\r