LCOV - code coverage report
Current view: top level - seq/detail - pipe.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 1 69 1.4 %
Date: 2016-07-30 05:04:55 Functions: 2 17 11.8 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2011-2015, Stefan Eilemann <eile@eyescale.ch>
       3             :  *                          Petros Kataras <petroskataras@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #include "pipe.h"
      20             : 
      21             : #include "config.h"
      22             : #include "node.h"
      23             : #include "objectMap.h"
      24             : #include "renderer.h"
      25             : 
      26             : #include <seq/application.h>
      27             : #include <seq/error.h>
      28             : #include <seq/renderer.h>
      29             : 
      30             : namespace seq
      31             : {
      32             : namespace detail
      33             : {
      34             : 
      35           0 : Pipe::Pipe( eq::Node* parent )
      36             :         : eq::Pipe( parent )
      37             :         , _objects( 0 )
      38           0 :         , _renderer( 0 )
      39           0 : {}
      40             : 
      41           0 : Pipe::~Pipe()
      42             : {
      43           0 :     LBASSERT( !_objects );
      44           0 : }
      45             : 
      46           0 : seq::Application* Pipe::getApplication()
      47             : {
      48           0 :     return getConfig()->getApplication();
      49             : }
      50             : 
      51           0 : Config* Pipe::getConfig()
      52             : {
      53           0 :     return getNode()->getConfig();
      54             : }
      55             : 
      56           0 : Node* Pipe::getNode()
      57             : {
      58           0 :     return static_cast< Node* >( eq::Pipe::getNode( ));
      59             : }
      60             : 
      61           0 : detail::Renderer* Pipe::getRendererImpl()
      62             : {
      63           0 :     LBASSERT( _renderer );
      64           0 :     if( !_renderer )
      65           0 :         return 0;
      66           0 :     return _renderer->getImpl();
      67             : }
      68             : 
      69           0 : co::Object* Pipe::getFrameData()
      70             : {
      71           0 :     LBASSERT( _objects );
      72           0 :     if( _objects )
      73           0 :         return _objects->getFrameData();
      74           0 :     return 0;
      75             : }
      76             : 
      77           0 : ObjectMap* Pipe::getObjectMap()
      78             : {
      79           0 :    return _objects;
      80             : }
      81             : 
      82           0 : bool Pipe::configInit( const uint128_t& initID )
      83             : {
      84           0 :     if( !eq::Pipe::configInit( initID ))
      85           0 :         return false;
      86             : 
      87           0 :     LBASSERT( !_renderer );
      88           0 :     _renderer = getApplication()->createRenderer();
      89           0 :     if( !_renderer )
      90             :     {
      91           0 :         LBASSERT( _renderer );
      92           0 :         sendError( ERROR_SEQUEL_CREATERENDERER_FAILED );
      93           0 :         return false;
      94             :     }
      95           0 :     getRendererImpl()->setPipe( this );
      96             : 
      97           0 :     if( _mapData( initID ))
      98           0 :         return true;
      99             : 
     100           0 :     sendError( ERROR_SEQUEL_MAPOBJECT_FAILED );
     101           0 :     return false;
     102             : }
     103             : 
     104           0 : bool Pipe::configExit()
     105             : {
     106           0 :     _unmapData();
     107             : 
     108           0 :     if( _renderer )
     109             :     {
     110           0 :         getRendererImpl()->setPipe( 0 );
     111           0 :         getApplication()->destroyRenderer( _renderer );
     112             :     }
     113           0 :     _renderer = 0;
     114             : 
     115           0 :     return eq::Pipe::configExit();
     116             : }
     117             : 
     118           0 : void Pipe::frameStart( const uint128_t& frameID, const uint32_t frameNumber )
     119             : {
     120           0 :     _syncData( frameID );
     121           0 :     return eq::Pipe::frameStart( frameID, frameNumber );
     122             : }
     123             : 
     124           0 : bool Pipe::_mapData( const uint128_t& initID )
     125             : {
     126           0 :     LBASSERT( !_objects );
     127           0 :     LBASSERT( _renderer );
     128             : 
     129           0 :     Config* config = getConfig();
     130           0 :     _objects = new ObjectMap( *config, *_renderer );
     131             :     const uint32_t request = config->mapObjectNB( _objects, initID,
     132             :                                                   co::VERSION_OLDEST,
     133           0 :                                                   config->getApplicationNode());
     134           0 :     if( !config->mapObjectSync( request ))
     135           0 :         return false;
     136           0 :     return true;
     137             : }
     138             : 
     139           0 : void Pipe::_syncData( const uint128_t& version )
     140             : {
     141           0 :     LBASSERT( _objects )
     142           0 :     _objects->sync( version );
     143           0 : }
     144             : 
     145           0 : void Pipe::_unmapData()
     146             : {
     147           0 :     LBASSERT( _objects )
     148           0 :         getConfig()->unmapObject( _objects );
     149           0 :     _objects->clear();
     150           0 :     delete _objects;
     151           0 :     _objects = 0;
     152           0 : }
     153             : 
     154             : }
     155          42 : }

Generated by: LCOV version 1.11