LCOV - code coverage report
Current view: top level - eq/server - configDestCompoundVisitor.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 22 23 95.7 %
Date: 2017-12-16 05:07:20 Functions: 5 6 83.3 %

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

Generated by: LCOV version 1.11