-/*
- * Copyright 2009 Internet2
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
*/
/**
#include "internal.h"
#include "saml2/metadata/ObservableMetadataProvider.h"
+#include <boost/bind.hpp>
#include <xmltooling/util/Threads.h>
using namespace opensaml::saml2md;
using namespace xmltooling;
+using namespace boost;
using namespace std;
ObservableMetadataProvider::ObservableMetadataProvider(const xercesc::DOMElement* e)
ObservableMetadataProvider::~ObservableMetadataProvider()
{
- delete m_observerLock;
}
void ObservableMetadataProvider::emitChangeEvent() const
{
Lock lock(m_observerLock);
- for (vector<const Observer*>::const_iterator i=m_observers.begin(); i!=m_observers.end(); i++) {
- (*i)->onEvent(*this);
- }
+ for_each(m_observers.begin(), m_observers.end(), boost::bind(&Observer::onEvent, _1, boost::cref(*this)));
+}
+
+void ObservableMetadataProvider::emitChangeEvent(const EntityDescriptor& entity) const
+{
+ Lock lock(m_observerLock);
+ for_each(m_observers.begin(), m_observers.end(), boost::bind(&Observer::onEvent, _1, boost::cref(*this), boost::cref(entity)));
}
void ObservableMetadataProvider::addObserver(const Observer* newObserver) const
const ObservableMetadataProvider::Observer* ObservableMetadataProvider::removeObserver(const Observer* oldObserver) const
{
Lock lock(m_observerLock);
- for (vector<const Observer*>::iterator i=m_observers.begin(); i!=m_observers.end(); i++) {
- if (oldObserver==(*i)) {
- m_observers.erase(i);
- return oldObserver;
- }
+ vector<const Observer*>::iterator i = find(m_observers.begin(), m_observers.end(), oldObserver);
+ if (i != m_observers.end()) {
+ m_observers.erase(i);
+ return oldObserver;
}
- return NULL;
+ return nullptr;
+}
+
+ObservableMetadataProvider::Observer::Observer()
+{
+}
+
+ObservableMetadataProvider::Observer::~Observer()
+{
+}
+
+void ObservableMetadataProvider::Observer::onEvent(const ObservableMetadataProvider& provider, const EntityDescriptor&) const
+{
+ onEvent(provider);
}