LCOV - code coverage report
Current view: top level - co - objectInstanceDataOStream.cpp (source / functions) Hit Total Coverage
Test: Collage Lines: 62 79 78.5 %
Date: 2018-01-09 16:37:03 Functions: 12 15 80.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2007-2014, Stefan Eilemann <eile@equalizergraphics.com>
       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 "objectInstanceDataOStream.h"
      23             : 
      24             : #include "log.h"
      25             : #include "nodeCommand.h"
      26             : #include "object.h"
      27             : #include "objectDataIStream.h"
      28             : #include "objectDataOCommand.h"
      29             : #include "versionedMasterCM.h"
      30             : 
      31             : namespace co
      32             : {
      33         129 : ObjectInstanceDataOStream::ObjectInstanceDataOStream(const ObjectCM* cm)
      34             :     : ObjectDataOStream(cm)
      35             :     , _instanceID(CO_INSTANCE_ALL)
      36         129 :     , _command(0)
      37             : {
      38         129 : }
      39             : 
      40         129 : ObjectInstanceDataOStream::~ObjectInstanceDataOStream()
      41             : {
      42         129 : }
      43             : 
      44         121 : void ObjectInstanceDataOStream::reset()
      45             : {
      46         121 :     ObjectDataOStream::reset();
      47         121 :     _nodeID = 0;
      48         121 :     _instanceID = CO_INSTANCE_NONE;
      49         121 :     _command = 0;
      50         121 : }
      51             : 
      52         121 : void ObjectInstanceDataOStream::enableCommit(const uint128_t& version,
      53             :                                              const Nodes& receivers)
      54             : {
      55         121 :     _command = CMD_NODE_OBJECT_INSTANCE_COMMIT;
      56         121 :     _nodeID = 0;
      57         121 :     _instanceID = CO_INSTANCE_NONE;
      58         121 :     ObjectDataOStream::enableCommit(version, receivers);
      59         121 : }
      60             : 
      61           2 : void ObjectInstanceDataOStream::enablePush(const uint128_t& version,
      62             :                                            const Nodes& receivers)
      63             : {
      64           2 :     _command = CMD_NODE_OBJECT_INSTANCE_PUSH;
      65           2 :     _nodeID = 0;
      66           2 :     _instanceID = CO_INSTANCE_NONE;
      67           2 :     ObjectDataOStream::enableCommit(version, receivers);
      68           2 : }
      69             : 
      70           4 : void ObjectInstanceDataOStream::enableSync(const uint128_t& version,
      71             :                                            const MasterCMCommand& command)
      72             : {
      73           8 :     NodePtr node = command.getNode();
      74             : 
      75           4 :     _command = CMD_NODE_OBJECT_INSTANCE_SYNC;
      76           4 :     _nodeID = node->getNodeID();
      77           4 :     _instanceID = command.getRequestID(); // ugh
      78           4 :     ObjectDataOStream::enableCommit(version, Nodes(1, node));
      79           4 : }
      80             : 
      81           3 : void ObjectInstanceDataOStream::push(const Nodes& receivers,
      82             :                                      const uint128_t& objectID,
      83             :                                      const uint128_t& groupID,
      84             :                                      const uint128_t& typeID)
      85             : {
      86           3 :     _command = CMD_NODE_OBJECT_INSTANCE_PUSH;
      87           3 :     _nodeID = 0;
      88           3 :     _instanceID = CO_INSTANCE_NONE;
      89           3 :     _setupConnections(receivers);
      90             : 
      91           3 :     _resend();
      92           6 :     OCommand(getConnections(), CMD_NODE_OBJECT_PUSH) << objectID << groupID
      93           3 :                                                      << typeID;
      94             : 
      95           3 :     _clearConnections();
      96           3 : }
      97             : 
      98           0 : void ObjectInstanceDataOStream::sync(const MasterCMCommand& command)
      99             : {
     100           0 :     NodePtr node = command.getNode();
     101             : 
     102           0 :     _command = CMD_NODE_OBJECT_INSTANCE_SYNC;
     103           0 :     _nodeID = node->getNodeID();
     104           0 :     _instanceID = command.getRequestID(); // ugh
     105           0 :     _setupConnections(Nodes(1, node));
     106           0 :     _resend();
     107           0 :     _clearConnections();
     108           0 : }
     109             : 
     110           0 : void ObjectInstanceDataOStream::sendInstanceData(const Nodes& receivers)
     111             : {
     112           0 :     _command = CMD_NODE_OBJECT_INSTANCE;
     113           0 :     _nodeID = 0;
     114           0 :     _instanceID = CO_INSTANCE_NONE;
     115           0 :     _setupConnections(receivers);
     116           0 :     _resend();
     117           0 :     _clearConnections();
     118           0 : }
     119             : 
     120          30 : void ObjectInstanceDataOStream::sendMapData(NodePtr node,
     121             :                                             const uint32_t instanceID)
     122             : {
     123          30 :     _command = CMD_NODE_OBJECT_INSTANCE_MAP;
     124          30 :     _nodeID = node->getNodeID();
     125          30 :     _instanceID = instanceID;
     126          30 :     _setupConnection(node, true /* useMulticast */);
     127          30 :     _resend();
     128          30 :     _clearConnections();
     129          30 : }
     130             : 
     131           2 : void ObjectInstanceDataOStream::enableMap(const uint128_t& version,
     132             :                                           NodePtr node,
     133             :                                           const uint32_t instanceID)
     134             : {
     135           2 :     _command = CMD_NODE_OBJECT_INSTANCE_MAP;
     136           2 :     _nodeID = node->getNodeID();
     137           2 :     _instanceID = instanceID;
     138           2 :     _version = version;
     139           2 :     _setupConnection(node, true /* useMulticast */);
     140           2 :     _enable();
     141           2 : }
     142             : 
     143          51 : void ObjectInstanceDataOStream::sendData(const void* data, const uint64_t size,
     144             :                                          const bool last)
     145             : {
     146          51 :     LBASSERT(_command);
     147         102 :     send(_command, COMMANDTYPE_NODE, _instanceID, data, size, last)
     148         153 :         << _nodeID << _cm->getObject()->getInstanceID();
     149          51 : }
     150          63 : }

Generated by: LCOV version 1.11