2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file xmltooling/AbstractDOMCachingXMLObject.h
20 * AbstractXMLObject mixin that implements DOM caching
23 #ifndef __xmltooling_abstractdomxmlobj_h__
24 #define __xmltooling_abstractdomxmlobj_h__
26 #include <xmltooling/AbstractXMLObject.h>
28 #if defined (_MSC_VER)
29 #pragma warning( push )
30 #pragma warning( disable : 4250 4251 )
33 namespace xmltooling {
36 * AbstractXMLObject mixin that implements DOM caching.
37 * Inherit from this class to implement standard DOM caching behavior.
39 class XMLTOOL_API AbstractDOMCachingXMLObject : public virtual AbstractXMLObject
42 virtual ~AbstractDOMCachingXMLObject();
44 xercesc::DOMElement* getDOM() const {
48 void setDOM(xercesc::DOMElement* dom, bool bindDocument=false) const;
50 void setDocument(xercesc::DOMDocument* doc) const {
52 m_document->release();
56 virtual void releaseDOM() const;
58 virtual void releaseParentDOM(bool propagateRelease=true) const;
60 virtual void releaseChildrenDOM(bool propagateRelease=true) const;
62 XMLObject* clone() const;
67 AbstractDOMCachingXMLObject() : m_dom(NULL), m_document(NULL) {}
69 /** Copy constructor. */
70 AbstractDOMCachingXMLObject(const AbstractDOMCachingXMLObject& src)
71 : AbstractXMLObject(src), m_dom(NULL), m_document(NULL) {}
74 * If a DOM representation exists, this clones it into a new document.
76 * @param doc the document to clone into, or NULL, in which case a new document is created
77 * @return the cloned DOM
79 xercesc::DOMElement* cloneDOM(xercesc::DOMDocument* doc=NULL) const;
82 mutable xercesc::DOMElement* m_dom;
83 mutable xercesc::DOMDocument* m_document;
88 #if defined (_MSC_VER)
89 #pragma warning( pop )
92 #endif /* __xmltooling_abstractdomxmlobj_h__ */