fullMasterCM.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_FULLMASTERCM_H
00019 #define EQNET_FULLMASTERCM_H
00020 
00021 #include "objectDeltaDataOStream.h" // member
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 
00039     class FullMasterCM : public ObjectCM
00040     {
00041     public:
00042         FullMasterCM( Object* object );
00043         virtual ~FullMasterCM();
00044 
00045         virtual void makeThreadSafe(){}
00046 
00051         virtual uint32_t commitNB();
00052         virtual uint32_t commitSync( const uint32_t commitID );
00053 
00054         virtual void obsolete( const uint32_t version ) { EQUNIMPLEMENTED; }
00055 
00056         virtual void setAutoObsolete( const uint32_t count, 
00057                                       const uint32_t flags )
00058             { _nVersions = count; _obsoleteFlags = flags; }
00059         
00060         virtual uint32_t getAutoObsoleteCount() const { return _nVersions; }
00061 
00062         virtual uint32_t sync( const uint32_t version )
00063             { EQDONTCALL; return _version; }
00064 
00065         virtual uint32_t getHeadVersion() const { return _version; }
00066         virtual uint32_t getVersion() const     { return _version; }
00067         virtual uint32_t getOldestVersion() const;
00069 
00070         virtual bool isMaster() const { return true; }
00071         virtual uint32_t getMasterInstanceID() const
00072             { EQDONTCALL; return EQ_ID_INVALID; }
00073         virtual void addSlave( NodePtr node, const uint32_t instanceID,
00074                                const uint32_t version );
00075         virtual void removeSlave( NodePtr node );
00076         virtual void addOldMaster( NodePtr node, const uint32_t instanceID );
00077 
00078         virtual void applyMapData() { EQDONTCALL; }
00079 
00080     private:
00082         Object* _object;
00083 
00085         NodeVector _slaves;
00086 
00088         base::UUIDHash< uint32_t > _slavesCount;
00089 
00091         uint32_t _version;
00092 
00094         uint32_t _commitCount;
00095 
00097         uint32_t _nVersions;
00098 
00100         uint32_t _obsoleteFlags;
00101 
00103         base::RequestHandler _requestHandler;
00104 
00105         struct DeltaData
00106         {
00107             DeltaData( const Object* object ) 
00108                     : os( object ), commitCount(0) {}
00109 
00110             ObjectDeltaDataOStream os;
00111             uint32_t commitCount;
00112         };
00113         
00115         std::deque< DeltaData* >  _deltaDatas;
00116         std::vector< DeltaData* > _deltaDataCache;
00117 
00118         DeltaData* _newDeltaData();
00119 
00120         void _obsolete();
00121         void _checkConsistency() const;
00122 
00123         /* The command handlers. */
00124         CommandResult _cmdCommit( Command& pkg );
00125         CommandResult _cmdDiscard( Command& pkg ) { return COMMAND_HANDLED; }
00126 
00127         CHECK_THREAD_DECLARE( _thread );
00128     };
00129 }
00130 }
00131 
00132 #endif // EQNET_FULLMASTERCM_H
Generated on Mon Aug 10 18:58:33 2009 for Equalizer 0.9 by  doxygen 1.5.8