-
Notifications
You must be signed in to change notification settings - Fork 0
/
MPI_Application.cpp
89 lines (68 loc) · 2 KB
/
MPI_Application.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// MPI_Application.cpp
//
#include "MPI_Application.h"
#include "MPI_Audio.h"
#include "MPI_Scheduler.h"
#include "MPI_AudioParticleFactory.h"
#include "MPI_Workspace.h"
#include "MPI_GUIRootWindow.h"
MPI_Application* MPI_Application::singletoninstance_ = NULL;
MPI_Application& MPI_Application::getInstance( void )
{
if ( !singletoninstance_ )
singletoninstance_ = new MPI_Application;
return *singletoninstance_;
}
void MPI_Application::destroyInstance( void )
{
// technically, this shouldn't be allowed, but this singleton needs to be
// destroyed somehow.
// FIXME try to find a nicer way to handle this
delete singletoninstance_;
singletoninstance_ = NULL;
}
void MPI_Application::start( void ) const
{
// Start up the application
// These calls may access MPI_Application::getInstance()
audio_->start();
guirootwindow_->start();
// this hangs here -- guirootwindow_->start() calls
// glutMainLoop(), which doesn't return.
}
MPI_Audio& MPI_Application::getAudio( void ) const
{
return *audio_;
}
MPI_GUIRootWindow& MPI_Application::getGUIRootWindow( void ) const
{
return *guirootwindow_;
}
MPI_ParticleFactory& MPI_Application::getParticleFactory( void ) const
{
return *factory_;
}
MPI_Application::MPI_Application()
{
// allocate all of the objects
// These calls may NOT access MPI_Application::getInstance()!
// It'll be undefined if they do, and chaos will ensue.
audio_ = new MPI_Audio;
scheduler_ = new MPI_Scheduler;
workspace_ = new MPI_Workspace;
factory_ = new MPI_AudioParticleFactory( *audio_, *workspace_, *scheduler_ );
workspace_->setFactory( factory_ );
factory_->setStateParticleStroke();
guirootwindow_ = new MPI_GUIRootWindow( *workspace_, *scheduler_ );
}
MPI_Application::~MPI_Application()
{
// destroy all of the objects in reverse order
delete guirootwindow_;
delete workspace_;
delete factory_;
delete scheduler_;
delete audio_;
}
// vim:sw=4:et:cindent: