LCOV - code coverage report
Current view: top level - co - fullMasterCM.h (source / functions) Hit Total Coverage
Test: Collage Lines: 3 5 60.0 %
Date: 2016-12-14 01:26:48 Functions: 2 4 50.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2007-2016, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *
       5             :  * This file is part of Collage <https://github.com/Eyescale/Collage>
       6             :  *
       7             :  * This library is free software; you can redistribute it and/or modify it under
       8             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       9             :  * by the Free Software Foundation.
      10             :  *
      11             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      12             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      13             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      14             :  * details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public License
      17             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      18             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      19             :  */
      20             : 
      21             : #ifndef CO_FULLMASTERCM_H
      22             : #define CO_FULLMASTERCM_H
      23             : 
      24             : #include "versionedMasterCM.h"        // base class
      25             : #include "objectInstanceDataOStream.h" // member
      26             : 
      27             : #include <deque>
      28             : 
      29             : namespace co
      30             : {
      31             : class ObjectDataIStream;
      32             : 
      33             : /**
      34             :  * An object change manager handling only full versions for the master
      35             :  * instance.
      36             :  * @internal
      37             :  */
      38             : class FullMasterCM : public VersionedMasterCM
      39             : {
      40             : public:
      41             :     explicit FullMasterCM( Object* object );
      42             :     virtual ~FullMasterCM();
      43             : 
      44             :     void init() override;
      45             :     uint128_t commit( const uint32_t incarnation ) override;
      46             :     void push( const uint128_t& groupID, const uint128_t& typeID,
      47             :                const Nodes& nodes ) override;
      48             :     bool sendSync( const MasterCMCommand& command ) override;
      49             : 
      50             :     /** @name Versioning */
      51             :     //@{
      52             :     void setAutoObsolete( const uint32_t count ) override;
      53           0 :     uint32_t getAutoObsolete() const override { return _nVersions; }
      54             :     //@}
      55             : 
      56             :     /** Speculatively send instance data to all nodes. */
      57             :     void sendInstanceData( const Nodes& nodes ) override;
      58             : 
      59             : protected:
      60         121 :     struct InstanceData
      61             :     {
      62         121 :         explicit InstanceData( const VersionedMasterCM* cm )
      63         121 :             : os( cm ), commitCount( 0 ) {}
      64             : 
      65             :         ObjectInstanceDataOStream os;
      66             :         uint32_t commitCount;
      67             :     };
      68             : 
      69             :     bool _initSlave( const MasterCMCommand&, const uint128_t&,
      70             :                      bool ) override;
      71             : 
      72             :     InstanceData* _newInstanceData();
      73             :     void _addInstanceData( InstanceData* data );
      74             :     void _releaseInstanceData( InstanceData* data );
      75             : 
      76             :     void _updateCommitCount( const uint32_t incarnation );
      77             :     void _obsolete();
      78             :     void _checkConsistency() const;
      79             : 
      80           0 :     bool isBuffered() const override { return true; }
      81             :     virtual void _commit();
      82             : 
      83             : private:
      84             :     /** The number of commits, needed for auto-obsoletion. */
      85             :     uint32_t _commitCount;
      86             : 
      87             :     /** The number of old versions to retain. */
      88             :     uint32_t _nVersions;
      89             : 
      90             :     typedef std::deque< InstanceData* > InstanceDataDeque;
      91             :     typedef std::vector< InstanceData* > InstanceDatas;
      92             : 
      93             :     /** The list of full instance datas, head version last. */
      94             :     InstanceDataDeque _instanceDatas;
      95             :     InstanceDatas _instanceDataCache;
      96             : 
      97             :     /* The command handlers. */
      98             :     bool _cmdCommit( ICommand& command );
      99             :     bool _cmdObsolete( ICommand& command );
     100             :     bool _cmdPush( ICommand& command );
     101             : };
     102             : }
     103             : 
     104             : #endif // CO_FULLMASTERCM_H

Generated by: LCOV version 1.11