sgpemv2/src/backend/observed_subject.hh
tchernobog 6b27a8461b - Pretty-indenting code
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@674 3ecf2c5c-341e-0410-92b4-d18e462d057c
2006-06-29 08:44:30 +00:00

76 lines
2 KiB
C++

// src/backend/observedSubject.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef OBSERVEDSUBJECT_HH
#define OBSERVEDSUBJECT_HH 1
#include "config.h"
#include <vector>
#include <algorithm>
#include "../observer.hh"
namespace sgpem
{
class ObservedSubject;
/** \brief Represents an observed entity.
Abstract class which represents an observed entity. It calls Update() in all Observer objects
which are attached to it. See the "Observer Pattern" for more informations.
*/
class SG_DLLEXPORT ObservedSubject
{
public:
virtual ~ObservedSubject() = 0;
/**
This method calls Update() on each attached Observer. It should be called when the internal state
of the ObservedSubject is changed and Observers have to be updated.
*/
void notify();
/**
\brief Adds an Observer object to the internal list.
*/
void attach(sgpem::Observer*);
/**
\brief Removes an Observer object from the internal list.
\returns TRUE if the Observer object has been previously attached (is found in the list);
\returns FALSE otherwise.
*/
bool detach(sgpem::Observer*);
private:
std::vector<Observer*> _attached;
};
} //~ namespace sgpem
#endif