pipeConnection.h

00001 
00002 /* Copyright (c) 2005-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef EQNET_PIPE_CONNECTION_H
00019 #define EQNET_PIPE_CONNECTION_H
00020 
00021 #ifdef WIN32
00022 #  include <eq/net/connection.h>
00023 #else
00024 #  include "fdConnection.h"
00025 #endif
00026 
00027 #include <eq/base/thread.h>
00028 
00029 namespace eq
00030 {
00031 namespace net
00032 {
00040     class PipeConnection 
00041 #ifdef WIN32
00042         : public Connection
00043 #else
00044         : public FDConnection
00045 #endif
00046     {
00047     public:
00049         EQ_EXPORT PipeConnection();
00051         EQ_EXPORT virtual ~PipeConnection();
00052 
00053         virtual bool connect();
00054         virtual void close();
00055 
00056 #ifdef WIN32
00057         virtual Notifier getNotifier() const { return _dataPending; }
00058         bool hasData() const 
00059             { return WaitForSingleObject( _dataPending, 0 ) == WAIT_OBJECT_0; }
00060 #endif
00061 
00062     protected:
00063 #ifdef WIN32
00064         virtual void readNB( void* buffer, const uint64_t bytes );
00065         virtual int64_t readSync( void* buffer, const uint64_t bytes );
00066         virtual int64_t write( const void* buffer, const uint64_t bytes );
00067 #endif
00068 
00069     private:
00070         bool _createPipe();
00071 
00072 #ifdef WIN32
00073         HANDLE _readHandle;
00074         HANDLE _writeHandle;
00075         mutable base::Lock _mutex;
00076         mutable uint64_t   _size;
00077         mutable HANDLE     _dataPending;
00078 #endif
00079     };
00080 }
00081 }
00082 
00083 #endif //EQNET_PIPE_CONNECTION_H
Generated on Mon Aug 10 18:58:40 2009 for Equalizer 0.9 by  doxygen 1.5.8