LCOV - code coverage report
Current view: top level - co - objectDataOStream.cpp (source / functions) Hit Total Coverage
Test: Collage Lines: 27 28 96.4 %
Date: 2015-11-03 13:48:53 Functions: 6 6 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2013, Stefan Eilemann <eile@eyescale.ch>
       3             :  *                    2010, Cedric Stalder  <cedric.stalder@gmail.com>
       4             :  *                    2012, 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             : namespace co
      29             : {
      30         178 : ObjectDataOStream::ObjectDataOStream( const ObjectCM* cm )
      31             :         : _cm( cm )
      32             :         , _version( VERSION_INVALID )
      33         178 :         , _sequence( 0 )
      34             : {
      35         178 :     const Object* object = cm->getObject();
      36         178 :     const uint32_t name = object->chooseCompressor();
      37         178 :     _initCompressor( name );
      38         178 :     LBLOG( LOG_OBJECTS )
      39           0 :         << "Using byte compressor 0x" << std::hex << name << std::dec << " for "
      40         356 :         << lunchbox::className( object ) << std::endl;
      41         178 : }
      42             : 
      43         229 : void ObjectDataOStream::reset()
      44             : {
      45         229 :     DataOStream::reset();
      46         229 :     _sequence = 0;
      47         229 :     _version = VERSION_INVALID;
      48         229 : }
      49             : 
      50         237 : void ObjectDataOStream::enableCommit( const uint128_t& version,
      51             :                                       const Nodes& receivers )
      52             : {
      53         237 :     _version = version;
      54         237 :     _setupConnections( receivers );
      55         237 :     _enable();
      56         237 : }
      57             : 
      58         163 : ObjectDataOCommand ObjectDataOStream::send(
      59             :     const uint32_t cmd, const uint32_t type, const uint32_t instanceID,
      60             :     const void* data, const uint64_t size, const bool last )
      61             : {
      62         163 :     LBASSERT( _version != VERSION_INVALID );
      63         163 :     const uint32_t sequence = _sequence++;
      64         163 :     if( last )
      65         157 :         _sequence = 0;
      66             : 
      67         163 :     return ObjectDataOCommand( getConnections(), cmd, type,
      68         163 :                                _cm->getObject()->getID(), instanceID, _version,
      69         326 :                                sequence, data, size, last, this );
      70             : }
      71             : 
      72          63 : }

Generated by: LCOV version 1.11