LCOV - code coverage report
Current view: top level - co - objectDataOStream.cpp (source / functions) Hit Total Coverage
Test: Collage Lines: 26 26 100.0 %
Date: 2018-01-09 16:37:03 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         172 : ObjectDataOStream::ObjectDataOStream(const ObjectCM* cm)
      33             :     : _cm(cm)
      34             :     , _version(VERSION_INVALID)
      35         172 :     , _sequence(0)
      36             : {
      37         172 :     const Object* object = cm->getObject();
      38         344 :     const CompressorInfo& info = object->chooseCompressor();
      39         172 :     _setCompressor(info);
      40         172 :     LBLOG(LOG_OBJECTS) << "Using " << info.name << " for "
      41         344 :                        << lunchbox::className(object) << std::endl;
      42         172 : }
      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         157 : ObjectDataOCommand ObjectDataOStream::send(const uint32_t cmd,
      60             :                                            const uint32_t type,
      61             :                                            const uint32_t instanceID,
      62             :                                            const void* data,
      63             :                                            const uint64_t size, const bool last)
      64             : {
      65         157 :     LBASSERT(_version != VERSION_INVALID);
      66         157 :     const uint32_t sequence = _sequence++;
      67         157 :     if (last)
      68         151 :         _sequence = 0;
      69             : 
      70             :     return ObjectDataOCommand(getConnections(), cmd, type,
      71         157 :                               _cm->getObject()->getID(), instanceID, _version,
      72         314 :                               sequence, data, size, last, this);
      73             : }
      74          63 : }

Generated by: LCOV version 1.11