JackWinNamedPipeServerChannel.h

00001 /*
00002 Copyright (C) 2004-2006 Grame  
00003   
00004   This program is free software; you can redistribute it and/or modify
00005   it under the terms of the GNU Lesser General Public License as published by
00006   the Free Software Foundation; either version 2.1 of the License, or
00007   (at your option) any later version.
00008   
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU Lesser General Public License for more details.
00013   
00014   You should have received a copy of the GNU Lesser General Public License
00015   along with this program; if not, write to the Free Software 
00016   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 
00018 */
00019 
00020 #ifndef __JackWinNamedPipeServerChannel__
00021 #define __JackWinNamedPipeServerChannel__
00022 
00023 #include "JackChannel.h"
00024 #include "JackWinNamedPipe.h"
00025 #include "JackThread.h"
00026 #include <map>
00027 #include <list>
00028 
00029 namespace Jack
00030 {
00031 
00032 class JackClientPipeThread : public JackRunnableInterface
00033 {
00034 
00035     private:
00036 
00037         JackWinNamedPipeClient* fPipe;
00038         JackServer*     fServer;
00039         JackThread*     fThread;
00040         int fRefNum;
00041 
00042         void AddClient(char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result);
00043         void RemoveClient();
00044         void KillClient();
00045 
00046         static HANDLE fMutex;
00047 
00048     public:
00049 
00050         JackClientPipeThread(JackWinNamedPipeClient* pipe);
00051         virtual ~JackClientPipeThread();
00052 
00053         int Open(JackServer* server);   // Open the Server/Client connection
00054         void Close();                                   // Close the Server/Client connection
00055 
00056         int HandleRequest();
00057 
00058         // JackRunnableInterface interface
00059         bool Execute();
00060 
00061                 // To be used for find out if the object can be deleted
00062         bool IsRunning()
00063         {
00064             return (fRefNum >= 0);
00065         }
00066 };
00067 
00072 class JackWinNamedPipeServerChannel : public JackServerChannelInterface, public JackRunnableInterface
00073 {
00074 
00075     private:
00076 
00077         JackWinNamedPipeServer fRequestListenPipe;      // Pipe to create request socket for the client
00078         JackServer*     fServer;
00079         JackThread*     fThread;                                                // Thread to execute the event loop
00080 
00081         std::list<JackClientPipeThread*> fClientList;
00082 
00083         void AddClient(JackWinNamedPipeClient* pipe);
00084 
00085     public:
00086 
00087         JackWinNamedPipeServerChannel();
00088         virtual ~JackWinNamedPipeServerChannel();
00089 
00090         int Open(JackServer* server);   // Open the Server/Client connection
00091         void Close();                                   // Close the Server/Client connection
00092 
00093         // JackRunnableInterface interface
00094         bool Init();
00095         bool Execute();
00096 };
00097 
00098 
00099 } // end of namespace
00100 
00101 #endif
00102 

Generated on Wed Jan 10 11:42:47 2007 for Jackdmp by  doxygen 1.4.5