client/object.cpp

00001 
00002 /* Copyright (c) 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 "object.h"
00019 
00020 #include <eq/net/dataOStream.h>
00021 #include <eq/net/dataIStream.h>
00022 
00023 namespace eq
00024 {
00025 
00026 Object::Object()
00027         : _dirty( DIRTY_NONE )
00028 {}
00029 
00030 Object::~Object()
00031 {
00032 }
00033 
00034 void Object::getInstanceData( net::DataOStream& os )
00035 {
00036     os << static_cast< uint64_t >( DIRTY_ALL );
00037     serialize( os, DIRTY_ALL );
00038 }
00039 
00040 void Object::pack( net::DataOStream& os )
00041 {
00042     if( _dirty == DIRTY_NONE )
00043         return;
00044 
00045     os << _dirty;
00046     serialize( os, _dirty );
00047     _dirty = DIRTY_NONE;
00048 }
00049 
00050 void Object::applyInstanceData( net::DataIStream& is )
00051 {
00052     if( is.getRemainingBufferSize() == 0 && is.nRemainingBuffers() == 0 )
00053         return;
00054     
00055     is >> _dirty;
00056     deserialize( is, _dirty );
00057 }
00058 
00059 void Object::serialize( net::DataOStream& os, const uint64_t dirtyBits )
00060 {
00061     if( dirtyBits & DIRTY_NAME )
00062         os << _name;
00063 }
00064 
00065 void Object::deserialize( net::DataIStream& is, const uint64_t dirtyBits )
00066 {
00067     if( dirtyBits & DIRTY_NAME )
00068         is >> _name;
00069 }
00070 
00071 void Object::setDirty( const uint64_t bits )
00072 {
00073     _dirty |= bits;
00074 }
00075 
00076 void Object::attachToSession( const uint32_t id, const uint32_t instanceID, 
00077                               net::Session* session )
00078 {
00079     net::Object::attachToSession( id, instanceID, session );
00080     _dirty = DIRTY_NONE;
00081 }
00082 
00083 void Object::setName( const std::string& name )
00084 {
00085     _name = name;
00086     setDirty( DIRTY_NAME );
00087 }
00088 
00089 const std::string& Object::getName() const
00090 {
00091     return _name;
00092 }
00093 
00094 
00095 }
Generated on Mon Aug 10 18:58:40 2009 for Equalizer 0.9 by  doxygen 1.5.8