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 ClientAdd(char* name, int* shared_engine, int* shared_client, int* shared_graph, int* result);
00043         void ClientRemove();
00044         void ClientKill();
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                 char fServerName[64];
00081 
00082         std::list<JackClientPipeThread*> fClientList;
00083 
00084         void ClientAdd(JackWinNamedPipeClient* pipe);
00085 
00086     public:
00087 
00088         JackWinNamedPipeServerChannel();
00089         virtual ~JackWinNamedPipeServerChannel();
00090 
00091         int Open(const char* server_name, JackServer* server);  // Open the Server/Client connection
00092         void Close();                                   // Close the Server/Client connection
00093 
00094         // JackRunnableInterface interface
00095         bool Init();
00096         bool Execute();
00097 };
00098 
00099 
00100 } // end of namespace
00101 
00102 #endif
00103 

Generated on Thu Feb 14 11:16:02 2008 for Jackdmp by  doxygen 1.5.1