Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Audio::SimpleScene Class Reference

#include <SimpleScene.h>

Inheritance diagram for Audio::SimpleScene:
Audio::Scene

Public Types

typedef SourceSet::iterator SourceIterator
 

Public Member Functions

 SimpleScene (const std::string &name) throw ()
 
virtual ~SimpleScene ()
 
virtual void add (SharedPtr< Source > source) throw (Exception)
 
virtual void remove (SharedPtr< Source > source) throw (NotFoundException)
 
virtual ListenergetListener () throw ()
 
virtual void notifySourcePlaying (SharedPtr< Source > source, bool playing) throw (Exception)
 
SourceIterator getActiveSources () throw ()
 
SourceIterator getActiveSourcesEnd () throw ()
 
- Public Member Functions inherited from Audio::Scene
virtual ~Scene ()
 
const std::string & getName () const throw ()
 

Protected Member Functions

void attach (SimpleSource *source) throw ()
 
void detach (SimpleSource *source) throw ()
 
- Protected Member Functions inherited from Audio::Scene
 Scene (const std::string &name) throw ()
 

Detailed Description

SimpleScene, basic implementation of the Scene interface

Remarks
This class implements the scene interface for a basic Scene manager.

Definition at line 27 of file SimpleScene.h.

Member Typedef Documentation

typedef SourceSet::iterator Audio::SimpleScene::SourceIterator

Definition at line 36 of file SimpleScene.h.

Constructor & Destructor Documentation

Audio::SimpleScene::SimpleScene ( const std::string &  name)
throw (
)

Construct a new, empty scene

Definition at line 13 of file SimpleScene.cpp.

13  :
14  Scene(name)
15  {
16  }
Audio::SimpleScene::~SimpleScene ( )
virtual

Definition at line 18 of file SimpleScene.cpp.

References detach().

19  {
20  SourceSet::iterator it;
21 
22  for (it = activeSources.begin(); it != activeSources.end(); ++it) {
23  (*it)->stopPlaying();
24  detach(dynamic_cast<SimpleSource*>(it->get()));
25  }
26  }

Member Function Documentation

void Audio::SimpleScene::add ( SharedPtr< Source source)
throw (Exception
)
virtual

Attach a source to this scene.

Remarks
The must be stopped. Adding a playing source is an error.
Remarks
source MUST be a SimpleSource

Implements Audio::Scene.

Definition at line 28 of file SimpleScene.cpp.

30  {
31  attach(dynamic_cast<SimpleSource*>(source.get()));
32  }
void Audio::SimpleScene::attach ( SimpleSource source)
throw (
)
protected

Definition at line 57 of file SimpleScene.cpp.

59  {
60  source->notifySceneAttached(this);
61  }
void Audio::SimpleScene::detach ( SimpleSource source)
throw (
)
protected

Definition at line 63 of file SimpleScene.cpp.

Referenced by ~SimpleScene().

65  {
66  source->notifySceneAttached(0);
67  }
SimpleScene::SourceIterator Audio::SimpleScene::getActiveSources ( )
throw (
)

Gets an iterator over active sources

Definition at line 70 of file SimpleScene.cpp.

Referenced by Audio::SceneManager::activationPhaseImpl().

72  {
73  return activeSources.begin();
74  }
SimpleScene::SourceIterator Audio::SimpleScene::getActiveSourcesEnd ( )
throw (
)

Gets the ending iterator of active sources

Definition at line 77 of file SimpleScene.cpp.

Referenced by Audio::SceneManager::activationPhaseImpl().

79  {
80  return activeSources.end();
81  }
Listener & Audio::SimpleScene::getListener ( )
throw (
)
virtual

Get the scene's listener

Implements Audio::Scene.

Definition at line 40 of file SimpleScene.cpp.

Referenced by Audio::SceneManager::activationPhaseImpl().

42  {
43  return listener;
44  }
void Audio::SimpleScene::notifySourcePlaying ( SharedPtr< Source source,
bool  playing 
)
throw (Exception
)
virtual

Notify the scene of a source that starts or stops playing.

Definition at line 46 of file SimpleScene.cpp.

References Singleton< SceneManager >::getSingleton(), and Audio::SceneManager::notifySourcePlaying().

Referenced by Audio::SimpleSource::stopPlayingImpl().

48  {
49  if (playing)
50  activeSources.insert(source);
51  else
52  activeSources.erase(source);
53 
54  SceneManager::getSingleton()->notifySourcePlaying(source, shared_from_this(), playing);
55  }
void Audio::SimpleScene::remove ( SharedPtr< Source source)
throw (NotFoundException
)
virtual

Detach a source from this scene

Remarks
The source is implicitly stopped.
Remarks
source MUST be a SimpleSource

Implements Audio::Scene.

Definition at line 34 of file SimpleScene.cpp.

36  {
37  detach(dynamic_cast<SimpleSource*>(source.get()));
38  }

The documentation for this class was generated from the following files: