bufferConnection.cpp

00001 
00002 /* Copyright (c) 2007-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 #include "bufferConnection.h"
00019 
00020 #include <string.h>
00021 
00022 using namespace std;
00023 
00024 namespace eq
00025 {
00026 namespace net
00027 {
00028 BufferConnection::BufferConnection()
00029 {
00030     _state = STATE_CONNECTED;
00031     EQVERB << "New BufferConnection @" << (void*)this << endl;
00032 }
00033 
00034 BufferConnection::~BufferConnection()
00035 {
00036     if( !_buffer.isEmpty( ))
00037         EQWARN << "Deleting BufferConnection with buffered data" << endl;
00038 }
00039 
00040 int64_t BufferConnection::write( const void* buffer, const uint64_t bytes )
00041 {
00042     _buffer.append( reinterpret_cast< const uint8_t* >( buffer ), bytes );
00043     return bytes;
00044 }
00045 
00046 void BufferConnection::sendBuffer( ConnectionPtr connection )
00047 {
00048     if( _buffer.isEmpty( ))
00049         return;
00050 
00051     if( !connection )
00052     {
00053         EQWARN << "NULL connection during buffer write" << endl;
00054         return;
00055     }
00056 
00057     EQCHECK( connection->send( _buffer.getData(), _buffer.getSize() ));
00058     _buffer.setSize( 0 );
00059 }
00060 }
00061 }
Generated on Sat Feb 6 12:59:42 2010 for Equalizer 0.9.1 by  doxygen 1.6.1