1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
13//osgFX - Copyright (C) 2003 Marco Jez
15#ifndef OSGFX_REGISTRY_
16#define OSGFX_REGISTRY_
18#include <osgFX/Export>
19#include <osgFX/Effect>
29 class OSGFX_EXPORT Registry : public osg::Referenced
34 Proxy(const Effect* effect): _effect(effect)
36 Registry::instance()->registerEffect(effect);
41 Registry::instance()->removeEffect(_effect.get());
44 osg::ref_ptr<const Effect> _effect;
47 typedef std::map<std::string, osg::ref_ptr<const Effect> > EffectMap;
49 static Registry* instance();
51 inline void registerEffect(const Effect* effect);
53 inline void removeEffect(const Effect* effect);
55 inline const EffectMap& getEffectMap() const;
59 // Registry is a singleton; constructor and destructor must be protected
71 inline const Registry::EffectMap& Registry::getEffectMap() const
76 inline void Registry::registerEffect(const Effect* effect)
78 _effects[effect->effectName()] = effect;
81 inline void Registry::removeEffect(const Effect* effect)
83 EffectMap::iterator itr = _effects.find(effect->effectName());
84 if (itr != _effects.end())