diff --git a/EosOscChannel.cpp b/EosOscChannel.cpp index 590ee9f..2fef3c1 100644 --- a/EosOscChannel.cpp +++ b/EosOscChannel.cpp @@ -5,6 +5,9 @@ char EosOscChannel::channelDisplayLine[CHANNEL_DISPLAY_LENGTH+1]; //current command line +EosOscChannel EosOscChannel::singleton; +bool EosOscChannel::madeSingleton = false; + EosOscChannel::EosOscChannel() { // manager->registerHandler(this); @@ -49,3 +52,13 @@ void EosOscChannel::routeCmd(OSCMessage &msg, int addrOffSet) { } + + +EosOscChannel* EosOscChannel::getInstance() { + if (!madeSingleton) EosOscChannel(singleton); + madeSingleton = true; + return &singleton; + //return NULL; +}; + + diff --git a/EosOscChannel.h b/EosOscChannel.h index fb26846..43e9b0c 100644 --- a/EosOscChannel.h +++ b/EosOscChannel.h @@ -10,10 +10,10 @@ class EosOscChannel : public EosOscHandler { private: - public: - EosOscChannel(); - + static EosOscChannel singleton; + static bool madeSingleton; + EosOscChannel(); //ideally hidden so can only get singleton void writeCommandLine(Stream &print); virtual void userChanged(); @@ -22,6 +22,13 @@ class EosOscChannel : public EosOscHandler static char channelDisplayLine[CHANNEL_DISPLAY_LENGTH+1]; //current command line static void routeCmd(OSCMessage &msg, int addrOffSet); + + static EosOscChannel * getInstance(); + /* + { + static EosOscChannel singleton; + return &singleton; + }*/ };