Made a singleton

git-svn-id: http://svn.drobilla.net/lad@94 a436a847-0d15-0410-975c-d299462d15a1
This commit is contained in:
dave 2006-07-18 05:16:37 +00:00
parent 2891e14e42
commit 246f424207
1 changed files with 9 additions and 4 deletions

View File

@ -39,15 +39,18 @@ template <typename T> class Driver;
/** The main class for Om, the whole app lives in here
*
* This class should not exist.
* A singleton, but shouldn't be (FIXME). Explicitly instantiated singleton
* to be exact - call instantiate before instance or suffer horrible death.
*
* \ingroup engine
*/
class OmApp
{
public:
OmApp(const char* const port, AudioDriver* audio_driver = 0);
~OmApp();
static void instantiate(const char* port, AudioDriver* audio_driver = 0);
OmApp& instance() { assert(m_instance); return *m_instance; }
int main();
@ -58,7 +61,6 @@ public:
void activate();
void deactivate();
AudioDriver* audio_driver() const { return m_audio_driver; }
OSCReceiver* osc_receiver() const { return m_osc_receiver; }
MidiDriver* midi_driver() const { return m_midi_driver; }
@ -75,10 +77,13 @@ public:
template<typename T> Driver<T>* driver();
private:
OmApp(const char* port, AudioDriver* audio_driver = 0);
// Prevent copies
OmApp(const OmApp&);
OmApp& operator=(const OmApp&);
static OmApp* m_instance;
AudioDriver* m_audio_driver;
OSCReceiver* m_osc_receiver;