LCOV - code coverage report
Current view: top level - eq/server - configDestCompoundVisitor.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 18 20 90.0 %
Date: 2016-07-30 05:04:55 Functions: 5 6 83.3 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-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             : #ifndef EQSERVER_CONFIGDESTCOMPOUNDVISITOR_H
      19             : #define EQSERVER_CONFIGDESTCOMPOUNDVISITOR_H
      20             : 
      21             : #include "configVisitor.h" // base class
      22             : #include "compound.h" // used in inline method
      23             : 
      24             : namespace eq
      25             : {
      26             : namespace server
      27             : {
      28             : namespace
      29             : {
      30             : 
      31             : class ConfigDestCompoundVisitor : public ConfigVisitor
      32             : {
      33             : public:
      34         752 :     ConfigDestCompoundVisitor( const Channels& channels, const bool ao )
      35         752 :             : _channels( channels ), _activeOnly( ao ) {}
      36           4 :     ConfigDestCompoundVisitor( Channel* channel, const bool ao )
      37           4 :             : _activeOnly( ao ) { _channels.push_back( channel ); }
      38         756 :     virtual ~ConfigDestCompoundVisitor() {}
      39             : 
      40           8 :     virtual VisitorResult visit( Compound* compound )
      41             :         {
      42           8 :             Channel* channel = compound->getChannel();
      43           8 :             if( !channel )
      44           4 :                 return TRAVERSE_CONTINUE;
      45             : 
      46             :             // Not in our search list
      47           4 :             Channels::const_iterator i = lunchbox::find( _channels, channel );
      48           4 :             if( i == _channels.end( ))
      49           0 :                 return TRAVERSE_PRUNE;
      50             : 
      51           4 :             if( _activeOnly )
      52             :             {
      53             :                 // Not an active compound
      54           4 :                 const Canvas* canvas = channel->getCanvas();
      55           8 :                 if( !canvas ||
      56           4 :                     canvas->getActiveLayout() != channel->getLayout( ))
      57             :                 {
      58           0 :                     return TRAVERSE_PRUNE;
      59             :                 }
      60             :             }
      61           4 :             _result.push_back( compound );
      62           4 :             return TRAVERSE_PRUNE;
      63             :         }
      64             : 
      65         756 :     const Compounds& getResult() const { return _result; }
      66             : 
      67             : private:
      68             :     Channels _channels;
      69             :     Compounds _result;
      70             :     const bool _activeOnly;
      71             : };
      72             : 
      73             : }
      74             : }
      75             : }
      76             : 
      77             : #endif // EQSERVER_CONFIGDESTCOMPOUNDVISITOR_H

Generated by: LCOV version 1.11