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 * Convenience method for notifying every registered Observer of an event.
65 virtual void emitChangeEvent(const EntityDescriptor& entity) const;
68 virtual ~ObservableMetadataProvider();
71 * An observer of metadata provider changes.
73 class SAML_API Observer {
74 MAKE_NONCOPYABLE(Observer);
81 * Called when a provider signals an event has occured.
82 * The provider is already locked.
84 * @param provider the provider being observed
86 virtual void onEvent(const ObservableMetadataProvider& provider) const=0;
89 * Called when a provider signals an event has occured.
90 * The provider is already locked.
92 * @param provider the provider being observed
93 * @param entity the entity that underwent modification
95 virtual void onEvent(const ObservableMetadataProvider& provider, const EntityDescriptor& entity) const;
99 * Adds a metadata observer.
101 * @param newObserver metadata observer to add
103 virtual void addObserver(const Observer* newObserver) const;
106 * Removes a metadata observer.
108 * @param oldObserver metadata observer to remove
109 * @return the old observer
111 virtual const Observer* removeObserver(const Observer* oldObserver) const;
114 mutable std::auto_ptr<xmltooling::Mutex> m_observerLock;
115 mutable std::vector<const Observer*> m_observers;
118 #if defined (_MSC_VER)
119 #pragma warning( pop )
125 #endif /* __saml2_obsmetadataprov_h__ */