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
SimpleScene.cpp
Go to the documentation of this file.
1 //
2 // C++ Implementation: Audio::SimpleScene
3 //
4 
5 #include "SimpleScene.h"
6 #include "SimpleSource.h"
7 #include "config.h"
8 
9 #include "SceneManager.h"
10 
11 namespace Audio {
12 
13  SimpleScene::SimpleScene(const std::string &name) throw() :
14  Scene(name)
15  {
16  }
17 
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  }
27 
28  void SimpleScene::add(SharedPtr<Source> source)
29  throw(Exception)
30  {
31  attach(dynamic_cast<SimpleSource*>(source.get()));
32  }
33 
34  void SimpleScene::remove(SharedPtr<Source> source)
35  throw(NotFoundException)
36  {
37  detach(dynamic_cast<SimpleSource*>(source.get()));
38  }
39 
41  throw()
42  {
43  return listener;
44  }
45 
46  void SimpleScene::notifySourcePlaying(SharedPtr<Source> source, bool playing)
47  throw(Exception)
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  }
56 
58  throw()
59  {
60  source->notifySceneAttached(this);
61  }
62 
64  throw()
65  {
66  source->notifySceneAttached(0);
67  }
68 
71  throw()
72  {
73  return activeSources.begin();
74  }
75 
78  throw()
79  {
80  return activeSources.end();
81  }
82 
83 };