Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# Messager.h

    00001 #ifndef STK_MESSAGER_H
    00002 #define STK_MESSAGER_H
    00003
    00004 #include "Stk.h"
    00005 #include "Skini.h"
    00006 #include <queue>
    00007
    00008 #if defined(__STK_REALTIME__)
    00009
    00010 #include "Mutex.h"
    00011 #include "Thread.h"
    00012 #include "TcpServer.h"
    00013 #include "RtMidi.h"
    00014
    00015 #endif // __STK_REALTIME__
    00016
    00017 namespace stk {
    00018
    00019 /***************************************************/
    00051 /***************************************************/
    00052
    00053 const int DEFAULT_QUEUE_LIMIT = 200;
    00054
    00055 class Messager : public Stk
    00056 {
    00057  public:
    00058
    00059   // This structure is used to share data among the various realtime
    00060   // messager threads.  It must be public.
    00061   struct MessagerData {
    00062     Skini skini;
    00063     std::queue<Skini::Message> queue;
    00064     unsigned int queueLimit;
    00065     int sources;
    00066
    00067 #if defined(__STK_REALTIME__)
    00068     Mutex mutex;
    00069     RtMidiIn *midi;
    00070     TcpServer *socket;
    00071     std::vector<int> fd;
    00072     fd_set mask;
    00073 #endif
    00074
    00075     // Default constructor.
    00076     MessagerData()
    00077       :queueLimit(0), sources(0) {}
    00078   };
    00079
    00081   Messager();
    00082
    00084   ~Messager();
    00085
    00087
    00093   void popMessage( Skini::Message& message );
    00094
    00096   void pushMessage( Skini::Message& message );
    00097
    00099
    00107   bool setScoreFile( const char* filename );
    00108
    00109 #if defined(__STK_REALTIME__)
    00111
    00120   bool startStdInput();
    00121
    00123
    00134   bool startSocketInput( int port=2001 );
    00135
    00137
    00149   bool startMidiInput( int port=0 );
    00150
    00151 #endif
    00152
    00153  protected:
    00154
    00155   MessagerData data_;
    00156
    00157 #if defined(__STK_REALTIME__)
    00158   Thread stdinThread_;
    00159   Thread socketThread_;
    00160 #endif
    00161
    00162 };
    00163
    00164 } // stk namespace
    00165
    00166 #endif

The Synthesis ToolKit in C++ (STK)
©1995-2010 Perry R. Cook and Gary P. Scavone. All Rights Reserved.