LCOV - code coverage report
Current view: top level - co - objectDataOStream.cpp (source / functions) Hit Total Coverage
Test: Collage Lines: 26 26 100.0 %
Date: 2016-12-14 01:26:48 Functions: 6 6 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2016, Stefan Eilemann <eile@eyescale.ch>
       3             :  *                          Cedric Stalder  <cedric.stalder@gmail.com>
       4             :  *                          Daniel Nachbaur <danielnachbaur@gmail.com>
       5             :  *
       6             :  * This file is part of Collage <https://github.com/Eyescale/Collage>
       7             :  *
       8             :  * This library is free software; you can redistribute it and/or modify it under
       9             :  * the terms of the GNU Lesser General Public License version 2.1 as published
      10             :  * by the Free Software Foundation.
      11             :  *
      12             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      13             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      14             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      15             :  * details.
      16             :  *
      17             :  * You should have received a copy of the GNU Lesser General Public License
      18             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      19             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      20             :  */
      21             : 
      22             : #include "objectDataOStream.h"
      23             : 
      24             : #include "log.h"
      25             : #include "objectCM.h"
      26             : #include "objectDataOCommand.h"
      27             : 
      28             : #include <pression/data/CompressorInfo.h>
      29             : 
      30             : namespace co
      31             : {
      32         178 : ObjectDataOStream::ObjectDataOStream( const ObjectCM* cm )
      33             :         : _cm( cm )
      34             :         , _version( VERSION_INVALID )
      35         178 :         , _sequence( 0 )
      36             : {
      37         178 :     const Object* object = cm->getObject();
      38         356 :     const CompressorInfo& info = object->chooseCompressor();
      39         178 :     _setCompressor( info );
      40         178 :     LBLOG( LOG_OBJECTS ) << "Using " << info.name << " for "
      41         356 :                          << lunchbox::className( object ) << std::endl;
      42         178 : }
      43             : 
      44         225 : void ObjectDataOStream::reset()
      45             : {
      46         225 :     DataOStream::reset();
      47         225 :     _sequence = 0;
      48         225 :     _version = VERSION_INVALID;
      49         225 : }
      50             : 
      51         233 : void ObjectDataOStream::enableCommit( const uint128_t& version,
      52             :                                       const Nodes& receivers )
      53             : {
      54         233 :     _version = version;
      55         233 :     _setupConnections( receivers );
      56         233 :     _enable();
      57         233 : }
      58             : 
      59         163 : ObjectDataOCommand ObjectDataOStream::send(
      60             :     const uint32_t cmd, const uint32_t type, const uint32_t instanceID,
      61             :     const void* data, const uint64_t size, const bool last )
      62             : {
      63         163 :     LBASSERT( _version != VERSION_INVALID );
      64         163 :     const uint32_t sequence = _sequence++;
      65         163 :     if( last )
      66         157 :         _sequence = 0;
      67             : 
      68             :     return ObjectDataOCommand( getConnections(), cmd, type,
      69         163 :                                _cm->getObject()->getID(), instanceID, _version,
      70         326 :                                sequence, data, size, last, this );
      71             : }
      72             : 
      73          66 : }

Generated by: LCOV version 1.11