LCOV - code coverage report
Current view: top level - eq/server - segment.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 52 72 72.2 %
Date: 2016-09-29 05:02:09 Functions: 11 13 84.6 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-2013, Stefan Eilemann <eile@equalizergraphics.com>
       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 "segment.h"
      19             : 
      20             : #include "canvas.h"
      21             : #include "channel.h"
      22             : #include "compound.h"
      23             : #include "config.h"
      24             : #include "configDestCompoundVisitor.h"
      25             : #include "pipe.h"
      26             : #include "view.h"
      27             : #include "window.h"
      28             : 
      29             : #include <eq/fabric/paths.h>
      30             : #include <co/dataOStream.h>
      31             : 
      32             : #include <boost/foreach.hpp>
      33             : 
      34             : namespace eq
      35             : {
      36             : namespace server
      37             : {
      38             : 
      39             : typedef fabric::Segment< Canvas, Segment, Channel > Super;
      40             : 
      41         754 : Segment::Segment( Canvas* parent )
      42             :         : Super( parent )
      43         754 :         , _private( 0 )
      44             : {
      45         754 : }
      46             : 
      47        2256 : Segment::~Segment()
      48             : {
      49             :     ConfigDestCompoundVisitor visitor( _destinationChannels,
      50         752 :                                        false /*activeOnly*/ );
      51         752 :     getConfig()->accept( visitor );
      52         752 :     const Compounds& compounds = visitor.getResult();
      53             : 
      54        2256 :     for( Compounds::const_iterator i = compounds.begin();
      55        1504 :          i != compounds.end(); ++i )
      56             :     {
      57           0 :         Compound* compound = *i;
      58           0 :         while( compound )
      59             :         {
      60           0 :             Compound* parent = compound->getParent();
      61           0 :             delete compound;
      62           0 :             if( parent && parent->isLeaf( )) // empty parent now
      63           0 :                 compound = parent;
      64             :             else
      65           0 :                 compound = 0;
      66             :         }
      67             :     }
      68             : 
      69             :     // Use copy - Channel::unsetOutput modifies vector
      70        1504 :     Channels destinationChannels = _destinationChannels;
      71        5772 :     for( Channels::const_iterator i = destinationChannels.begin();
      72        3848 :          i != destinationChannels.end(); ++i )
      73             :     {
      74        1172 :         Channel* channel = *i;
      75        1172 :         LBASSERT( channel );
      76        1172 :         channel->unsetOutput();
      77             :     }
      78             : 
      79         752 :     LBASSERT( _destinationChannels.empty( ));
      80        1504 :     _destinationChannels.clear();
      81        1504 : }
      82             : 
      83           0 : void Segment::updateFrustum()
      84             : {
      85           0 :     BOOST_FOREACH( Channel* channel, _destinationChannels )
      86             :     {
      87           0 :         View* view = channel->getView();
      88           0 :         view->updateFrusta();
      89             :     }
      90           0 : }
      91             : 
      92         756 : Config* Segment::getConfig()
      93             : {
      94         756 :     Canvas* canvas = getCanvas();
      95         756 :     LBASSERT( canvas );
      96         756 :     return canvas ? canvas->getConfig() : 0;
      97             : }
      98             : 
      99             : 
     100         378 : const Config* Segment::getConfig() const
     101             : {
     102         378 :     const Canvas* canvas = getCanvas();
     103         378 :     LBASSERT( canvas );
     104         378 :     return canvas ? canvas->getConfig() : 0;
     105             : }
     106             : 
     107           4 : ServerPtr Segment::getServer()
     108             : {
     109           4 :     Canvas* canvas = getCanvas();
     110           4 :     LBASSERT( canvas );
     111           4 :     return ( canvas ? canvas->getServer() : 0 );
     112             : }
     113             : 
     114        1174 : void Segment::addDestinationChannel( Channel* channel )
     115             : {
     116        1174 :     LBASSERT( channel );
     117        1174 :     LBASSERT( std::find( _destinationChannels.begin(),
     118             :                          _destinationChannels.end(), channel ) ==
     119             :               _destinationChannels.end( ));
     120             : 
     121        1174 :     _destinationChannels.push_back( channel );
     122        1174 : }
     123             : 
     124        1172 : bool Segment::removeDestinationChannel( Channel* channel )
     125             : {
     126        1172 :     Channels::iterator i = lunchbox::find( _destinationChannels, channel );
     127             : 
     128        1172 :     LBASSERT( i !=  _destinationChannels.end( ));
     129        1172 :     if( i == _destinationChannels.end( ))
     130           0 :         return false;
     131             : 
     132        1172 :     _destinationChannels.erase( i );
     133             : 
     134        1172 :     LBASSERT( lunchbox::find( _destinationChannels, channel ) ==
     135             :               _destinationChannels.end( ));
     136        1172 :     return true;
     137             : }
     138             : 
     139           0 : void Segment::findDestinationChannels( const Layout* layout,
     140             :                                        Channels& result ) const
     141             : {
     142           0 :     for( Channels::const_iterator i = _destinationChannels.begin();
     143           0 :          i != _destinationChannels.end(); ++i )
     144             :     {
     145           0 :         Channel* channel = *i;
     146           0 :         if( channel->getLayout() == layout )
     147           0 :             result.push_back( channel );
     148             :     }
     149           0 : }
     150             : 
     151         594 : SegmentPath Segment::getPath() const
     152             : {
     153         594 :     const Canvas* canvas = getCanvas();
     154         594 :     LBASSERT( canvas );
     155         594 :     SegmentPath path( canvas->getPath( ));
     156             : 
     157         594 :     const Segments& segments = canvas->getSegments();
     158             :     Segments::const_iterator i = std::find( segments.begin(), segments.end(),
     159         594 :                                             this );
     160         594 :     LBASSERT( i != segments.end( ));
     161         594 :     path.segmentIndex = std::distance( segments.begin(), i );
     162         594 :     return path;
     163             : }
     164             : 
     165             : }
     166             : }
     167             : 
     168             : #include "../fabric/segment.ipp"
     169             : template class eq::fabric::Segment< eq::server::Canvas, eq::server::Segment,
     170             :                                     eq::server::Channel >;
     171             : /** @cond IGNORE */
     172             : template std::ostream& eq::fabric::operator << ( std::ostream&,
     173          84 :                                                  const eq::server::Super& );
     174             : /** @endcond */

Generated by: LCOV version 1.11