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 #ifndef EQSERVER_CONFIGSYNCVISITOR_H 00019 #define EQSERVER_CONFIGSYNCVISITOR_H 00020 00021 #include "configVisitor.h" // base class 00022 00023 namespace eq 00024 { 00025 namespace server 00026 { 00028 class ConfigSyncVisitor : public ConfigVisitor 00029 { 00030 public: 00031 ConfigSyncVisitor( const uint32_t nChanges, 00032 const net::ObjectVersion* changes ) 00033 : _nChanges( nChanges ), _changes( changes ), _current( 0 ) {} 00034 virtual ~ConfigSyncVisitor() {} 00035 00036 virtual VisitorResult visit( Observer* observer ) 00037 { 00038 return _sync( observer ); 00039 } 00040 virtual VisitorResult visitPre( Canvas* canvas ) 00041 { 00042 return _sync( canvas ); 00043 } 00044 virtual VisitorResult visit( View* view ) 00045 { 00046 return _sync( view ); 00047 } 00048 virtual VisitorResult visitPost( Config* config ) 00049 { 00050 EQUNREACHABLE; 00051 return TRAVERSE_CONTINUE; 00052 } 00053 00054 private: 00055 const uint32_t _nChanges; 00056 const net::ObjectVersion* _changes; 00057 uint32_t _current; 00058 00059 VisitorResult _sync( net::Object* object ) 00060 { 00061 EQASSERT( _current < _nChanges ); 00062 const net::ObjectVersion& change = _changes[ _current ]; 00063 00064 if( change.id != object->getID( )) 00065 return TRAVERSE_CONTINUE; 00066 00067 object->sync( change.version ); 00068 ++_current; 00069 00070 if( _current == _nChanges ) 00071 return TRAVERSE_TERMINATE; // all done 00072 return TRAVERSE_CONTINUE; 00073 } 00074 }; 00075 } 00076 } 00077 #endif // EQSERVER_CONSTCONFIGVISITOR_H
0.9 by
1.5.8