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.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * @file saml/saml2/metadata/ObservableMetadataProvider.h
24 * A metadata provider that notifies interested parties of changes.
27 #ifndef __saml2_obsmetadataprov_h__
28 #define __saml2_obsmetadataprov_h__
30 #include <saml/saml2/metadata/MetadataProvider.h>
32 namespace xmltooling {
33 class XMLTOOL_API Mutex;
40 #if defined (_MSC_VER)
41 #pragma warning( push )
42 #pragma warning( disable : 4251 )
45 * A metadata provider that notifies interested parties of changes.
47 class SAML_API ObservableMetadataProvider : public virtual MetadataProvider
53 * @param e DOM to supply configuration for provider
55 ObservableMetadataProvider(const xercesc::DOMElement* e=nullptr);
58 * Convenience method for notifying every registered Observer of an event.
60 virtual void emitChangeEvent() const;
63 virtual ~ObservableMetadataProvider();
66 * An observer of metadata provider changes.
68 class SAML_API Observer {
69 MAKE_NONCOPYABLE(Observer);
76 * Called when a provider signals an event has occured.
77 * The provider is already locked.
79 * @param provider the provider being observed
81 virtual void onEvent(const ObservableMetadataProvider& provider) const=0;
85 * Adds a metadata observer.
87 * @param newObserver metadata observer to add
89 virtual void addObserver(const Observer* newObserver) const;
92 * Removes a metadata observer.
94 * @param oldObserver metadata observer to remove
95 * @return the old observer
97 virtual const Observer* removeObserver(const Observer* oldObserver) const;
100 std::auto_ptr<xmltooling::Mutex> m_observerLock;
101 mutable std::vector<const Observer*> m_observers;
104 #if defined (_MSC_VER)
105 #pragma warning( pop )
111 #endif /* __saml2_obsmetadataprov_h__ */