From 36875bcf5c6d257e9173892d260db8462e849cb4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 18 Jul 2006 05:16:37 +0000 Subject: Made a singleton git-svn-id: http://svn.drobilla.net/lad/ingen@94 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/OmApp.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/libs/engine/OmApp.h') diff --git a/src/libs/engine/OmApp.h b/src/libs/engine/OmApp.h index 240f356e..f59b15f5 100644 --- a/src/libs/engine/OmApp.h +++ b/src/libs/engine/OmApp.h @@ -39,15 +39,18 @@ template 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 Driver* 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; -- cgit v1.2.1