objectInstanceDataIStream.cpp

00001 
00002 /* Copyright (c) 2007-2008, 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 "objectInstanceDataIStream.h"
00019 
00020 #include "command.h"
00021 #include "commands.h"
00022 
00023 #include <eq/base/idPool.h>
00024 
00025 using namespace std;
00026 
00027 namespace eq
00028 {
00029 namespace net
00030 {
00031 ObjectInstanceDataIStream::ObjectInstanceDataIStream()
00032     : _sequence( EQ_ID_INVALID ) // only for safety check - remove me later!
00033 {
00034 }
00035 
00036 ObjectInstanceDataIStream::~ObjectInstanceDataIStream()
00037 {
00038 }
00039 
00040 bool ObjectInstanceDataIStream::getNextBuffer( const uint8_t** buffer, 
00041                                                uint64_t* size )
00042 {
00043     const Command* command = getNextCommand();
00044     if( !command )
00045         return false;
00046 
00047     switch( (*command)->command )
00048     {
00049         case CMD_OBJECT_INSTANCE_DATA:
00050         {
00051             const ObjectInstanceDataPacket* packet = 
00052                 command->getPacket< ObjectInstanceDataPacket >();
00053             *buffer = packet->data;
00054             *size   = packet->dataSize;
00055 
00056             EQASSERTINFO( ( _sequence==EQ_ID_INVALID && packet->sequence==0 )||
00057                           ( _sequence+1 == packet->sequence ),
00058                           "have " << _sequence << " got " << packet->sequence);
00059             _sequence = packet->sequence;
00060             return true;
00061         }
00062 
00063         case CMD_OBJECT_INSTANCE:
00064         {
00065             const ObjectInstancePacket* packet =
00066                 command->getPacket< ObjectInstancePacket >();
00067             *buffer = packet->data;
00068             *size   = packet->dataSize;
00069 
00070             EQASSERTINFO( ( _sequence==EQ_ID_INVALID && packet->sequence==0 )||
00071                 ( _sequence+1 == packet->sequence ),
00072                 "have " << _sequence << " got " << packet->sequence);
00073             _sequence = EQ_ID_INVALID; // last in stream
00074             return true;
00075         }
00076         
00077         default: 
00078             EQERROR << "Illegal command in command fifo: " << *command << endl;
00079             EQUNREACHABLE;
00080     }
00081 
00082     return false;    
00083 }
00084 }
00085 }
Generated on Mon Aug 10 18:58:40 2009 for Equalizer 0.9 by  doxygen 1.5.8