2 * Copyright 2001-2006 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/util/ReloadableXMLFile.h
20 * Base class for file-based XML configuration.
23 #ifndef __xmltooling_reloadable_h__
24 #define __xmltooling_reloadable_h__
26 #include <xmltooling/Lockable.h>
27 #include <xmltooling/util/Threads.h>
32 namespace xmltooling {
35 * Base class for file-based XML configuration.
37 class XMLTOOL_API ReloadableXMLFile : protected virtual Lockable
39 MAKE_NONCOPYABLE(ReloadableXMLFile);
43 * Constructor taking a DOM element supporting the following content:
46 * <dt>file | filename | path | pathname</dt>
47 * <dd>identifies a local file</dd>
49 * <dd>identifies a remote resource</dd>
51 * <dd>use a validating parser</dd>
52 * <dt>reloadChanges</dt>
53 * <dd>enables monitoring of resources for changes</dd>
56 * @param e DOM to supply configuration
58 ReloadableXMLFile(const DOMElement* e);
60 virtual ~ReloadableXMLFile() {
73 * Loads configuration material.
75 * <p>This method is called to load configuration material
76 * initially and any time a change is detected. The base version
77 * performs basic parsing duties and returns the result.
79 * @return a pair consisting of a flag indicating whether to take ownership of
80 * the document, and the root element of the tree to load
82 virtual std::pair<bool,DOMElement*> load();
85 * Overrideable method to determine whether a remote resource remains valid.
87 * @return true iff the resource remains valid and should not be reloaded
89 virtual bool isValid() const {
94 const DOMElement* m_root;
95 bool m_local, m_validate;
103 #endif /* __xmltooling_reloadable_h__ */