LCOV - code coverage report
Current view: top level - seq/detail - pipe.cpp (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 58 67 86.6 %
Date: 2014-06-18 Functions: 16 16 100.0 %

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

Generated by: LCOV version 1.10