/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * Notification.cpp * * Created on: Dec 1, 2011 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "CodePatterns/Observer/Notification.hpp" #include "CodePatterns/Observer/Observer.hpp" #include "CodePatterns/Observer/ObserverLog.hpp" Notification::Notification(size_t _channelno) : channelno(_channelno) {} Notification::~Notification(){} void Notification::addObserver(Observer *target) { targets.insert(target); } void Notification::removeObserver(Observer *target) { targets.erase(target); } void Notification::notifyAll(Observable * const publisher) { for(std::set::iterator it=targets.begin(); it!=targets.end();++it){ #ifdef LOG_OBSERVER observerLog().addMessage() << "-> Sending update from " << observerLog().getName(publisher) << " for channel " << channelno << " to " << observerLog().getName(*it); #endif (*it)->recieveNotification(publisher,this); } } void Notification::subjectKilled(Observable * const publisher) { for(std::set::iterator it=targets.begin(); it!=targets.end();++it){ (*it)->subjectKilled(publisher); } }