Observer
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library 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
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_OBSERVER
#define OSG_OBSERVER 1
#include <OpenThreads/Mutex>
#include <osg/Referenced>
#include <set>
namespace osg {
class OSG_EXPORT Observer
{
public:
Observer();
virtual ~Observer();
virtual void objectDeleted(void*) {}
};
class OSG_EXPORT ObserverSet : public osg::Referenced
{
public:
ObserverSet(const Referenced* observedObject);
Referenced* getObserverdObject() { return _observedObject; }
const Referenced* getObserverdObject() const { return _observedObject; }
Referenced* addRefLock();
inline OpenThreads::Mutex* getObserverSetMutex() const { return &_mutex; }
void addObserver(Observer* observer);
void removeObserver(Observer* observer);
void signalObjectDeleted(void* ptr);
typedef std::set<Observer*> Observers;
Observers& getObservers() { return _observers; }
const Observers& getObservers() const { return _observers; }
protected:
ObserverSet(const ObserverSet& rhs): osg::Referenced(rhs) {}
ObserverSet& operator = (const ObserverSet& /*rhs*/) { return *this; }
virtual ~ObserverSet();
mutable OpenThreads::Mutex _mutex;
Referenced* _observedObject;
Observers _observers;
};
}
#endif
Mutex
Referenced
OpenThreads::Mutex
This class provides an object-oriented thread mutex interface.
Definition Mutex:31
osg::ObserverSet::getObserverdObject
const Referenced * getObserverdObject() const
Definition Observer:45
osg::ObserverSet::ObserverSet
ObserverSet(const ObserverSet &rhs)
Definition Observer:66
osg::ObserverSet::removeObserver
void removeObserver(Observer *observer)
osg::ObserverSet::_mutex
OpenThreads::Mutex _mutex
Definition Observer:70
osg::ObserverSet::getObservers
Observers & getObservers()
Definition Observer:61
osg::ObserverSet::Observers
std::set< Observer * > Observers
Definition Observer:60
osg::ObserverSet::getObserverSetMutex
OpenThreads::Mutex * getObserverSetMutex() const
Definition Observer:53
osg::ObserverSet::getObserverdObject
Referenced * getObserverdObject()
Definition Observer:44
osg::ObserverSet::addRefLock
Referenced * addRefLock()
osg::ObserverSet::_observedObject
Referenced * _observedObject
Definition Observer:71
osg::ObserverSet::signalObjectDeleted
void signalObjectDeleted(void *ptr)
osg::ObserverSet::~ObserverSet
virtual ~ObserverSet()
osg::ObserverSet::getObservers
const Observers & getObservers() const
Definition Observer:62
osg::ObserverSet::_observers
Observers _observers
Definition Observer:72
osg::ObserverSet::ObserverSet
ObserverSet(const Referenced *observedObject)
osg::ObserverSet::addObserver
void addObserver(Observer *observer)
osg::Observer
Definition Observer:25
osg::Observer::Observer
Observer()
osg::Observer::objectDeleted
virtual void objectDeleted(void *)
Definition Observer:33
osg::Observer::~Observer
virtual ~Observer()
osg::Referenced
Definition Referenced:44
osg::Referenced::Referenced
Referenced()
osg
Definition AlphaFunc:19
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39