LCOV - code coverage report
Current view: top level - co - fullMasterCM.h (source / functions) Hit Total Coverage
Test: Collage Lines: 5 7 71.4 %
Date: 2018-01-09 16:37:03 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 "objectInstanceDataOStream.h" // member
      25             : #include "versionedMasterCM.h"         // base class
      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)
      64         121 :             , commitCount(0)
      65             :         {
      66         121 :         }
      67             : 
      68             :         ObjectInstanceDataOStream os;
      69             :         uint32_t commitCount;
      70             :     };
      71             : 
      72             :     bool _initSlave(const MasterCMCommand&, const uint128_t&, bool) override;
      73             : 
      74             :     InstanceData* _newInstanceData();
      75             :     void _addInstanceData(InstanceData* data);
      76             :     void _releaseInstanceData(InstanceData* data);
      77             : 
      78             :     void _updateCommitCount(const uint32_t incarnation);
      79             :     void _obsolete();
      80             :     void _checkConsistency() const;
      81             : 
      82           0 :     bool isBuffered() const override { return true; }
      83             :     virtual void _commit();
      84             : 
      85             : private:
      86             :     /** The number of commits, needed for auto-obsoletion. */
      87             :     uint32_t _commitCount;
      88             : 
      89             :     /** The number of old versions to retain. */
      90             :     uint32_t _nVersions;
      91             : 
      92             :     typedef std::deque<InstanceData*> InstanceDataDeque;
      93             :     typedef std::vector<InstanceData*> InstanceDatas;
      94             : 
      95             :     /** The list of full instance datas, head version last. */
      96             :     InstanceDataDeque _instanceDatas;
      97             :     InstanceDatas _instanceDataCache;
      98             : 
      99             :     /* The command handlers. */
     100             :     bool _cmdCommit(ICommand& command);
     101             :     bool _cmdObsolete(ICommand& command);
     102             :     bool _cmdPush(ICommand& command);
     103             : };
     104             : }
     105             : 
     106             : #endif // CO_FULLMASTERCM_H

Generated by: LCOV version 1.11