0943be547330dcc804d600518a9e76acc710d822
[shibboleth/cpp-xmltooling.git] / xmltooling / validation / ValidatingXMLObject.h
1 /*\r
2  *  Copyright 2001-2006 Internet2\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 /**\r
18  * @file ValidatingXMLObject.h\r
19  * \r
20  * An XMLObject that can evaluate per-object validation rules.  \r
21  */\r
22 \r
23 #if !defined(__xmltooling_valxmlobj_h__)\r
24 #define __xmltooling_valxmlobj_h__\r
25 \r
26 #include <vector>\r
27 #include <xmltooling/XMLObject.h>\r
28 #include <xmltooling/validation/Validator.h>\r
29 \r
30 #if defined (_MSC_VER)\r
31     #pragma warning( push )\r
32     #pragma warning( disable : 4250 4251 )\r
33 #endif\r
34 \r
35 namespace xmltooling {\r
36 \r
37     /**\r
38      * A functional interface for XMLObjects that offer the ability\r
39      * to evaluate validation rules defined per-object.\r
40      */\r
41     class XMLTOOL_API ValidatingXMLObject : public virtual XMLObject\r
42     {\r
43     protected:\r
44         ValidatingXMLObject() {}\r
45     \r
46     public:\r
47         virtual ~ValidatingXMLObject() {}\r
48         \r
49         /**\r
50          * Registers a validator for this XMLObject.\r
51          * \r
52          * @param validator the validator\r
53          */\r
54         virtual void registerValidator(Validator* validator)=0;\r
55         \r
56         /**\r
57          * Deregisters a validator for this XMLObject.\r
58          * \r
59          * @param validator the validator\r
60          */\r
61         virtual void deregisterValidator(Validator* validator)=0;\r
62 \r
63         /**\r
64          * Deregisters all validators for this XMLObject.\r
65          */\r
66         virtual void deregisterAll()=0;\r
67         \r
68         /**\r
69          * Validates this XMLObject against all registered validators.\r
70          * \r
71          * @param validateDescendants true if all the descendants of this object should \r
72          * be validated as well, false if not\r
73          * \r
74          * @throws ValidationException thrown if the object is not valid\r
75          */\r
76         virtual void validate(bool validateDescendants) const=0;\r
77     };\r
78     \r
79 };\r
80 \r
81 #if defined (_MSC_VER)\r
82     #pragma warning( pop )\r
83 #endif\r
84 \r
85 #endif /* __xmltooling_valxmlobj_h__ */\r