Skip to content
Snippets Groups Projects
IObserver.h 1.74 KiB
Newer Older
  • Learn to ignore specific revisions
  • // ************************************************************************** //
    
    //  BornAgain: simulate and fit scattering at grazing incidence
    //
    
    //! @file      Tools/inc/IObserver.h
    
    //! @brief     Defines classes IObserver and IObservable (Observer pattern).
    //!
    
    //! @homepage  http://apps.jcns.fz-juelich.de/BornAgain
    
    //! @license   GNU General Public License v3 or higher (see COPYING)
    
    //! @copyright Forschungszentrum Jülich GmbH 2013
    //! @authors   Scientific Computing Group at MLZ Garching
    
    //! @authors   C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke
    
    //
    // ************************************************************************** //
    
    
    #ifndef IOBSERVER_H
    #define IOBSERVER_H
    
    #include "Exceptions.h"
    #include <list>
    
    pospelov's avatar
    pospelov committed
    #include <boost/shared_ptr.hpp>
    
    pospelov's avatar
    pospelov committed
    
    
    //! @class IObserver
    //! @ingroup tools_internal
    //! @brief Observer interface from %Observer pattern, for 1:n object dependencies.
    
    pospelov's avatar
    pospelov committed
        virtual ~IObserver() {}
    
    
        //! method which is used by observable subject to notify change in status
    
        virtual void update (IObservable* /*subject*/) {
    
            throw NotImplementedException("IObserver::update() -> Not implemented");
        }
    
    pospelov's avatar
    pospelov committed
    
    
    //! @class IObservable
    //! @ingroup tools_internal
    //! @brief Observable interface from %Observer pattern, for 1:n object dependencies.
    
    pospelov's avatar
    pospelov committed
        typedef boost::shared_ptr<IObserver > observer_t;
        typedef std::list<observer_t > observerlist_t;
    
    
        virtual ~IObservable(){}
    
        //! attach observer to the list of observers
    
    pospelov's avatar
    pospelov committed
        virtual void attachObserver(observer_t obj);
    
    
        //! notify observers about change in status
    
    pospelov's avatar
    pospelov committed
        observerlist_t m_observers;