LCOV - code coverage report
Current view: top level - eq/server - canvas.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 43 50 86.0 %
Date: 2016-07-30 05:04:55 Functions: 11 12 91.7 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-2011, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                    2010, Cedric Stalder <cedric.stalder@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 "canvas.h"
      20             : 
      21             : #include "channel.h"
      22             : #include "compound.h"
      23             : #include "config.h"
      24             : #include "configDestCompoundVisitor.h"
      25             : #include "layout.h"
      26             : #include "log.h"
      27             : #include "node.h"
      28             : #include "pipe.h"
      29             : #include "segment.h"
      30             : #include "view.h"
      31             : #include "window.h"
      32             : 
      33             : #include <eq/fabric/log.h>
      34             : #include <eq/fabric/paths.h>
      35             : #include <co/dataIStream.h>
      36             : #include <co/dataOStream.h>
      37             : #include <lunchbox/stdExt.h>
      38             : 
      39             : namespace eq
      40             : {
      41             : namespace server
      42             : {
      43             : typedef fabric::Canvas< Config, Canvas, Segment, Layout > Super;
      44             : 
      45         442 : Canvas::Canvas( Config* parent )
      46             :         : Super( parent )
      47             :         , _state( STATE_STOPPED )
      48         442 :         , _private( 0 )
      49         442 : {}
      50             : 
      51         880 : Canvas::~Canvas()
      52             : {
      53         880 : }
      54             : 
      55        2672 : Segment* Canvas::getSegment( const SegmentPath& path )
      56             : {
      57        2672 :     const Segments& segments = getSegments();
      58        2672 :     LBASSERTINFO( segments.size() > path.segmentIndex,
      59             :                   segments.size() << " <= " << path.segmentIndex );
      60             : 
      61        2672 :     if( segments.size() <= path.segmentIndex )
      62           0 :         return 0;
      63             : 
      64        2672 :     return segments[ path.segmentIndex ];
      65             : }
      66             : 
      67           8 : ServerPtr Canvas::getServer()
      68             : {
      69           8 :     Config* config = getConfig();
      70           8 :     LBASSERT( config );
      71           8 :     return ( config ? config->getServer() : 0 );
      72             : }
      73             : 
      74           4 : void Canvas::activateLayout( const uint32_t index )
      75             : {
      76           4 :     if( _state == STATE_RUNNING )
      77           0 :         _switchLayout( getActiveLayoutIndex(), index );
      78             :     else
      79           4 :         Super::activateLayout( index );
      80           4 : }
      81             : 
      82           2 : void Canvas::init()
      83             : {
      84           2 :     LBASSERT( _state == STATE_STOPPED );
      85           2 :     _switchLayout( LB_UNDEFINED_UINT32, getActiveLayoutIndex( ));
      86           2 :     _state = STATE_RUNNING;
      87           2 : }
      88             : 
      89           2 : void Canvas::exit()
      90             : {
      91           2 :     LBASSERT( _state == STATE_RUNNING || _state == STATE_DELETE );
      92           2 :     _switchLayout( getActiveLayoutIndex(), LB_UNDEFINED_UINT32 );
      93           2 :     if( _state == STATE_RUNNING )
      94           2 :         _state = STATE_STOPPED;
      95           2 : }
      96             : 
      97           4 : void Canvas::_switchLayout( const uint32_t oldIndex, const uint32_t newIndex )
      98             : {
      99           4 :     if( oldIndex == newIndex )
     100           0 :         return;
     101             : 
     102           4 :     const Layouts& layouts = getLayouts();
     103           4 :     const size_t nLayouts = layouts.size();
     104           4 :     Layout* oldLayout = (oldIndex >= nLayouts) ? 0 : layouts[oldIndex];
     105           4 :     Layout* newLayout = (newIndex >= nLayouts) ? 0 : layouts[newIndex];
     106             : 
     107           4 :     if( oldLayout )
     108           2 :         oldLayout->trigger( this, false );
     109             : 
     110           4 :     if( newIndex == LB_UNDEFINED_UINT32 )
     111           2 :         return;
     112             : 
     113           2 :     Super::activateLayout( newIndex );
     114             : 
     115           2 :     if( newLayout )
     116           2 :         newLayout->trigger( this, true );
     117             : }
     118             : 
     119           0 : void Canvas::postDelete()
     120             : {
     121           0 :     _state = STATE_DELETE;
     122           0 :     getConfig()->postNeedsFinish();
     123           0 : }
     124             : 
     125             : }
     126             : }
     127             : 
     128             : #include "nodeFactory.h"
     129             : #include "../fabric/canvas.ipp"
     130             : 
     131             : template class eq::fabric::Canvas< eq::server::Config, eq::server::Canvas,
     132             :                                    eq::server::Segment, eq::server::Layout >;
     133             : /** @cond IGNORE */
     134             : template std::ostream& eq::fabric::operator << ( std::ostream&,
     135             :     const eq::fabric::Canvas< eq::server::Config, eq::server::Canvas,
     136          84 :                               eq::server::Segment, eq::server::Layout >& );
     137             : /** @endcond */

Generated by: LCOV version 1.11