00001 00002 /* Copyright (c) 2007-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 EQNET_FULLSLAVECM_H 00019 #define EQNET_FULLSLAVECM_H 00020 00021 #include "staticSlaveCM.h" // base class 00022 00023 #include <eq/net/commandQueue.h> // member 00024 #include <eq/net/object.h> // nested enum (Object::Version) 00025 #include <eq/base/idPool.h> // for EQ_ID_INVALID 00026 00027 namespace eq 00028 { 00029 namespace net 00030 { 00031 class Node; 00032 class ObjectDataIStream; 00033 class ObjectDeltaDataIStream; 00034 00039 class FullSlaveCM : public StaticSlaveCM 00040 { 00041 public: 00042 FullSlaveCM( Object* object, uint32_t masterInstanceID ); 00043 virtual ~FullSlaveCM(); 00044 00045 virtual void makeThreadSafe(); 00046 00051 virtual uint32_t commitNB() { EQDONTCALL; return EQ_ID_INVALID; } 00052 virtual uint32_t commitSync( const uint32_t commitID ) 00053 { EQDONTCALL; return Object::VERSION_NONE; } 00054 00055 virtual void obsolete( const uint32_t version ) { EQDONTCALL; } 00056 00057 virtual void setAutoObsolete( const uint32_t count, 00058 const uint32_t flags ) { EQDONTCALL; } 00059 virtual uint32_t getAutoObsoleteCount() const 00060 { EQDONTCALL; return 0; } 00061 00062 virtual uint32_t sync( const uint32_t version ); 00063 00064 virtual uint32_t getHeadVersion() const; 00065 virtual uint32_t getVersion() const { return _version; } 00066 virtual uint32_t getOldestVersion() const { return _version; } 00068 00069 virtual bool isMaster() const { return false; } 00070 virtual uint32_t getMasterInstanceID() const {return _masterInstanceID;} 00071 00072 virtual void addSlave( NodePtr slave, const uint32_t instanceID, 00073 const uint32_t version ) { EQDONTCALL; } 00074 virtual void removeSlave( NodePtr node ) { EQDONTCALL; } 00075 virtual void addOldMaster( NodePtr node, const uint32_t instanceID ) 00076 { EQDONTCALL } 00077 00078 virtual void applyMapData(); 00079 00080 protected: 00082 uint32_t _version; 00083 00085 base::MTQueue< ObjectDataIStream* > _queuedVersions; 00086 00088 virtual void _unpackOneVersion( ObjectDataIStream* is ); 00089 00090 private: 00092 base::Lock* _mutex; 00093 00095 ObjectDataIStream* _currentDeltaStream; 00096 00098 uint32_t _masterInstanceID; 00099 00100 void _syncToHead(); 00101 00102 /* The command handlers. */ 00103 CommandResult _cmdDeltaData( Command& command ); 00104 CommandResult _cmdDelta( Command& command ); 00105 CommandResult _cmdVersion( Command& pkg ); 00106 00107 CHECK_THREAD_DECLARE( _thread ); 00108 }; 00109 } 00110 } 00111 00112 #endif // EQNET_FULLSLAVECM_H
0.9 by
1.5.8