configCommitVisitor.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef EQ_CONFIGCOMMITVISITOR_H
00019 #define EQ_CONFIGCOMMITVISITOR_H
00020
00021 #include <eq/client/configVisitor.h>
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;
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