Use shibboleth-sp as package name for compatibility.
[shibboleth/cpp-sp.git] / shibsp / util / PropertySet.h
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */
20
21 /**
22  * @file shibsp/util/PropertySet.h
23  * 
24  * Interface to a generic set of typed properties or a DOM container of additional data.
25  */
26
27 #ifndef __shibsp_propset_h__
28 #define __shibsp_propset_h__
29
30 #include <shibsp/util/SPConstants.h>
31
32 #include <map>
33 #include <string>
34 #include <xercesc/dom/DOM.hpp>
35
36 namespace shibsp {
37
38     /**
39      * Interface to a generic set of typed properties or a DOM container of additional data.
40      */
41     class SHIBSP_API PropertySet
42     {
43         MAKE_NONCOPYABLE(PropertySet);
44     protected:
45         PropertySet();
46     public:
47         virtual ~PropertySet();
48
49         /**
50          * Returns parent of this PropertySet, if any.
51          *
52          * @return the parent object, or nullptr
53          */
54         virtual const PropertySet* getParent() const=0;
55
56         /**
57          * Establishes a "parent" PropertySet to supply inherited settings.
58          *
59          * @param parent    the parent PropertySet to use
60          */
61         virtual void setParent(const PropertySet* parent)=0;
62
63         /**
64          * Returns a boolean-valued property.
65          * 
66          * @param name  property name
67          * @param ns    property namespace, or nullptr
68          * @return a pair consisting of a nullptr indicator and the property value iff the indicator is true
69          */
70         virtual std::pair<bool,bool> getBool(const char* name, const char* ns=nullptr) const=0;
71
72         /**
73          * Returns a string-valued property.
74          * 
75          * @param name  property name
76          * @param ns    property namespace, or nullptr
77          * @return a pair consisting of a nullptr indicator and the property value iff the indicator is true
78          */
79         virtual std::pair<bool,const char*> getString(const char* name, const char* ns=nullptr) const=0;
80
81         /**
82          * Returns a Unicode string-valued property.
83          * 
84          * @param name  property name
85          * @param ns    property namespace, or nullptr
86          * @return a pair consisting of a nullptr indicator and the property value iff the indicator is true
87          */
88         virtual std::pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=nullptr) const=0;
89
90         /**
91          * Returns an unsigned integer-valued property.
92          * 
93          * @param name  property name
94          * @param ns    property namespace, or nullptr
95          * @return a pair consisting of a nullptr indicator and the property value iff the indicator is true
96          */
97         virtual std::pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=nullptr) const=0;
98
99         /**
100          * Returns an integer-valued property.
101          * 
102          * @param name  property name
103          * @param ns    property namespace, or nullptr
104          * @return a pair consisting of a nullptr indicator and the property value iff the indicator is true
105          */
106         virtual std::pair<bool,int> getInt(const char* name, const char* ns=nullptr) const=0;
107
108         /**
109          * Returns a map of all known properties in string form.
110          *
111          * @param properties    map to populate
112          */
113         virtual void getAll(std::map<std::string,const char*>& properties) const=0;
114
115         /**
116          * Returns a nested property set.
117          * 
118          * @param name  nested property set name
119          * @param ns    nested property set namespace, or nullptr
120          * @return the nested property set, or nullptr
121          */        
122         virtual const PropertySet* getPropertySet(const char* name, const char* ns=shibspconstants::ASCII_SHIB2SPCONFIG_NS) const=0;
123         
124         /**
125          * Returns a DOM element representing the property container, if any.
126          * 
127          * @return a DOM element, or nullptr
128          */
129         virtual const xercesc::DOMElement* getElement() const=0;
130     };
131 };
132
133 #endif /* __shibsp_propset_h__ */