configCommitVisitor.h

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 EQ_CONFIGCOMMITVISITOR_H
00019 #define EQ_CONFIGCOMMITVISITOR_H
00020 
00021 #include <eq/client/configVisitor.h> // base class
00022 
00023 namespace eq
00024 {
00025     class Config;
00026 
00028     class ConfigCommitVisitor : public ConfigVisitor
00029     {
00030     public:
00031         ConfigCommitVisitor() : _needFinish( false ) {}
00032         virtual ~ConfigCommitVisitor() {}
00033 
00034         virtual VisitorResult visit( Observer* observer )
00035             { 
00036                 _commit( observer );
00037                 return TRAVERSE_CONTINUE; 
00038             }
00039         virtual VisitorResult visitPre( Canvas* canvas )
00040             {
00041                 if( canvas->getDirty() & Canvas::DIRTY_LAYOUT )
00042                     _needFinish = true;
00043 
00044                 _commit( canvas );
00045                 return TRAVERSE_PRUNE; // no need to visit segments
00046             }
00047         virtual VisitorResult visit( View* view )
00048             { 
00049                 _commit( view );
00050                 return TRAVERSE_CONTINUE; 
00051             }
00052         
00053         bool needsFinish() const { return _needFinish; }
00054 
00055         const std::vector< net::ObjectVersion >& getChanges() const
00056             { return _changes; }
00057 
00058     private:
00059         bool _needFinish;
00060         std::vector< net::ObjectVersion > _changes;
00061         
00062         void _commit( net::Object* object )
00063             {
00064                 const uint32_t oldVersion = object->getVersion();
00065                 const uint32_t newVersion = object->commit();
00066 
00067                 if( oldVersion != newVersion )
00068                     _changes.push_back( net::ObjectVersion( object->getID(),
00069                                                             newVersion ));
00070             }
00071     };
00072 }
00073 
00074 #endif // EQ_CONFIGDESERIALIZER_H
Generated on Mon Aug 10 18:58:32 2009 for Equalizer 0.9 by  doxygen 1.5.8