osg::GroupMCastConnection Class Reference
[Network]

#include <OSGGroupMCastConnection.h>

Inheritance diagram for osg::GroupMCastConnection:

osg::GroupSockConnection osg::GroupConnection osg::Connection osg::BinaryDataHandler

List of all members.

private helpers



bool checkChannels (void)
bool sendQueue (void)
void initialize (void)
static void sendQueueThread (void *arg)

Public Types

public types


typedef Int32 Channel

Public Member Functions

Constructors


 GroupMCastConnection (void)
virtual ~GroupMCastConnection (void)
type info


virtual const ConnectionTypegetType (void)
connection


virtual Channel connectPoint (const std::string &address, Time timeout=-1)
virtual void disconnect (Channel channel)
virtual Channel acceptPoint (Time timeout=-1)
params


virtual void setParams (const std::string &params)
connection


virtual std::string bind (const std::string &interf)
channel handling


virtual Channel selectChannel (Time timeout=-1) throw (ReadError)
channel handling


UInt32 getChannelCount (void)
void addSelection (Channel channel)
void subSelection (Channel channel)
void clearSelection (void)
void resetSelection (void)
UInt32 getSelectionCount (void)
group address


void setDestination (const std::string &destination)
std::string getDestination (void)
interface


const std::string & getInterface (void)
void setInterface (const std::string &interf)
Put


void put (void const *src, UInt32 size)
void putAndFree (MemoryHandle src, UInt32 size)
void putValue (const bool &value)
void putValue (const UInt8 &value)
void putValue (const UInt16 &value)
void putValue (const UInt32 &value)
void putValue (const UInt64 &value)
void putValue (const Int8 &value)
void putValue (const Int16 &value)
void putValue (const Int32 &value)
void putValue (const Int64 &value)
void putValue (const Real16 &value)
void putValue (const Real32 &value)
void putValue (const Real64 &value)
void putValue (const Real128 &value)
void putValue (const std::string &value)
void putValues (const bool *value, UInt32 size)
void putValues (const UInt8 *value, UInt32 size)
void putValues (const UInt16 *value, UInt32 size)
void putValues (const UInt32 *value, UInt32 size)
void putValues (const UInt64 *value, UInt32 size)
void putValues (const Int8 *value, UInt32 size)
void putValues (const Int16 *value, UInt32 size)
void putValues (const Int32 *value, UInt32 size)
void putValues (const Int64 *value, UInt32 size)
void putValues (const Real16 *value, UInt32 size)
void putValues (const Real32 *value, UInt32 size)
void putValues (const Real64 *value, UInt32 size)
void putValues (const Real128 *value, UInt32 size)
void putValues (const std::string *value, UInt32 size)
Get


void get (void *dst, UInt32 size)
void getAndAlloc (MemoryHandle &src, UInt32 size)
void getValue (bool &value)
void getValue (UInt8 &value)
void getValue (UInt16 &value)
void getValue (UInt32 &value)
void getValue (UInt64 &value)
void getValue (Int8 &value)
void getValue (Int16 &value)
void getValue (Int32 &value)
void getValue (Int64 &value)
void getValue (Real16 &value)
void getValue (Real32 &value)
void getValue (Real64 &value)
void getValue (Real128 &value)
void getValue (std::string &value)
void getValues (bool *value, UInt32 size)
void getValues (UInt8 *value, UInt32 size)
void getValues (UInt16 *value, UInt32 size)
void getValues (UInt32 *value, UInt32 size)
void getValues (UInt64 *value, UInt32 size)
void getValues (Int8 *value, UInt32 size)
void getValues (Int16 *value, UInt32 size)
void getValues (Int32 *value, UInt32 size)
void getValues (Int64 *value, UInt32 size)
void getValues (Real16 *value, UInt32 size)
void getValues (Real32 *value, UInt32 size)
void getValues (Real64 *value, UInt32 size)
void getValues (Real128 *value, UInt32 size)
void getValues (std::string *value, UInt32 size)
Helper


virtual void forceCopy (void)
virtual void forceDirectIO (void)
void flush (void)
 write data not yet written
void setNetworkOrder (bool value)
bool getNetworkOrder (void)

Static Public Member Functions

create


static GroupConnectioncreate (void)
 create conneciton

Protected Types

typedef std::vector< MemoryBlockBuffersT
typedef std::list< MemoryHandleFreeMemT
protected types


typedef Int32 ChannelIndex

Protected Member Functions

IO Implementation


virtual void write (MemoryHandle mem, UInt32 size)
virtual void writeBuffer (void)
synchronisation


virtual bool wait (Time timeout) throw (ReadError)
virtual void signal (void) throw (WriteError)
IO Implementation


virtual void read (MemoryHandle mem, UInt32 size)
virtual void readBuffer (void)
internal channel handling


Channel newChannelIndex (ChannelIndex index)
void delChannelIndex (ChannelIndex index)
channel index mapping


ChannelIndex channelToIndex (Channel channel) const
Channel indexToChannel (ChannelIndex index) const
Read


BuffersT::iterator readBufBegin (void)
BuffersT::iterator readBufEnd (void)
void readBufAdd (MemoryHandle mem, UInt32 size, UInt32 dataSize=0)
void readBufClear (void)
Write


BuffersT::iterator writeBufBegin (void)
BuffersT::iterator writeBufEnd (void)
void writeBufAdd (MemoryHandle mem, UInt32 size, UInt32 dataSize=0)
void writeBufClear (void)
Helper


bool isReadBufferEmpty (void)

Protected Attributes

Members


DgramSocket _mcastSocket
SocketAddress _mcastAddress
BaseThread_sendQueueThread
bool _sendQueueThreadRunning
bool _sendQueueThreadStop
DgramQueue _queue
DgramQueue _free
Lock_lock
UInt16 _seqNumber
UInt32 _receivers
UInt32 _windowSize
std::vector< SocketAddress_receiver
std::vector< SocketAddress_waitFor
bool _initialized
members


StreamSocket _acceptSocket
std::vector< StreamSocket_sockets
std::vector< SocketAddress_remoteAddresses
ChannelIndex _readIndex
std::vector< UInt8_socketReadBuffer
std::vector< UInt8_socketWriteBuffer
protected fields


std::vector< UInt8_selection
std::string _destination
std::set< Channel_disconnectedChannel
protected members


std::string _interface
Member


BuffersT _readBuffers
BuffersT _writeBuffers
BuffersT _zeroCopyBuffers
UInt32 _zeroCopyThreshold
FreeMemT _freeMem
BuffersT::iterator _currentReadBuffer
UInt32 _currentReadBufferPos
BuffersT::iterator _currentWriteBuffer
UInt32 _currentWriteBufferPos
bool _networkOrder

Private Types

typedef GroupSockConnection Inherited

Private Member Functions

 GroupMCastConnection (const GroupMCastConnection &source)
GroupMCastConnectionoperator= (const GroupMCastConnection &source)

Static Private Attributes

static members


static ConnectionType _type

Friends

class PointMCastConnection

Classes

struct  SocketBufferHeader


Detailed Description

Definition at line 62 of file OSGGroupMCastConnection.h.


Member Typedef Documentation

Reimplemented from osg::GroupSockConnection.

Definition at line 180 of file OSGGroupMCastConnection.h.

typedef Int32 osg::GroupConnection::ChannelIndex [protected, inherited]

Definition at line 122 of file OSGGroupConnection.h.

typedef Int32 osg::Connection::Channel [inherited]

Definition at line 69 of file OSGConnection.h.

typedef std::vector<MemoryBlock> osg::BinaryDataHandler::BuffersT [protected, inherited]

Definition at line 213 of file OSGBinaryDataHandler.h.

typedef std::list<MemoryHandle> osg::BinaryDataHandler::FreeMemT [protected, inherited]

Definition at line 214 of file OSGBinaryDataHandler.h.


Constructor & Destructor Documentation

GroupMCastConnection::GroupMCastConnection ( void   ) 

Constructor

Definition at line 71 of file OSGGroupMCastConnection.cpp.

References _free, _lock, _mcastSocket, _windowSize, osg::Socket::bind(), osg::Lock::get(), osg::Socket::getReadBufferSize(), osg::DgramSocket::open(), OSG_DGRAM_LEN, OSG_DGRAM_QUEUE_LEN, osg::osgMin(), osg::DgramQueue::put(), and osg::Socket::setReadBufferSize().

Referenced by create().

00071                                           :
00072     Inherited(),
00073     _sendQueueThread(NULL),
00074     _seqNumber(0),
00075     _initialized(false)
00076 {
00077     char lockName[256];
00078     sprintf(lockName,"GroupMCastConnection%p",this);
00079 
00080     // create locks
00081     _lock     = Lock::get(lockName);
00082     // fill dgramqueue
00083     for(UInt32 dI = 0 ; dI < OSG_DGRAM_QUEUE_LEN ; ++dI)
00084         _free.put(new Dgram());
00085     // prepare mcast socket
00086     _mcastSocket.open();
00087     _mcastSocket.bind();
00088     _mcastSocket.setReadBufferSize(262144);
00089     // set window size
00090     _windowSize = _mcastSocket.getReadBufferSize()/(OSG_DGRAM_LEN) - 1;
00091     _windowSize = osgMin((UInt32)13,_windowSize);
00092 }

GroupMCastConnection::~GroupMCastConnection ( void   )  [virtual]

Destructor

Definition at line 96 of file OSGGroupMCastConnection.cpp.

References _free, _lock, _mcastSocket, _queue, _sendQueueThread, _sendQueueThreadStop, osg::Lock::aquire(), osg::DgramSocket::close(), osg::DgramQueue::empty(), osg::DgramQueue::get(), osg::BaseThread::join(), osg::DgramQueue::put(), osg::Lock::release(), and osg::Dgram::setSize().

00097 {
00098     Dgram *dgram;
00099     _sendQueueThreadStop = true;
00100 
00101     // get free dgram
00102     _lock->aquire();
00103     dgram = _free.get(_lock);
00104     dgram->setSize(0);
00105     _queue.put(dgram);
00106     _lock->release();
00107     // wait for stop
00108     if(_sendQueueThread)
00109         BaseThread::join(_sendQueueThread);    
00110     // close socket
00111     _mcastSocket.close();
00112     // free queues
00113     _lock->aquire();
00114     while(!_free.empty())
00115         delete _free.get(_lock);
00116     while(!_queue.empty())
00117         delete _queue.get(_lock);
00118     _lock->release();
00119 }

osg::GroupMCastConnection::GroupMCastConnection ( const GroupMCastConnection source  )  [private]


Member Function Documentation

const ConnectionType * GroupMCastConnection::getType ( void   )  [virtual]

get connection type

Reimplemented from osg::GroupSockConnection.

Definition at line 123 of file OSGGroupMCastConnection.cpp.

References _type.

00124 {
00125     return &_type;
00126 }

GroupConnection::Channel GroupMCastConnection::connectPoint ( const std::string &  address,
Time  timeout = -1 
) [virtual]

connect to the given point. If timeout is reached, -1 is returned

Reimplemented from osg::GroupSockConnection.

Definition at line 134 of file OSGGroupMCastConnection.cpp.

References osg::GroupSockConnection::connectPoint().

00137 {
00138     Channel channel = Inherited::connectPoint(address,timeout);
00139     return channel;
00140 }

void GroupMCastConnection::disconnect ( Channel  channel  )  [virtual]

disconnect the given channel

Reimplemented from osg::GroupSockConnection.

Definition at line 144 of file OSGGroupMCastConnection.cpp.

References osg::GroupConnection::_destination, _lock, osg::Lock::aquire(), osg::GroupConnection::channelToIndex(), osg::GroupSockConnection::disconnect(), and osg::Lock::release().

00145 {
00146     Inherited::disconnect(channel);
00147     _lock->aquire();
00148     _destination.erase(_destination.begin()+channelToIndex(channel));
00149     _lock->release();
00150 }

GroupConnection::Channel GroupMCastConnection::acceptPoint ( Time  timeout = -1  )  [virtual]

accept an icomming point connection. If timeout is reached, -1 is returned. If timeout is -1 then wait without timeout

Reimplemented from osg::GroupSockConnection.

Definition at line 155 of file OSGGroupMCastConnection.cpp.

References osg::GroupSockConnection::acceptPoint().

00156 {
00157     Connection::Channel channel = Inherited::acceptPoint(timeout);
00158     return channel;
00159 }

void GroupMCastConnection::setParams ( const std::string &  params  )  [virtual]

parse the params string.

Reimplemented from osg::GroupSockConnection.

Definition at line 163 of file OSGGroupMCastConnection.cpp.

References _mcastSocket, FINFO, osg::GroupSockConnection::setParams(), and osg::DgramSocket::setTTL().

00164 {
00165     if(params.empty())
00166         return;
00167 
00168     Inherited::setParams(params);
00169 
00170     std::string option = "TTL=";
00171     std::string::size_type i = 0;
00172     if((i=params.find(option)) != std::string::npos)
00173     {
00174         std::string str = params.substr(i + option.size());
00175 
00176         std::stringstream ss;
00177         std::string::size_type j = 0;
00178         while(j < str.length() && str[j] != ',' && isdigit(str[j]))
00179         {
00180             ss << str[j++];
00181         }
00182         UInt32 ttl;
00183         ss >> ttl;
00184         if(ttl > 255)
00185             ttl = 255;
00186         _mcastSocket.setTTL((unsigned char) ttl);
00187         FINFO(("GroupMCastConnection::setParams : setting ttl to %u.\n", ttl));
00188     }
00189 }

ConnectionType GroupMCastConnection::_type & GroupMCastConnection::create ( void   )  [static]

Reimplemented from osg::GroupSockConnection.

Definition at line 216 of file OSGGroupMCastConnection.cpp.

References GroupMCastConnection().

00217 {
00218     return new GroupMCastConnection();
00219 }

void GroupMCastConnection::write ( MemoryHandle  mem,
UInt32  size 
) [protected, virtual]

Write data to all destinations

Parameters:
mem Pointer to data buffer
size Size of bytes to write

Reimplemented from osg::GroupSockConnection.

Definition at line 231 of file OSGGroupMCastConnection.cpp.

References _free, _initialized, _lock, _mcastAddress, _mcastSocket, _queue, _sendQueueThread, _sendQueueThreadRunning, _seqNumber, osg::Lock::aquire(), osg::DgramQueue::get(), osg::Dgram::getBuffer(), osg::Dgram::getBufferSize(), osg::Dgram::getCapacity(), osg::Dgram::getData(), osg::Dgram::getSize(), initialize(), osg::BaseThread::join(), osg::osgMin(), osg::DgramQueue::put(), osg::Lock::release(), osg::DgramSocket::sendTo(), osg::Dgram::setEarlySend(), osg::Dgram::setId(), osg::Dgram::setSize(), and osg::DgramQueue::waiting().

Referenced by writeBuffer().

00232 {
00233     Dgram  *dgram  = NULL;;
00234     UInt32  pos    = 0;
00235     char   *buffer = (char*)mem;
00236 
00237     if(!_initialized)
00238         initialize();
00239 
00240     while(size)
00241     {
00242         // get free dgram
00243         _lock->aquire();
00244         dgram = _free.get(_lock);
00245         _lock->release();
00246         // fill with data
00247         dgram->setSize(osgMin(size,dgram->getCapacity()));
00248         memcpy(dgram->getData(),buffer+pos,dgram->getSize());
00249         // set sequence number
00250         dgram->setId( _seqNumber++ );
00251         // prepate next block
00252         size -= dgram->getSize();
00253         pos  += dgram->getSize();
00254         // put to write queue
00255         _lock->aquire();
00256         if(!_sendQueueThreadRunning)
00257         {
00258             _lock->release();
00259             BaseThread::join(_sendQueueThread);    
00260             throw WriteError("Channel closed");
00261         }
00262 #ifdef USE_EARLY_SEND
00263         if(_queue.waiting())
00264         {
00265             dgram->setEarlySend(true);
00266             _mcastSocket.sendTo(dgram->getBuffer(),
00267                                 dgram->getBufferSize(),
00268                                 _mcastAddress);
00269         }
00270 #endif
00271         _queue.put(dgram);
00272         _lock->release();
00273     }
00274 }

void GroupMCastConnection::writeBuffer ( void   )  [protected, virtual]

Write buffer

Write blocksize and data.

Reimplemented from osg::GroupSockConnection.

Definition at line 281 of file OSGGroupMCastConnection.cpp.

References write(), and osg::BinaryDataHandler::writeBufBegin().

00282 {
00283     UInt32       size   = writeBufBegin()->getDataSize();
00284     MemoryHandle buffer = writeBufBegin()->getMem();
00285 
00286     write(buffer,size);
00287 }

bool GroupMCastConnection::wait ( Time  timeout  )  throw (ReadError) [protected, virtual]

wait for signal

Reimplemented from osg::GroupSockConnection.

Definition at line 196 of file OSGGroupMCastConnection.cpp.

References osg::GroupSockConnection::wait().

00197 {
00198     // todo
00199     return Inherited::wait(timeout);
00200 }

void GroupMCastConnection::signal ( void   )  throw (WriteError) [protected, virtual]

send signal

Reimplemented from osg::GroupSockConnection.

Definition at line 204 of file OSGGroupMCastConnection.cpp.

References osg::BinaryDataHandler::flush(), and osg::BinaryDataHandler::putValue().

00205 {
00206     UInt32 tag=314156;
00207     putValue(tag);
00208     flush();
00209 }

bool GroupMCastConnection::checkChannels ( void   )  [private]

check if all receivers are alive

Definition at line 294 of file OSGGroupMCastConnection.cpp.

References _lock, osg::GroupSockConnection::_sockets, osg::Lock::aquire(), FWARNING, osg::SocketSelection::isSetRead(), osg::Lock::release(), osg::SocketSelection::select(), osg::SocketSelection::setRead(), and osg::Exception::what().

Referenced by sendQueue().

00295 {
00296     SocketSelection selection;
00297     UInt32          index;
00298     bool            valid=true;
00299                     
00300     _lock->aquire();
00301     for(index = 0 ; index < _sockets.size() ; ++index)
00302         selection.setRead(_sockets[index]);
00303     if(selection.select(0))
00304     {
00305         UInt32 len;
00306         char   buffer;
00307         for(index = 0 ; index < _sockets.size() ; ++index)
00308         {
00309             if(selection.isSetRead(_sockets[index]))
00310             {
00311                 try
00312                 {
00313                     _sockets[index].send(&buffer,1);
00314                 }
00315                 catch(SocketException &e)
00316                 {
00317                     valid = false;
00318                     FWARNING(("Socket error:%s\n",e.what()))
00319                     break;
00320                 }
00321             }
00322         }
00323     }
00324     _lock->release();
00325     return valid;
00326 }

void GroupMCastConnection::sendQueueThread ( void *  arg  )  [static, private]

write thread

Definition at line 530 of file OSGGroupMCastConnection.cpp.

References _sendQueueThreadRunning, FFATAL, sendQueue(), and osg::Exception::what().

Referenced by initialize().

00531 {
00532     GroupMCastConnection *the = (GroupMCastConnection *)arg;
00533     try
00534     {
00535         the->sendQueue();
00536     }
00537     catch(SocketException &e)
00538     {
00539         FFATAL(( "Writer Proc crashed %s\n",e.what() ));
00540     }
00541     the->_sendQueueThreadRunning = false;
00542 }

bool GroupMCastConnection::sendQueue ( void   )  [private]

Send current write queue

Definition at line 330 of file OSGGroupMCastConnection.cpp.

References _free, _lock, _mcastAddress, _mcastSocket, _queue, _sendQueueThreadStop, _waitFor, _windowSize, osg::Lock::aquire(), checkChannels(), osg::DgramQueue::empty(), FDEBUG, osg::DgramQueue::get(), osg::Dgram::getBuffer(), osg::Dgram::getBufferCapacity(), osg::Dgram::getBufferSize(), osg::SocketAddress::getHost(), osg::Dgram::getId(), osg::SocketAddress::getPort(), osg::Dgram::getResponseAck(), osg::getSystemTime(), osg::Dgram::less(), osg::DgramQueue::put(), osg::DgramSocket::recvFrom(), osg::Lock::release(), osg::DgramSocket::sendTo(), osg::Dgram::setId(), osg::Dgram::setResponseSize(), osg::Dgram::setSize(), and osg::Socket::waitReadable().

Referenced by sendQueueThread().

00331 {
00332     std::vector<Dgram*>                   dgram;
00333     std::vector<std::set<SocketAddress> > missing;
00334     UInt32                  count    = 0;
00335     UInt32                  maxCount = _windowSize-1;
00336     UInt32                  ack  = 0;
00337     UInt32                  end  = 0;
00338     UInt32                  send = 0;
00339     UInt32                  channel;
00340     UInt32                  index;
00341     Dgram                   response;
00342     UInt32                  m;
00343     bool                    readable = false;
00344     Time                    waitStart = getSystemTime();
00345     Time                    lastAckTime=0;
00346     UInt32                  len;
00347     SocketAddress           fromAddress;
00348     Dgram                   ackRequest;
00349     const Time              ackTimeout = 0.01;
00350     UInt16                  sendId=0;
00351     UInt16                  lastNak=0;
00352     Time                    lastNakTime=0;
00353     bool                    stopAfterSend=false;
00354 
00355     // prepate buffers
00356     dgram.resize(_windowSize);
00357     missing.resize(_windowSize);
00358 
00359 #ifdef TEST_LOST_DGRAM_RATE
00360     srand48((int)getSystemTime());
00361 #endif
00362     do
00363     {
00364         // read new dgrams
00365         if(count < maxCount)
00366         {
00367             _lock->aquire();
00368             while(count < maxCount &&
00369                   (count == 0 || !_queue.empty()))
00370             {
00371                 dgram[end] = _queue.get(_lock);
00372                 // stop
00373                 if(!dgram[end]->getSize())
00374                 {
00375                     if(count)
00376                     {
00377                         // wait for ack of packages in window
00378                         stopAfterSend = true;
00379                         break;
00380                     }
00381                     else
00382                     {
00383                         // no packages in the window
00384                         _lock->release();
00385                         return true;
00386                     }
00387                 }
00388                 // insert to expected responses
00389                 for(index=0 ; index<_waitFor.size() ; ++index)
00390                     missing[end].insert(_waitFor[index]);
00391                 end = (end+1) % _windowSize;
00392                 if(!count)
00393                     lastAckTime = getSystemTime();
00394                 count++;
00395             }
00396             _lock->release();
00397         }
00398 
00399         // send all dgrams in current window
00400         for( ; send != end ; send = (send+1) % _windowSize)
00401         {
00402 #ifdef TEST_LOST_DGRAM_RATE
00403             if(drand48()>TEST_LOST_DGRAM_RATE)
00404 #endif
00405             {
00406                 if(!dgram[send]->getEarlySend())
00407                     _mcastSocket.sendTo(dgram[send]->getBuffer(),
00408                                         dgram[send]->getBufferSize(),
00409                                         _mcastAddress);
00410                 dgram[send]->setEarlySend(false);
00411             }
00412             sendId = dgram[send]->getId();
00413 //            printf("send dgram %d at id %d\n",send,dgram[send]->getId());
00414         }
00415 
00416         // loop while
00417         // window is full and nothing to send or
00418         // queue is empty
00419         // or there is something to read
00420         while(count &&
00421               ( ( readable = _mcastSocket.waitReadable(0) ) ||
00422                 ( count == maxCount && send == end ) || 
00423                 ( getSystemTime() - lastAckTime > ackTimeout) ) )
00424         {
00425             if(!readable && !_mcastSocket.waitReadable(ackTimeout))
00426             {
00427 #if 0
00428                 printf("count %d\n",count);
00429                 printf("missing %d\n",missing[ack].size());
00430 
00431                 printf("readable %d\n",readable);
00432                 printf("send %d end %d\n",send,end);
00433                 printf("lastack %lf\n",getSystemTime() - lastAckTime);
00434 #endif
00435                 FDEBUG(("timeout count %d %d missing %d\n",count,sendId,missing[ack].size()))
00436 //                printf("%.10f timeout count %d %d missing %d\n",getSystemTime()-t1,count,sendId,missing[ack].size());
00437                     
00438                 ackRequest.setSize(0);
00439                 ackRequest.setId(sendId);
00440 
00441                 // send request over multicast
00442                 _mcastSocket.sendTo(ackRequest.getBuffer(),
00443                                     ackRequest.getBufferSize(),
00444                                     _mcastAddress);
00445 
00446                 // wait until next ack request                
00447                 _mcastSocket.waitReadable(0.05);
00448 
00449                 // check channels
00450                 if(getSystemTime() - lastAckTime > 0.5)
00451                 {
00452                     if(!checkChannels())
00453                         return false;
00454                 }
00455                 if(_sendQueueThreadStop && 
00456                    getSystemTime() - lastAckTime > 1)
00457                     // linger max 1 sec after close
00458                     break;
00459                 else
00460                     // retry wait
00461                     continue;
00462             }
00463 
00464             // read response
00465             len = _mcastSocket.recvFrom(response.getBuffer(),
00466                                         response.getBufferCapacity(),
00467                                         fromAddress);
00468             lastAckTime = getSystemTime();
00469 
00470             // ignore response with wrong len
00471             response.setResponseSize();
00472             if(len != response.getBufferSize())
00473             {
00474                 FDEBUG(("Wrong response len %d\n",len))
00475                     continue;
00476             }
00477 
00478             // old ack ?
00479             if(!Dgram::less(response.getId(),dgram[ack]->getId()))
00480             {
00481                 // first ack for this dgram from this receiver
00482                 if(response.getResponseAck() == true)
00483                 {
00484 //                    printf("Ack %d from %s:%d\n",response.getId(),fromAddress.getHost().c_str(),fromAddress.getPort());
00485                     for(m = ack ; 
00486                         dgram[m]->getId() != response.getId() ;
00487                         m=(m+1) % _windowSize)
00488                         missing[m].erase(fromAddress);
00489                     missing[m].erase(fromAddress);
00490                 }
00491                 else
00492                 {
00493                     if(response.getId() == lastNak &&
00494                        getSystemTime() - lastNakTime < 0.02)
00495                         continue;
00496                     lastNak = response.getId();
00497                     lastNakTime = getSystemTime();
00498                     FDEBUG(("Nack %d from %s:%d\n",response.getId(),fromAddress.getHost().c_str(),fromAddress.getPort()));
00499 //                    printf("Nack %d from %s:%d\n",response.getId(),fromAddress.getHost().c_str(),fromAddress.getPort());
00500                     // retransmit
00501                     for(m = ack ; 
00502                         m != send && dgram[m]->getId() != response.getId() ; 
00503                         m = (m+1) % _windowSize);
00504                     send = m;
00505                 }
00506             }
00507 
00508             // free acknolaged packes
00509             if(missing[ack].empty())
00510             {
00511 //                printf("ack %d\n",dgram[ack]->getId());
00512                 _lock->aquire();
00513                 while(count && missing[ack].empty())
00514                 {
00515                     _free.put(dgram[ack]);
00516                     ack = (ack+1) % _windowSize;
00517                     count--;
00518                 }
00519                 _lock->release();
00520             }
00521         }
00522     }
00523     while(!stopAfterSend || send != end);
00524 
00525     return true;
00526 }

void GroupMCastConnection::initialize ( void   )  [private]

initialize connection. Connect to all points

Definition at line 546 of file OSGGroupMCastConnection.cpp.

References osg::GroupConnection::_destination, _initialized, _mcastAddress, _mcastSocket, _receiver, osg::GroupSockConnection::_remoteAddresses, _sendQueueThread, _sendQueueThreadRunning, _sendQueueThreadStop, _seqNumber, osg::GroupSockConnection::_sockets, _waitFor, osg::BinaryMessage::clear(), osg::BaseThread::get(), osg::Socket::getAddress(), osg::GroupConnection::getDestination(), osg::SocketAddress::getHost(), osg::Connection::getInterface(), osg::SocketAddress::getPort(), osg::BinaryMessage::getUInt32(), osg::osgMin(), osg::osgsqrt(), osg::BinaryMessage::putString(), osg::BinaryMessage::putUInt32(), osg::BaseThread::runFunction(), sendQueueThread(), osg::SocketAddress::setHost(), osg::DgramSocket::setMCastInterface(), osg::SocketAddress::setPort(), and SINFO.

Referenced by write().

00547 {
00548     std::string   group = "239.33.42.32";
00549 //    std::string group = "146.140.32.7";
00550 //    std::string group = "146.140.32.255";
00551     int           port = 15356;
00552     int           pos  = _destination.find(':');
00553     int           clientPort;
00554     std::string   clientHost;
00555     UInt32        index;
00556     UInt32        len;
00557     UInt32        ackNum = (UInt32) osgsqrt(Real32(_sockets.size()));
00558     UInt32        numSource;
00559     UInt32        sendTo;
00560     BinaryMessage message;
00561     char          threadName[256];
00562 
00563     sprintf(threadName,"GroupMCastConnection%p",this);
00564 
00565     if(!getDestination().empty())
00566         group = getDestination();
00567         
00568     if(_sockets.size()<=16)
00569         ackNum = 1;
00570 
00571     if(pos>=0)
00572     {
00573         group = std::string(_destination,0,pos);
00574         port  = atoi(std::string(_destination,pos+1,std::string::npos).c_str());
00575     }
00576     else
00577     {
00578         if(_destination.size())
00579             group = _destination;
00580     }
00581     _mcastAddress.setHost(group);
00582     _mcastAddress.setPort(port );
00583 
00584     // set multicast interface, if given
00585     if(!getInterface().empty())
00586         _mcastSocket.setMCastInterface(
00587             SocketAddress(getInterface().c_str()));
00588 
00589     for(index = 0 ; index < _sockets.size() ; ++index)
00590     {
00591         message.clear();
00592         // tell the point connection the multicast address
00593         message.putString(_mcastAddress.getHost());
00594         message.putUInt32(_mcastAddress.getPort());
00595         // tell the current seq number
00596         message.putUInt32(_seqNumber);
00597         // tell the point from wich port requests are comming
00598         message.putUInt32(_mcastSocket.getAddress().getPort());
00599         // send the message
00600         _sockets[index].send(message);
00601         
00602         // receive destination address
00603         message.clear();
00604         len = _sockets[index].recv(message);
00605         if(len == 0)
00606             throw ReadError("Channel closed\n");
00607         clientHost = _remoteAddresses[index].getHost();
00608         clientPort = message.getUInt32();
00609         SINFO << "Server:" << clientHost 
00610               << " Port:" << clientPort << std::endl;
00611         _receiver.push_back(SocketAddress(clientHost.c_str(),clientPort));
00612     }
00613     for(index = 0 ; index < _sockets.size() ; ++index)
00614     {
00615         message.clear();
00616         // tell receivers, whom to report acks
00617         if((index % ackNum) == 0)
00618         {
00619             _waitFor.push_back(_receiver[index]);
00620             numSource = osgMin( ackNum-1, (UInt32) _sockets.size()-index-1 );
00621             message.putUInt32(numSource);
00622             for(UInt32 r = index+1 ; r < index+1+numSource ; ++r)
00623             {
00624                 message.putString(_receiver[r].getHost());
00625                 message.putUInt32(_receiver[r].getPort());
00626             }
00627             message.putString("");
00628             message.putUInt32(_mcastSocket.getAddress().getPort());
00629         }
00630         else
00631         {
00632             sendTo = index - (index % ackNum);
00633             message.putUInt32(0);
00634             message.putString(_receiver[sendTo].getHost());
00635             message.putUInt32(_receiver[sendTo].getPort());
00636         }
00637         // send the message
00638         _sockets[index].send(message);
00639     }
00640 
00641     // start write thread
00642     _sendQueueThread=BaseThread::get(threadName);
00643     _sendQueueThreadRunning = true;
00644     _sendQueueThreadStop    = false;
00645     _sendQueueThread->runFunction( sendQueueThread, (void *) (this) );
00646     _initialized = true;
00647 }

GroupMCastConnection& osg::GroupMCastConnection::operator= ( const GroupMCastConnection source  )  [private]

std::string GroupSockConnection::bind ( const std::string &  address  )  [virtual, inherited]

bind the connection to an network interface. The address is returned, on wich the port could be connected. The interface is determined by the connection interface filed and the address parameter. Address can be empty, wich means to use a free port or address can contain a port number.

Implements osg::Connection.

Definition at line 176 of file OSGGroupSockConnection.cpp.

References osg::GroupSockConnection::_acceptSocket, osg::Socket::bind(), osg::Socket::getAddress(), osg::SocketAddress::getHost(), osg::Connection::getInterface(), osg::SocketAddress::getPort(), osg::Socket::listen(), osg::osgGetHostname(), osg::Socket::setReusePort(), and SINFO.

00177 {
00178     int         port=0;
00179     char        localhost[256];
00180     char        host[256];
00181     char        portStr[256];
00182     std::string interf;
00183     std::string boundedAddress;
00184 
00185     // get local host name
00186     osgGetHostname(localhost,255);
00187 
00188     if(!getInterface().empty())
00189         interf = getInterface();
00190     else
00191         interf = localhost;
00192     // parse address
00193     if(!address.empty())
00194         if(sscanf(address.c_str(),"%*[^:]:%d",&port) != 1)
00195             if(sscanf(address.c_str(),":%d",&port) != 1)
00196                 port = 0;
00197     // bind port
00198     _acceptSocket.setReusePort(true);
00199     _acceptSocket.bind(SocketAddress(interf.c_str(),port));
00200     SINFO << "Connection bound to "
00201           << _acceptSocket.getAddress().getHost() << ":"
00202           << _acceptSocket.getAddress().getPort() << std::endl;
00203     _acceptSocket.listen();
00204     // create address
00205     sprintf(portStr,"%d",_acceptSocket.getAddress().getPort());
00206     return interf + ":" + portStr;
00207 }

Connection::Channel GroupSockConnection::selectChannel ( Time  timeout = -1  )  throw (ReadError) [virtual, inherited]

select the next channel for reading. If timeout is not -1 then -1 is returned if timeout is reached

Implements osg::Connection.

Definition at line 254 of file OSGGroupSockConnection.cpp.

References osg::BinaryDataHandler::_currentReadBuffer, osg::GroupSockConnection::_readIndex, osg::GroupConnection::_selection, osg::GroupSockConnection::_sockets, osg::BinaryDataHandler::_zeroCopyThreshold, FFATAL, osg::GroupConnection::indexToChannel(), osg::SocketSelection::isSetRead(), osg::BinaryDataHandler::readBufEnd(), osg::SocketSelection::select(), osg::SocketSelection::setRead(), and osg::Exception::what().

00256 {
00257     Int32 maxnread=0,nread;
00258     ChannelIndex index;
00259     SocketSelection selection,result;
00260 
00261     // if there is data in the read buffer, return current channel
00262     if(_zeroCopyThreshold != 1 &&
00263        _currentReadBuffer != readBufEnd())
00264     {
00265         FFATAL(("Channel change ignores data in current buffer"))
00266         return indexToChannel(_readIndex);
00267     }    
00268 
00269     if(_selection[_readIndex] &&
00270        _sockets[_readIndex].getAvailable())
00271     {
00272         return indexToChannel(_readIndex);;
00273     }
00274 
00275     // wait for first socket to deliver data
00276     for(index = 0 ; index < _sockets.size() ; ++index)
00277     {
00278         if(_selection[index])
00279             selection.setRead(_sockets[index]);
00280     }
00281     
00282     try 
00283     {
00284         // select ok ?
00285         if(!selection.select(timeout,result))
00286             return -1;
00287 
00288         // use socket with most data
00289         for(index = 0 ; index < _sockets.size() ; ++index)
00290         {
00291             if(result.isSetRead(_sockets[index]))
00292             {
00293                 nread=_sockets[index].getAvailable();
00294                 if(maxnread < nread)
00295                 {
00296                     maxnread = nread;
00297                     _readIndex=index;
00298                 }
00299             }
00300         }
00301     }
00302     catch(SocketException &e)
00303     {
00304         throw ReadError(e.what());
00305     }
00306 
00307     // return channel id
00308     return indexToChannel(_readIndex);
00309 }

void GroupSockConnection::read ( MemoryHandle  mem,
UInt32  size 
) [protected, virtual, inherited]

Read data into given memory

Read data form the current read socket. The read socket is that socket, that was selectet in selectChannel.

Reimplemented from osg::BinaryDataHandler.

Definition at line 397 of file OSGGroupSockConnection.cpp.

References osg::GroupSockConnection::_readIndex, and osg::GroupSockConnection::_sockets.

00398 {
00399     int len;
00400 
00401     // read data
00402     len=_sockets[_readIndex].recv(mem,size);
00403     if(len==0)
00404     {
00405 //        throw ChannelClosed(indexToChannel(_readIndex));
00406         throw ReadError("Channel closed");
00407     }
00408 } 

void GroupSockConnection::readBuffer ( void   )  [protected, virtual, inherited]

Read next data block

The stream connection uses only BinaryDataHandler buffer. If more then one buffer is present, then this methode must be changed!

Reimplemented from osg::BinaryDataHandler.

Definition at line 417 of file OSGGroupSockConnection.cpp.

References osg::GroupSockConnection::_readIndex, osg::GroupSockConnection::_socketReadBuffer, osg::GroupSockConnection::_sockets, osg::osgntohl(), and osg::BinaryDataHandler::readBufBegin().

00418 {
00419     int size;
00420     int len;
00421 
00422     // read buffer header
00423     len=_sockets[_readIndex].recv(&_socketReadBuffer[0],sizeof(SocketBufferHeader));
00424     if(len==0)
00425         throw ReadError("Channel closed");
00426     // read remaining data
00427     size=osgntohl(((SocketBufferHeader*)&_socketReadBuffer[0])->size);
00428     len=_sockets[_readIndex].recv(&_socketReadBuffer[sizeof(SocketBufferHeader)],
00429                          size);
00430     if(len==0)
00431         throw ReadError("Channel closed");
00432     readBufBegin()->setDataSize(size);
00433 }    

UInt32 GroupConnection::getChannelCount ( void   )  [inherited]

void GroupConnection::addSelection ( Channel  channel  )  [inherited]

mark the given channel as selectable

Definition at line 85 of file OSGGroupConnection.cpp.

References osg::GroupConnection::_channelToIndex, and osg::GroupConnection::_selection.

00086 {
00087     ChannelIndex index = _channelToIndex[channel];
00088     _selection[index] = true;
00089 }

void GroupConnection::subSelection ( Channel  channel  )  [inherited]

void GroupConnection::clearSelection ( void   )  [inherited]

mark all channels as selectable

Definition at line 101 of file OSGGroupConnection.cpp.

References osg::GroupConnection::_selection.

00102 {
00103     std::fill(_selection.begin(),_selection.end(),false);
00104 }

void GroupConnection::resetSelection ( void   )  [inherited]

UInt32 GroupConnection::getSelectionCount ( void   )  [inherited]

get number of sockets in the selection

Definition at line 115 of file OSGGroupConnection.cpp.

References osg::GroupConnection::_selection.

00116 {
00117     UInt32 selectionCount=0;
00118     std::vector<UInt8>::iterator i;
00119     for(i=_selection.begin() ; i!=_selection.end() ; ++i)
00120         if(*i)
00121             selectionCount++;
00122     return selectionCount;
00123 }

void GroupConnection::setDestination ( const std::string &  destination  )  [inherited]

set destination address used to broadcast or multicast to all connected points. On Multicast connections this could be 224.22.22.1 or something like that.

Definition at line 132 of file OSGGroupConnection.cpp.

References osg::GroupConnection::_destination.

Referenced by osg::ClusterWindow::init().

00133 {
00134     _destination = destination;
00135 }

std::string GroupConnection::getDestination ( void   )  [inherited]

get destination address

Definition at line 139 of file OSGGroupConnection.cpp.

References osg::GroupConnection::_destination.

Referenced by initialize().

00140 {
00141     return _destination;
00142 }

Connection::Channel GroupConnection::newChannelIndex ( ChannelIndex  index  )  [protected, inherited]

create a new channel

Definition at line 149 of file OSGGroupConnection.cpp.

References osg::GroupConnection::_channelToIndex, osg::GroupConnection::_indexToChannel, osg::GroupConnection::_reuseChannel, and osg::GroupConnection::_selection.

Referenced by osg::GroupSockConnection::acceptPoint(), and osg::GroupSockConnection::connectPoint().

00150 {
00151     Channel channel;
00152     if(_reuseChannel.begin() != _reuseChannel.end())
00153     {
00154         channel = *(_reuseChannel.begin());
00155         _reuseChannel.pop_front();
00156     }
00157     else
00158     {
00159         channel = _channelToIndex.size();
00160         _channelToIndex.resize(channel+1);
00161     }
00162     if(index >= _indexToChannel.size())
00163         _indexToChannel.resize(index+1);
00164     if(index >= _selection.size())
00165         _selection.resize(index+1);
00166     // enable selection
00167     _selection[index] = true;
00168     // set index to channel mapping
00169     _indexToChannel[index] = channel;
00170     // set channel to index mapping
00171     _channelToIndex[channel] = index;
00172     return channel;
00173 }

void GroupConnection::delChannelIndex ( ChannelIndex  index  )  [protected, inherited]

remove a channel.

Definition at line 177 of file OSGGroupConnection.cpp.

References osg::GroupConnection::_indexToChannel, osg::GroupConnection::_reuseChannel, and osg::GroupConnection::_selection.

Referenced by osg::GroupSockConnection::disconnect().

00178 {
00179     Channel channel = _indexToChannel[index];
00180     // erase from indexed arrays
00181     _selection     .erase(_selection.begin()      + index);
00182     _indexToChannel.erase(_indexToChannel.begin() + index);
00183     // move to reuse
00184     _reuseChannel.push_back(channel);
00185 }

GroupConnection::ChannelIndex GroupConnection::channelToIndex ( Channel  channel  )  const [protected, inherited]

Definition at line 190 of file OSGGroupConnection.cpp.

References osg::GroupConnection::_channelToIndex.

Referenced by osg::GroupSockConnection::disconnect(), and disconnect().

00191 {
00192     return _channelToIndex[channel];
00193 }

Connection::Channel GroupConnection::indexToChannel ( ChannelIndex  index  )  const [protected, inherited]

Definition at line 195 of file OSGGroupConnection.cpp.

References osg::GroupConnection::_indexToChannel.

Referenced by osg::GroupSockConnection::selectChannel().

00196 {
00197     return _indexToChannel[index];
00198 }

const std::string & Connection::getInterface ( void   )  [inherited]

void Connection::setInterface ( const std::string &  interf  )  [inherited]

set network interface

Definition at line 105 of file OSGConnection.cpp.

References osg::Connection::_interface.

Referenced by osg::ClusterServer::acceptClient(), and osg::ClusterWindow::init().

00106 {
00107     _interface = interf;
00108 }

void BinaryDataHandler::put ( void const *  src,
UInt32  size 
) [inherited]

Definition at line 83 of file OSGBinaryDataHandler.cpp.

References osg::BinaryDataHandler::_currentWriteBuffer, osg::BinaryDataHandler::_currentWriteBufferPos, osg::BinaryDataHandler::_zeroCopyBuffers, osg::BinaryDataHandler::_zeroCopyThreshold, osg::osgMin(), osg::BinaryDataHandler::pushBuffer(), osg::BinaryDataHandler::write(), and osg::BinaryDataHandler::writeBufEnd().

Referenced by osg::BinaryDataHandler::putAndFree(), osg::BinaryDataHandler::putValue(), osg::BinaryDataHandler::putValues(), and osg::ClusterViewBuffer::send().

00084 {
00085     UInt8 const *data = static_cast<UInt8 const *>(src);
00086 
00087     if(_zeroCopyThreshold && size >= _zeroCopyThreshold)
00088     {
00089         if(_zeroCopyThreshold == 1)
00090         {
00091             write(const_cast<MemoryHandle>(data), size);
00092         }
00093         else
00094         {
00095             UInt8 tag = 1;
00096 
00097             // we have to write a tag, to indicate the membership
00098             // of this zero copy block to the current data block
00099             put(&tag, sizeof(tag));
00100 
00101             _zeroCopyBuffers.push_back(
00102                 MemoryBlock(const_cast<MemoryHandle>(data), size, size));
00103         }
00104     }
00105     else
00106     {
00107         UInt32 copySize;
00108 
00109         while(size != 0)
00110         {
00111             if(_currentWriteBuffer == writeBufEnd())
00112             {
00113                 pushBuffer();
00114             }
00115 
00116             copySize = osgMin((_currentWriteBuffer->getSize() -
00117                                _currentWriteBufferPos),
00118                               size);
00119 
00120             memcpy(_currentWriteBuffer->getMem() + _currentWriteBufferPos,
00121                     data,
00122                     copySize);
00123 
00124              size                  -= copySize;
00125             _currentWriteBufferPos += copySize;
00126              data                  += copySize;
00127 
00128             // skip to next buffer if current buffer is full
00129             if(_currentWriteBufferPos == _currentWriteBuffer->getSize())
00130             {
00131                 _currentWriteBuffer->setDataSize(_currentWriteBufferPos);
00132                 _currentWriteBuffer++;
00133                 _currentWriteBufferPos = 0;
00134             }
00135         }
00136     }
00137 }

void BinaryDataHandler::putAndFree ( MemoryHandle  src,
UInt32  size 
) [inherited]

Put data from dynamic allocated block The caller doesn't know, when the block will be written. So we are responsible for freeing this block.

Definition at line 144 of file OSGBinaryDataHandler.cpp.

References osg::BinaryDataHandler::_freeMem, osg::BinaryDataHandler::_zeroCopyThreshold, and osg::BinaryDataHandler::put().

00145 {
00146     put(src, size);
00147 
00148     if(_zeroCopyThreshold && size > _zeroCopyThreshold)
00149     {
00150         _freeMem.push_back(src);
00151     }
00152     else
00153     {
00154         delete [] src;
00155     }
00156 }

void osg::BinaryDataHandler::putValue ( const bool &  value  )  [inline, inherited]

Definition at line 60 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::put().

Referenced by osg::SortFirstWindow::clientInit(), osg::ClusterNetwork::connectAllGroupToPoint(), osg::ClusterNetwork::connectAllPointToPoint(), osg::osg::FieldDataTraits2< bool >::copyToBin(), osg::RenderNode::copyToBin(), osg::ParticleBSPTree::copyToBin(), osg::MField< FieldTypeT, fieldNameSpace >::copyToBin(), osg::FieldTraitsIntegralRecurseMapper< uint64_t >::copyToBin(), osg::FieldTraitsRecurseBase1< GLXContext >::copyToBin(), osg::FieldTraitsRecurseBase< osg::NodePtr >::copyToBin(), osg::osg::FieldTraitsRecurseMapper< FieldContainerPtr, false >::copyToBin(), osg::osg::FieldDataTraits< Plane >::copyToBin(), osg::osg::FieldDataTraits1< GLenum >::copyToBin(), osg::osg::FieldDataTraits1< BitVector >::copyToBin(), osg::osg::FieldDataTraits< DynamicVolume >::copyToBin(), osg::osg::FieldDataTraits1< Time >::copyToBin(), osg::osg::FieldDataTraits< std::string >::copyToBin(), osg::osg::FieldTraitsRecurseMapper< AttachmentMap, false >::copyToBin(), osg::BINWriter::doWriteIndexedFC(), osg::RemoteAspect::handleFCMapping(), osg::ClusterWindow::init(), osg::BinaryDataHandler::putValue(), osg::BinaryDataHandler::putValues(), osg::ClusterViewBuffer::send(), osg::RemoteAspect::sendSync(), osg::SortFirstWindow::serverInit(), signal(), osg::ClusterServer::start(), and osg::BINWriter::writeFileHeader().

00061 {
00062     // on Mac OS X a bool is four bytes long on all other
00063     // platfroms it is one byte long. So we write now always
00064     // one byte out.
00065     // put(&value, sizeof(bool));
00066     UInt8 temp = (UInt8) value;
00067     put(&temp, sizeof(UInt8));
00068 }

void osg::BinaryDataHandler::putValue ( const UInt8 value  )  [inline, inherited]

Definition at line 71 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::put().

00072 {
00073     put(&value, sizeof(UInt8));
00074 }

void osg::BinaryDataHandler::putValue ( const UInt16 value  )  [inline, inherited]

Definition at line 77 of file OSGBinaryDataHandler.inl.

References osg::osghtons(), and osg::BinaryDataHandler::put().

00078 {
00079     UInt16 z = osghtons(value);
00080 
00081     put(&z, sizeof(UInt16));
00082 }

void osg::BinaryDataHandler::putValue ( const UInt32 value  )  [inline, inherited]

Definition at line 85 of file OSGBinaryDataHandler.inl.

References osg::osghtonl(), and osg::BinaryDataHandler::put().

00086 {
00087     UInt32 z = osghtonl(value);
00088 
00089     put(&z, sizeof(UInt32));
00090 }

void osg::BinaryDataHandler::putValue ( const UInt64 value  )  [inline, inherited]

Definition at line 93 of file OSGBinaryDataHandler.inl.

References osg::osghtonll(), and osg::BinaryDataHandler::put().

00094 {
00095     UInt64 z = osghtonll(value);
00096 
00097     put(&z, sizeof(UInt64));
00098 }

void osg::BinaryDataHandler::putValue ( const Int8 value  )  [inline, inherited]

Definition at line 101 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::put().

00102 {
00103     put(&value, sizeof(Int8));
00104 }

void osg::BinaryDataHandler::putValue ( const Int16 value  )  [inline, inherited]

Definition at line 107 of file OSGBinaryDataHandler.inl.

References osg::osghtons(), and osg::BinaryDataHandler::put().

00108 {
00109     Int16 z = osghtons(value);
00110 
00111     put(&z, sizeof(Int16));
00112 }

void osg::BinaryDataHandler::putValue ( const Int32 value  )  [inline, inherited]

Definition at line 115 of file OSGBinaryDataHandler.inl.

References osg::osghtonl(), and osg::BinaryDataHandler::put().

00116 {
00117     Int32 z = osghtonl(value);
00118 
00119     put(&z, sizeof(Int32));
00120 }

void osg::BinaryDataHandler::putValue ( const Int64 value  )  [inline, inherited]

Definition at line 123 of file OSGBinaryDataHandler.inl.

References osg::osghtonll(), and osg::BinaryDataHandler::put().

00124 {
00125     Int64 z = osghtonll(value);
00126     put(&z, sizeof(Int64));
00127 
00128 }

void osg::BinaryDataHandler::putValue ( const Real16 value  )  [inline, inherited]

Definition at line 131 of file OSGBinaryDataHandler.inl.

References osg::Real16::bits(), osg::osghtons(), and osg::BinaryDataHandler::put().

00132 {
00133     UInt16 v = osghtons(value.bits());
00134 
00135     put(&v, sizeof(Real16));
00136 }

void osg::BinaryDataHandler::putValue ( const Real32 value  )  [inline, inherited]

Definition at line 139 of file OSGBinaryDataHandler.inl.

References osg::osghtonl(), and osg::BinaryDataHandler::put().

00140 {
00141     UInt32 v = osghtonl( *((const UInt32 *)(&value)) );
00142 
00143     put(&v, sizeof(Real32));
00144 }

void osg::BinaryDataHandler::putValue ( const Real64 value  )  [inline, inherited]

Definition at line 147 of file OSGBinaryDataHandler.inl.

References osg::osghtonll(), and osg::BinaryDataHandler::put().

00148 {
00149     UInt64 v = osghtonll( *((const UInt64 *)(&value)) );
00150 
00151     put(&v, sizeof(Real64));
00152 }

void osg::BinaryDataHandler::putValue ( const Real128 value  )  [inline, inherited]

Definition at line 155 of file OSGBinaryDataHandler.inl.

References osg::osghtonll(), and osg::BinaryDataHandler::put().

00156 {
00157     UInt64 v = osghtonll( *( (const UInt64 *)(&value)) );
00158     UInt64 w = osghtonll( *(((const UInt64 *)(&value)) + 1) );
00159 
00160 #if BYTE_ORDER == LITTLE_ENDIAN
00161     put(&w, sizeof(UInt64));
00162     put(&v, sizeof(UInt64));
00163 #else
00164     put(&v, sizeof(UInt64));
00165     put(&w, sizeof(UInt64));
00166 #endif
00167 }

void osg::BinaryDataHandler::putValue ( const std::string &  value  )  [inline, inherited]

Definition at line 170 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::put(), osg::BinaryDataHandler::putValue(), and osg::stringlen().

00171 {
00172     UInt32 len = stringlen(value.c_str()) + 1;
00173 
00174     putValue(len);
00175 
00176     if(len != 0)
00177     {
00178         put(value.c_str(), len);
00179     }
00180 }

void osg::BinaryDataHandler::putValues ( const bool *  value,
UInt32  size 
) [inline, inherited]

void osg::BinaryDataHandler::putValues ( const UInt8 value,
UInt32  size 
) [inline, inherited]

Definition at line 191 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::put().

00192 {
00193     put(value, size * sizeof(UInt8));
00194 }

void osg::BinaryDataHandler::putValues ( const UInt16 value,
UInt32  size 
) [inline, inherited]

Definition at line 197 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue().

00198 {
00199 #if BYTE_ORDER == LITTLE_ENDIAN
00200 
00201     if(_networkOrder == true)
00202     {
00203         for(UInt32 i = 0; i < size; ++i)
00204         {
00205             putValue(value[i]);
00206         }
00207     }
00208     else
00209 #endif
00210     {
00211         put(value, size * sizeof(UInt16));
00212     }
00213 }

void osg::BinaryDataHandler::putValues ( const UInt32 value,
UInt32  size 
) [inline, inherited]

Definition at line 216 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue().

00217 {
00218 #if BYTE_ORDER == LITTLE_ENDIAN
00219     if(_networkOrder == true)
00220     {
00221         for(UInt32 i = 0; i < size; ++i)
00222         {
00223             putValue(value[i]);
00224         }
00225     }
00226     else
00227 #endif
00228     {
00229         put(value, size * sizeof(UInt32));
00230     }
00231 }

void osg::BinaryDataHandler::putValues ( const UInt64 value,
UInt32  size 
) [inline, inherited]

Definition at line 234 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue().

00235 {
00236 #if BYTE_ORDER == LITTLE_ENDIAN
00237     if(_networkOrder == true)
00238     {
00239         for(UInt32 i = 0; i < size; ++i)
00240         {
00241             putValue(value[i]);
00242         }
00243     }
00244     else
00245 #endif
00246     {
00247         put(value, size * sizeof(UInt64));
00248     }
00249 }

void osg::BinaryDataHandler::putValues ( const Int8 value,
UInt32  size 
) [inline, inherited]

Definition at line 252 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue().

00253 {
00254 #if BYTE_ORDER == LITTLE_ENDIAN
00255     if(_networkOrder == true)
00256     {
00257         for(UInt32 i = 0; i < size; ++i)
00258         {
00259             putValue(value[i]);
00260         }
00261     }
00262     else
00263 #endif
00264     {
00265         put(value, size * sizeof(Int8));
00266     }
00267 }

void osg::BinaryDataHandler::putValues ( const Int16 value,
UInt32  size 
) [inline, inherited]

Definition at line 270 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue().

00271 {
00272 #if BYTE_ORDER == LITTLE_ENDIAN
00273     if(_networkOrder == true)
00274     {
00275         for(UInt32 i = 0; i < size; ++i)
00276         {
00277             putValue(value[i]);
00278         }
00279     }
00280     else
00281 #endif
00282     {
00283         put(value, size * sizeof(Int16));
00284     }
00285 }

void osg::BinaryDataHandler::putValues ( const Int32 value,
UInt32  size 
) [inline, inherited]

Definition at line 288 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue().

00289 {
00290 #if BYTE_ORDER == LITTLE_ENDIAN
00291     if(_networkOrder == true)
00292     {
00293         for(UInt32 i = 0; i < size; ++i)
00294         {
00295             putValue(value[i]);
00296         }
00297     }
00298     else
00299 #endif
00300     {
00301         put(value, size * sizeof(Int32));
00302     }
00303 }

void osg::BinaryDataHandler::putValues ( const Int64 value,
UInt32  size 
) [inline, inherited]

Definition at line 306 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue().

00307 {
00308 #if BYTE_ORDER == LITTLE_ENDIAN
00309     if(_networkOrder == true)
00310     {
00311         for(UInt32 i = 0; i < size; ++i)
00312         {
00313             putValue(value[i]);
00314         }
00315     }
00316     else
00317 #endif
00318     {
00319         put(value, size * sizeof(Int64));
00320     }
00321 }

void osg::BinaryDataHandler::putValues ( const Real16 value,
UInt32  size 
) [inline, inherited]

Definition at line 324 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue().

00325 {
00326 #if BYTE_ORDER == LITTLE_ENDIAN
00327     if(_networkOrder == true)
00328     {
00329         for(UInt32 i = 0; i < size; ++i)
00330         {
00331             putValue(value[i]);
00332         }
00333     }
00334     else
00335 #endif
00336     {
00337         put(value, size * sizeof(Real16));
00338     }
00339 }

void osg::BinaryDataHandler::putValues ( const Real32 value,
UInt32  size 
) [inline, inherited]

Definition at line 342 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue().

00343 {
00344 #if BYTE_ORDER == LITTLE_ENDIAN
00345     if(_networkOrder == true)
00346     {
00347         for(UInt32 i = 0; i < size; ++i)
00348         {
00349             putValue(value[i]);
00350         }
00351     }
00352     else
00353 #endif
00354     {
00355         put(value, size * sizeof(Real32));
00356     }
00357 }

void osg::BinaryDataHandler::putValues ( const Real64 value,
UInt32  size 
) [inline, inherited]

Definition at line 360 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue().

00361 {
00362 #if BYTE_ORDER == LITTLE_ENDIAN
00363     if(_networkOrder == true)
00364     {
00365         for(UInt32 i = 0; i < size; ++i)
00366         {
00367             putValue(value[i]);
00368         }
00369     }
00370     else
00371 #endif
00372     {
00373         put(value, size * sizeof(Real64));
00374     }
00375 }

void osg::BinaryDataHandler::putValues ( const Real128 value,
UInt32  size 
) [inline, inherited]

Definition at line 378 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue().

00379 {
00380 #if BYTE_ORDER == LITTLE_ENDIAN
00381     if(_networkOrder == true)
00382     {
00383         for(UInt32 i = 0; i < size; ++i)
00384         {
00385             putValue(value[i]);
00386         }
00387     }
00388     else
00389 #endif
00390     {
00391         put(value, size * sizeof(Real128));
00392     }
00393 }

void osg::BinaryDataHandler::putValues ( const std::string *  value,
UInt32  size 
) [inline, inherited]

Definition at line 396 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::putValue().

00397 {
00398     for(UInt32 i = 0; i<size; ++i)
00399     {
00400         putValue(value[i]);    
00401     }
00402 }

void BinaryDataHandler::get ( void *  dst,
UInt32  size 
) [inherited]

Definition at line 161 of file OSGBinaryDataHandler.cpp.

References osg::BinaryDataHandler::_currentReadBuffer, osg::BinaryDataHandler::_currentReadBufferPos, osg::BinaryDataHandler::_zeroCopyThreshold, osg::osgMin(), osg::BinaryDataHandler::pullBuffer(), osg::BinaryDataHandler::read(), and osg::BinaryDataHandler::readBufEnd().

Referenced by osg::RemoteAspect::receiveSync(), and osg::ClusterViewBuffer::recv().

00162 {
00163     MemoryHandle data = static_cast<MemoryHandle>(dst);
00164 
00165     if(_zeroCopyThreshold && size >= _zeroCopyThreshold)
00166     {
00167         if(_zeroCopyThreshold > 1)
00168         {
00169             UInt8 tag;
00170 
00171             // we have to read the tag, to force reading of data blocks
00172             // if the first data field was zero copied
00173             get(&tag, sizeof(tag));
00174         }
00175 
00176         // read direct into destination
00177         read(data, size);
00178     }
00179     else
00180     {
00181         UInt32 copySize;
00182 
00183         while(size != 0)
00184         {
00185             // read new data if nothing left
00186             if(_currentReadBuffer == readBufEnd())
00187             {
00188                 pullBuffer();
00189             }
00190 
00191             // num bytes to copy
00192             copySize = osgMin((_currentReadBuffer->getDataSize() -
00193                                _currentReadBufferPos),
00194                               size);
00195 
00196             // no data in buffer ?
00197             if(copySize != 0)
00198             {
00199                 memcpy( data,
00200                        _currentReadBuffer->getMem() + _currentReadBufferPos,
00201                         copySize);
00202 
00203                  size                 -= copySize;
00204                 _currentReadBufferPos += copySize;
00205                  data                 += copySize;
00206             }
00207 
00208             // skip to next buffer if current buffer is full
00209             if(_currentReadBufferPos == _currentReadBuffer->getDataSize())
00210             {
00211                 _currentReadBuffer++;
00212                 _currentReadBufferPos = 0;
00213             }
00214         }
00215     }
00216 }

void BinaryDataHandler::getAndAlloc ( MemoryHandle src,
UInt32  size 
) [inherited]

read data in a dynamic allocated block

If data was compressed or converted then it is not possible to write it into the destination memory. BinaryDataHandler doesn't store data in continous memory areas. If the caller needs a continuous memory then we provide a dynamic allocated block. The caller is responsible to free this block.

Definition at line 227 of file OSGBinaryDataHandler.cpp.

00228 {
00229     src = new UInt8[size];
00230 
00231     get(src, size);
00232 }

void osg::BinaryDataHandler::getValue ( bool &  value  )  [inline, inherited]

Definition at line 405 of file OSGBinaryDataHandler.inl.

Referenced by osg::BINLoader::chargeFieldContainers(), osg::SortFirstWindow::clientInit(), osg::ClusterNetwork::connectAllGroupToPoint(), osg::ClusterNetwork::connectAllPointToPoint(), osg::osg::FieldDataTraits2< bool >::copyFromBin(), osg::RenderNode::copyFromBin(), osg::ParticleBSPTree::copyFromBin(), osg::MField< FieldTypeT, fieldNameSpace >::copyFromBin(), osg::FieldTraitsIntegralRecurseMapper< uint64_t >::copyFromBin(), osg::FieldTraitsRecurseBase1< GLXContext >::copyFromBin(), osg::FieldTraitsRecurseBase< osg::NodePtr >::copyFromBin(), osg::osg::FieldTraitsRecurseMapper< FieldContainerPtr, false >::copyFromBin(), osg::osg::FieldDataTraits< Plane >::copyFromBin(), osg::osg::FieldDataTraits1< GLenum >::copyFromBin(), osg::osg::FieldDataTraits1< BitVector >::copyFromBin(), osg::osg::FieldDataTraits< DynamicVolume >::copyFromBin(), osg::osg::FieldDataTraits1< Time >::copyFromBin(), osg::osg::FieldDataTraits< std::string >::copyFromBin(), osg::osg::FieldTraitsRecurseMapper< AttachmentMap, false >::copyFromBin(), osg::BINLoader::createFieldContainers(), osg::BinaryDataHandler::getValue(), osg::BinaryDataHandler::getValues(), osg::ClusterWindow::init(), osg::RemoteAspect::receiveSync(), osg::ClusterViewBuffer::recv(), osg::SortFirstWindow::serverInit(), osg::ClusterServer::start(), and osg::PointMCastConnection::wait().

00406 {
00407     //get(&value, sizeof(bool));
00408     UInt8 temp;
00409     get(&temp, sizeof(UInt8));
00410     value = (temp!=0);
00411 }

void osg::BinaryDataHandler::getValue ( UInt8 value  )  [inline, inherited]

Definition at line 414 of file OSGBinaryDataHandler.inl.

00415 {
00416     get(&value, sizeof(UInt8));
00417 }

void osg::BinaryDataHandler::getValue ( UInt16 value  )  [inline, inherited]

Definition at line 420 of file OSGBinaryDataHandler.inl.

References osg::osgntohs().

00421 {
00422     get(&value, sizeof(UInt16));
00423 
00424     value = osgntohs(value);
00425 }

void osg::BinaryDataHandler::getValue ( UInt32 value  )  [inline, inherited]

Definition at line 428 of file OSGBinaryDataHandler.inl.

References osg::osgntohl().

00429 {
00430     get(&value, sizeof(UInt32));
00431 
00432     value = osgntohl(value);
00433 }

void osg::BinaryDataHandler::getValue ( UInt64 value  )  [inline, inherited]

Definition at line 436 of file OSGBinaryDataHandler.inl.

References osg::osgntohll().

00437 {
00438     get(&value, sizeof(UInt64));
00439 
00440     value = osgntohll(value);
00441 }

void osg::BinaryDataHandler::getValue ( Int8 value  )  [inline, inherited]

Definition at line 444 of file OSGBinaryDataHandler.inl.

00445 {
00446     get(&value, sizeof(Int8));
00447 }

void osg::BinaryDataHandler::getValue ( Int16 value  )  [inline, inherited]

Definition at line 450 of file OSGBinaryDataHandler.inl.

References osg::osgntohs().

00451 {
00452     get(&value, sizeof(Int16));
00453 
00454     value = osgntohs(value);
00455 }

void osg::BinaryDataHandler::getValue ( Int32 value  )  [inline, inherited]

Definition at line 458 of file OSGBinaryDataHandler.inl.

References osg::osgntohl().

00459 {
00460     get(&value, sizeof(Int32));
00461 
00462     value = osgntohl(value);
00463 }

void osg::BinaryDataHandler::getValue ( Int64 value  )  [inline, inherited]

Definition at line 466 of file OSGBinaryDataHandler.inl.

References osg::osgntohll().

00467 {
00468     get(&value, sizeof(Int64));
00469 
00470     value = osgntohll(value);
00471 }

void osg::BinaryDataHandler::getValue ( Real16 value  )  [inline, inherited]

Definition at line 474 of file OSGBinaryDataHandler.inl.

References osg::osgntohs(), and osg::Real16::setBits().

00475 {
00476     UInt16 v;
00477 
00478     get(&v, sizeof(Real16));
00479 
00480     v     = osgntohs(v);
00481     value.setBits(v);
00482 }

void osg::BinaryDataHandler::getValue ( Real32 value  )  [inline, inherited]

Definition at line 485 of file OSGBinaryDataHandler.inl.

References osg::osgntohf(), and osg::osgntohl().

00486 {
00487     get(&value, sizeof(Real32));
00488 
00489     value = osgntohf(value);
00490 
00491 #if 0
00492     // doesn't work on my 64 bit linux ...
00493     UInt32 v;
00494 
00495     get(&v, sizeof(Real32));
00496 
00497     v     = osgntohl(v);
00498     value = *(reinterpret_cast<Real32 *>(&v));
00499 #endif
00500 }

void osg::BinaryDataHandler::getValue ( Real64 value  )  [inline, inherited]

Definition at line 503 of file OSGBinaryDataHandler.inl.

References osg::osgntohd(), and osg::osgntohll().

00504 {
00505     get(&value, sizeof(Real64));
00506 
00507     value = osgntohd(value);
00508 
00509 #if 0
00510     UInt64 v;
00511 
00512     get(&v, sizeof(Real64));
00513 
00514     v     = osgntohll(v);
00515     value = *(reinterpret_cast<Real64 *>(&v));
00516 #endif
00517 }

void osg::BinaryDataHandler::getValue ( Real128 value  )  [inline, inherited]

Definition at line 520 of file OSGBinaryDataHandler.inl.

References osg::osgntohdd(), and osg::osgntohll().

00521 {
00522     get(&value, sizeof(Real128));
00523 
00524     value = osgntohdd(value);
00525 
00526 #if 0
00527     UInt64 v[2];
00528 
00529 #if BYTE_ORDER == LITTLE_ENDIAN
00530     get(&v[1], sizeof(UInt64));
00531     get(&v[0], sizeof(UInt64));
00532 #else
00533     get(&v[0], sizeof(UInt64));
00534     get(&v[1], sizeof(UInt64));
00535 #endif
00536 
00537     v[0]     = osgntohll(v[0]);
00538     v[1]     = osgntohll(v[1]);
00539     value = *(reinterpret_cast<Real128 *>(&v));
00540 #endif
00541 }

void osg::BinaryDataHandler::getValue ( std::string &  value  )  [inline, inherited]

Definition at line 544 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::getValue().

00545 {
00546     UInt32  len;
00547     Char8  *str = NULL;
00548 
00549     getValue(len);
00550 
00551     if(len != 0)
00552     {
00553         str = new Char8[len];
00554         
00555         get(str, len);
00556 
00557         value = str;
00558         
00559         delete [] str;
00560     }
00561     else
00562     {
00563         value.erase();
00564     }
00565 }

void osg::BinaryDataHandler::getValues ( bool *  value,
UInt32  size 
) [inline, inherited]

void osg::BinaryDataHandler::getValues ( UInt8 value,
UInt32  size 
) [inline, inherited]

Definition at line 575 of file OSGBinaryDataHandler.inl.

00576 {
00577     get(value, size * sizeof(UInt8));
00578 }

void osg::BinaryDataHandler::getValues ( UInt16 value,
UInt32  size 
) [inline, inherited]

Definition at line 581 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, and osg::osgntohs().

00582 {
00583     get(value, size * sizeof(UInt16));
00584 
00585 #if BYTE_ORDER == LITTLE_ENDIAN
00586     if(_networkOrder == true)
00587     {
00588         for(UInt32 i = 0; i < size; ++i)
00589         {
00590             value[i] = osgntohs(value[i]);
00591         }
00592     }
00593 #endif
00594 }

void osg::BinaryDataHandler::getValues ( UInt32 value,
UInt32  size 
) [inline, inherited]

Definition at line 597 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, and osg::osgntohl().

00598 {
00599     get(value, size * sizeof(UInt32));
00600 
00601 #if BYTE_ORDER == LITTLE_ENDIAN
00602     if(_networkOrder == true)
00603     {
00604         for(UInt32 i = 0; i < size; ++i)
00605         {
00606             value[i] = osgntohl(value[i]);
00607         }
00608     }
00609 #endif
00610 }

void osg::BinaryDataHandler::getValues ( UInt64 value,
UInt32  size 
) [inline, inherited]

Definition at line 613 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, and osg::osgntohll().

00614 {
00615     get(value, size * sizeof(UInt64));
00616 
00617 #if BYTE_ORDER == LITTLE_ENDIAN
00618     if(_networkOrder == true)
00619     {
00620         for(UInt32 i = 0; i < size; ++i)
00621         {
00622             value[i] = osgntohll(value[i]);
00623         }
00624     }
00625 #endif
00626 }

void osg::BinaryDataHandler::getValues ( Int8 value,
UInt32  size 
) [inline, inherited]

Definition at line 629 of file OSGBinaryDataHandler.inl.

00630 {
00631     get(value, size * sizeof(Int8));
00632 }

void osg::BinaryDataHandler::getValues ( Int16 value,
UInt32  size 
) [inline, inherited]

Definition at line 635 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, and osg::osgntohs().

00636 {
00637     get(value, size * sizeof(Int16));
00638 
00639 #if BYTE_ORDER == LITTLE_ENDIAN
00640     if(_networkOrder == true)
00641     {
00642         for(UInt32 i = 0; i < size; ++i)
00643         {
00644             value[i] = osgntohs(value[i]);
00645         }
00646     }
00647 #endif
00648 }

void osg::BinaryDataHandler::getValues ( Int32 value,
UInt32  size 
) [inline, inherited]

Definition at line 651 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, and osg::osgntohl().

00652 {
00653     get(value, size * sizeof(Int32));
00654 
00655 #if BYTE_ORDER == LITTLE_ENDIAN
00656     if(_networkOrder == true)
00657     {
00658         for(UInt32 i = 0; i < size; ++i)
00659         {
00660             value[i] = osgntohl(value[i]);
00661         }
00662     }
00663 #endif
00664 }

void osg::BinaryDataHandler::getValues ( Int64 value,
UInt32  size 
) [inline, inherited]

Definition at line 667 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, and osg::osgntohll().

00668 {
00669     get(value, size * sizeof(Int64));
00670 
00671 #if BYTE_ORDER == LITTLE_ENDIAN
00672     if(_networkOrder == true)
00673     {
00674         for(UInt32 i = 0; i < size; ++i)
00675         {
00676             value[i] = osgntohll(value[i]);
00677         }
00678     }
00679 #endif
00680 }

void osg::BinaryDataHandler::getValues ( Real16 value,
UInt32  size 
) [inline, inherited]

Definition at line 683 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, osg::osgntohs(), and osg::Real16::setBits().

00684 {
00685     get(value, size * sizeof(Real16));
00686 
00687 #if BYTE_ORDER == LITTLE_ENDIAN
00688     if(_networkOrder == true)
00689     {
00690         UInt16 *intValue = reinterpret_cast<UInt16 *>(value);
00691 
00692         for(UInt32 i = 0; i < size; ++i)
00693         {
00694             value[i].setBits(osgntohs(intValue[i]));
00695         }
00696     }
00697 #endif
00698 }

void osg::BinaryDataHandler::getValues ( Real32 value,
UInt32  size 
) [inline, inherited]

Definition at line 701 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, and osg::osgntohl().

00702 {
00703     get(value, size * sizeof(Real32));
00704 
00705 #if BYTE_ORDER == LITTLE_ENDIAN
00706     if(_networkOrder == true)
00707     {
00708         UInt32 *intValue = reinterpret_cast<UInt32 *>(value);
00709 
00710         for(UInt32 i = 0; i < size; ++i)
00711         {
00712             intValue[i] = osgntohl(intValue[i]);
00713         }
00714     }
00715 #endif
00716 }

void osg::BinaryDataHandler::getValues ( Real64 value,
UInt32  size 
) [inline, inherited]

Definition at line 719 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, and osg::osgntohll().

00720 {
00721     get(value, size * sizeof(Real64));
00722 
00723 #if BYTE_ORDER == LITTLE_ENDIAN
00724     if(_networkOrder == true)
00725     {
00726         UInt64 *longValue = reinterpret_cast<UInt64 *>(value);
00727 
00728         for(UInt32 i = 0; i < size; ++i)
00729         {
00730             longValue[i] = osgntohll(longValue[i]);
00731         }
00732     }
00733 #endif
00734 }

void osg::BinaryDataHandler::getValues ( Real128 value,
UInt32  size 
) [inline, inherited]

Definition at line 737 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::_networkOrder, and osg::osgntohll().

00738 {
00739     get(value, size * sizeof(UInt64) * 2);
00740 
00741 #if BYTE_ORDER == LITTLE_ENDIAN
00742     if(_networkOrder == true)
00743     {
00744         UInt64 *longValue = reinterpret_cast<UInt64 *>(value);
00745 
00746         for(UInt32 i = 0; i < size; i += 2)
00747         {
00748             UInt64 l = longValue[i];
00749             longValue[i]     = osgntohll(longValue[i + 1]);
00750             longValue[i + 1] = osgntohll(longValue[l    ]);
00751         }
00752     }
00753 #endif
00754 }

void osg::BinaryDataHandler::getValues ( std::string *  value,
UInt32  size 
) [inline, inherited]

Definition at line 757 of file OSGBinaryDataHandler.inl.

References osg::BinaryDataHandler::getValue().

00758 {
00759     for(UInt32 i = 0; i < size; ++i)
00760     {
00761         getValue(value[i]);
00762     }
00763 }

void BinaryDataHandler::forceCopy ( void   )  [virtual, inherited]

always copy memory blocks befor write forceCopy must be called for all endpoints of this connection

Definition at line 260 of file OSGBinaryDataHandler.cpp.

References osg::BinaryDataHandler::_zeroCopyThreshold.

00261 {
00262     _zeroCopyThreshold = 0;
00263 }

void BinaryDataHandler::forceDirectIO ( void   )  [virtual, inherited]

always read or write directly into or from memory blocks forceDirectIO must be called for all endpoints of this connection

Definition at line 268 of file OSGBinaryDataHandler.cpp.

References osg::BinaryDataHandler::_zeroCopyThreshold.

00269 {
00270     _zeroCopyThreshold = 1;
00271 }

void BinaryDataHandler::flush ( void   )  [inherited]

void BinaryDataHandler::setNetworkOrder ( bool  value  )  [inherited]

always copy memory blocks befor write forceCopy must be called for all endpoints of this connection

Definition at line 277 of file OSGBinaryDataHandler.cpp.

References osg::BinaryDataHandler::_networkOrder.

Referenced by osg::ClusterWindow::init(), and osg::ClusterServer::start().

00278 {
00279     _networkOrder = value;    
00280 }

bool BinaryDataHandler::getNetworkOrder ( void   )  [inherited]

always copy memory blocks befor write forceCopy must be called for all endpoints of this connection

Definition at line 282 of file OSGBinaryDataHandler.cpp.

References osg::BinaryDataHandler::_networkOrder.

00283 {
00284     return _networkOrder;
00285 }

BinaryDataHandler::BuffersT::iterator osg::BinaryDataHandler::readBufBegin ( void   )  [inline, protected, inherited]

BinaryDataHandler::BuffersT::iterator osg::BinaryDataHandler::readBufEnd ( void   )  [inline, protected, inherited]

void BinaryDataHandler::readBufAdd ( MemoryHandle  mem,
UInt32  size,
UInt32  dataSize = 0 
) [protected, inherited]

void BinaryDataHandler::readBufClear ( void   )  [protected, inherited]

BinaryDataHandler::BuffersT::iterator osg::BinaryDataHandler::writeBufBegin ( void   )  [inline, protected, inherited]

BinaryDataHandler::BuffersT::iterator osg::BinaryDataHandler::writeBufEnd ( void   )  [inline, protected, inherited]

void BinaryDataHandler::writeBufAdd ( MemoryHandle  mem,
UInt32  size,
UInt32  dataSize = 0 
) [protected, inherited]

void BinaryDataHandler::writeBufClear ( void   )  [protected, inherited]

bool BinaryDataHandler::isReadBufferEmpty ( void   )  [protected, inherited]

check for data in read buffer

Definition at line 431 of file OSGBinaryDataHandler.cpp.

References osg::BinaryDataHandler::_currentReadBuffer, osg::BinaryDataHandler::_zeroCopyThreshold, and osg::BinaryDataHandler::readBufEnd().

Referenced by osg::PointMCastConnection::selectChannel().

00432 {
00433     if(_zeroCopyThreshold == 1)
00434         return true;
00435     if(_currentReadBuffer == readBufEnd())
00436         return true;
00437     return false;
00438 }


Friends And Related Function Documentation

friend class PointMCastConnection [friend]

Definition at line 160 of file OSGGroupMCastConnection.h.


Member Data Documentation

Definition at line 125 of file OSGGroupMCastConnection.h.

Referenced by initialize(), sendQueue(), and write().

Definition at line 126 of file OSGGroupMCastConnection.h.

Referenced by initialize(), write(), and ~GroupMCastConnection().

Definition at line 127 of file OSGGroupMCastConnection.h.

Referenced by initialize(), sendQueueThread(), and write().

Definition at line 128 of file OSGGroupMCastConnection.h.

Referenced by initialize(), sendQueue(), and ~GroupMCastConnection().

Definition at line 129 of file OSGGroupMCastConnection.h.

Referenced by sendQueue(), write(), and ~GroupMCastConnection().

Definition at line 132 of file OSGGroupMCastConnection.h.

Referenced by initialize(), and write().

Definition at line 133 of file OSGGroupMCastConnection.h.

Definition at line 134 of file OSGGroupMCastConnection.h.

Referenced by GroupMCastConnection(), and sendQueue().

Definition at line 135 of file OSGGroupMCastConnection.h.

Referenced by initialize().

Definition at line 136 of file OSGGroupMCastConnection.h.

Referenced by initialize(), and sendQueue().

Definition at line 137 of file OSGGroupMCastConnection.h.

Referenced by initialize(), and write().

Reimplemented from osg::GroupSockConnection.

Definition at line 176 of file OSGGroupMCastConnection.h.

Referenced by getType().

std::vector<StreamSocket> osg::GroupSockConnection::_sockets [protected, inherited]

std::vector<SocketAddress> osg::GroupSockConnection::_remoteAddresses [protected, inherited]

std::vector<UInt8> osg::GroupSockConnection::_socketReadBuffer [protected, inherited]

std::vector<UInt8> osg::GroupSockConnection::_socketWriteBuffer [protected, inherited]

std::vector<UInt8> osg::GroupConnection::_selection [protected, inherited]

std::string osg::GroupConnection::_destination [protected, inherited]

std::set<Channel> osg::GroupConnection::_disconnectedChannel [protected, inherited]

Definition at line 115 of file OSGGroupConnection.h.

std::string osg::Connection::_interface [protected, inherited]

BuffersT::iterator osg::BinaryDataHandler::_currentReadBuffer [protected, inherited]

BuffersT::iterator osg::BinaryDataHandler::_currentWriteBuffer [protected, inherited]

bool osg::BinaryDataHandler::_networkOrder [protected, inherited]


The documentation for this class was generated from the following files:

Generated on Mon Mar 17 12:03:51 2008 for OpenSG by  doxygen 1.5.5