deltaMasterCM.h

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_DELTAMASTERCM_H
00019 #define EQNET_DELTAMASTERCM_H
00020 
00021 #include "objectInstanceDataOStream.h"
00022 
00023 #include <eq/net/objectCM.h>           // base class
00024 #include <eq/net/types.h>              // for NodeVector
00025 
00026 #include <deque>
00027 
00028 namespace eq
00029 {
00030 namespace net
00031 {
00032     class Node;
00033     class ObjectDeltaDataOStream;
00034 
00040     class DeltaMasterCM : public ObjectCM
00041     {
00042     public:
00043         DeltaMasterCM( Object* object );
00044         virtual ~DeltaMasterCM();
00045 
00046         virtual void makeThreadSafe(){}
00047 
00052         virtual uint32_t commitNB();
00053         virtual uint32_t commitSync( const uint32_t commitID );
00054 
00055         virtual void obsolete( const uint32_t version ) { EQUNIMPLEMENTED; }
00056 
00057         virtual void setAutoObsolete( const uint32_t count, 
00058                                       const uint32_t flags )
00059             { _nVersions = count; _obsoleteFlags = flags; }
00060         
00061         virtual uint32_t getAutoObsoleteCount() const { return _nVersions; }
00062 
00063         virtual uint32_t sync( const uint32_t version )
00064             { EQDONTCALL; return _version; }
00065 
00066         virtual uint32_t getHeadVersion() const { return _version; }
00067         virtual uint32_t getVersion() const     { return _version; }
00068         virtual uint32_t getOldestVersion() const;
00070 
00071         virtual bool isMaster() const { return true; }
00072         virtual uint32_t getMasterInstanceID() const
00073             { EQDONTCALL; return EQ_ID_INVALID; }
00074         virtual void addSlave( NodePtr node, const uint32_t instanceID,
00075                                const uint32_t version );
00076         virtual void removeSlave( NodePtr node );
00077         virtual void addOldMaster( NodePtr node, const uint32_t instanceID );
00078 
00079         virtual void applyMapData() { EQDONTCALL; }
00080 
00081     private:
00083         Object* _object;
00084 
00086         NodeVector _slaves;
00087 
00089         base::UUIDHash< uint32_t > _slavesCount;
00090 
00092         uint32_t _version;
00093 
00095         uint32_t _commitCount;
00096 
00098         uint32_t _nVersions;
00099 
00101         uint32_t _obsoleteFlags;
00102 
00104         base::RequestHandler _requestHandler;
00105 
00106         struct InstanceData
00107         {
00108             InstanceData( const Object* object )
00109                     : os( object ), commitCount(0) {}
00110 
00111             ObjectInstanceDataOStream os;
00112             uint32_t commitCount;
00113         };
00114         
00115         typedef ObjectDeltaDataOStream DeltaData;
00116         
00118         std::deque< InstanceData* > _instanceDatas;
00119 
00121         std::deque< DeltaData* > _deltaDatas;
00122         
00123         std::vector< InstanceData* > _instanceDataCache;
00124         std::vector< DeltaData* >   _deltaDataCache;
00125 
00126         DeltaData*   _newDeltaData();
00127         InstanceData* _newInstanceData();
00128 
00129         void _obsolete();
00130         void _checkConsistency() const;
00131 
00132         /* The command handlers. */
00133         CommandResult _cmdCommit( Command& pkg );
00134         CommandResult _cmdDiscard( Command& pkg ) { return COMMAND_HANDLED; }
00135 
00136         CHECK_THREAD_DECLARE( _thread );
00137     };
00138 }
00139 }
00140 
00141 #endif // EQNET_DELTAMASTERCM_H
Generated on Mon Aug 10 18:58:32 2009 for Equalizer 0.9 by  doxygen 1.5.8