2 * Copyright 2001-2010 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 saml/saml2/metadata/ObservableMetadataProvider.h
20 * A metadata provider that notifies interested parties of changes.
23 #ifndef __saml2_obsmetadataprov_h__
24 #define __saml2_obsmetadataprov_h__
26 #include <saml/saml2/metadata/MetadataProvider.h>
28 namespace xmltooling {
29 class XMLTOOL_API Mutex;
36 #if defined (_MSC_VER)
37 #pragma warning( push )
38 #pragma warning( disable : 4251 )
41 * A metadata provider that notifies interested parties of changes.
43 class SAML_API ObservableMetadataProvider : public virtual MetadataProvider
49 * @param e DOM to supply configuration for provider
51 ObservableMetadataProvider(const xercesc::DOMElement* e=nullptr);
54 * Convenience method for notifying every registered Observer of an event.
56 virtual void emitChangeEvent() const;
59 virtual ~ObservableMetadataProvider();
62 * An observer of metadata provider changes.
64 class SAML_API Observer {
65 MAKE_NONCOPYABLE(Observer);
72 * Called when a provider signals an event has occured.
73 * The provider is already locked.
75 * @param provider the provider being observed
77 virtual void onEvent(const ObservableMetadataProvider& provider) const=0;
81 * Adds a metadata observer.
83 * @param newObserver metadata observer to add
85 virtual void addObserver(const Observer* newObserver) const;
88 * Removes a metadata observer.
90 * @param oldObserver metadata observer to remove
91 * @return the old observer
93 virtual const Observer* removeObserver(const Observer* oldObserver) const;
96 mutable xmltooling::Mutex* m_observerLock;
97 mutable std::vector<const Observer*> m_observers;
100 #if defined (_MSC_VER)
101 #pragma warning( pop )
107 #endif /* __saml2_obsmetadataprov_h__ */