Move MIDI common files in server library on OSX.
[jack2.git] / windows / JackWinNamedPipe.h
blob6487d4b349e2977d0e952411e93b28e1443e432b
1 /*
2 Copyright (C) 2004-2008 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #ifndef __JackWinNamedPipe__
22 #define __JackWinNamedPipe__
24 #include <windows.h>
26 namespace Jack
29 class JackWinNamedPipe
32 protected:
34 HANDLE fNamedPipe;
35 char fName[256];
37 public:
39 JackWinNamedPipe(): fNamedPipe(INVALID_HANDLE_VALUE)
41 JackWinNamedPipe(HANDLE pipe): fNamedPipe(pipe)
43 virtual ~JackWinNamedPipe()
46 virtual int Read(void* data, int len);
47 virtual int Write(void* data, int len);
50 /*!
51 \brief Client named pipe.
54 class JackWinNamedPipeClient : public JackWinNamedPipe
57 public:
59 JackWinNamedPipeClient(): JackWinNamedPipe()
61 JackWinNamedPipeClient(HANDLE pipe): JackWinNamedPipe(pipe)
64 virtual ~JackWinNamedPipeClient()
67 virtual int Connect(const char* dir, int which);
68 virtual int Connect(const char* dir, const char* name, int which);
69 virtual int Close();
70 virtual void SetReadTimeOut(long sec);
71 virtual void SetWriteTimeOut(long sec);
74 class JackWinAsyncNamedPipeClient : public JackWinNamedPipeClient
76 enum kIOState {kIdle = 0, kConnecting, kReading, kWriting};
78 private:
80 bool fPendingIO;
81 kIOState fIOState;
82 OVERLAPPED fOverlap;
84 public:
86 JackWinAsyncNamedPipeClient();
87 JackWinAsyncNamedPipeClient(HANDLE pipe, bool pending);
88 virtual ~JackWinAsyncNamedPipeClient();
90 virtual int Read(void* data, int len);
91 virtual int Write(void* data, int len);
93 HANDLE GetEvent()
95 return (HANDLE)fOverlap.hEvent;
98 kIOState GetIOState()
100 return fIOState;
103 bool GetPending()
105 return fPendingIO;
108 int FinishIO();
112 \brief Server named pipe.
115 class JackWinNamedPipeServer : public JackWinNamedPipe
118 public:
120 JackWinNamedPipeServer(): JackWinNamedPipe()
122 virtual ~JackWinNamedPipeServer()
125 virtual int Bind(const char* dir, int which);
126 virtual int Bind(const char* dir, const char* name, int which);
127 virtual bool Accept();
128 virtual JackWinNamedPipeClient* AcceptClient();
129 int Close();
133 \brief Server async named pipe.
136 class JackWinAsyncNamedPipeServer : public JackWinNamedPipeServer
139 public:
141 JackWinAsyncNamedPipeServer(): JackWinNamedPipeServer()
143 virtual ~JackWinAsyncNamedPipeServer()
146 int Bind(const char* dir, int which);
147 int Bind(const char* dir, const char* name, int which);
148 bool Accept();
149 JackWinNamedPipeClient* AcceptClient();
150 int Close();
153 } // end of namespace
156 #endif