LCOV - code coverage report
Current view: top level - eq/client - initVisitor.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 15 24 62.5 %
Date: 2014-06-18 Functions: 6 7 85.7 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2013-2014, 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             : namespace eq
      19             : {
      20             : namespace detail
      21             : {
      22           8 : class InitVisitor : public ConfigVisitor
      23             : {
      24             : public:
      25           8 :     InitVisitor( const Strings& activeLayouts, const float modelUnit )
      26           8 :         : _layouts( activeLayouts ), _modelUnit( modelUnit ), _update( false )
      27           8 :     {}
      28             : 
      29           8 :     virtual VisitorResult visit( eq::Observer* observer )
      30             :     {
      31           8 :         if( observer->configInit( ))
      32           8 :             return TRAVERSE_CONTINUE;
      33           0 :         LBWARN << *observer << " initialization failed" << std::endl;
      34           0 :         return TRAVERSE_TERMINATE;
      35             :     }
      36             : 
      37          55 :     virtual VisitorResult visit( eq::View* view )
      38             :     {
      39          55 :         if( view->setModelUnit( _modelUnit ))
      40           0 :             _update = true;
      41          55 :         return TRAVERSE_CONTINUE;
      42             :     }
      43             : 
      44           8 :     virtual VisitorResult visitPre( eq::Canvas* canvas )
      45             :     {
      46           8 :         const Layouts& layouts = canvas->getLayouts();
      47             : 
      48           8 :         for( StringsCIter i = _layouts.begin(); i != _layouts.end(); ++i )
      49             :         {
      50           0 :             const std::string& name = *i;
      51           0 :             for( LayoutsCIter j = layouts.begin(); j != layouts.end(); ++j )
      52             :             {
      53           0 :                 const eq::Layout* layout = *j;
      54           0 :                 if( layout->getName() == name &&
      55           0 :                     canvas->useLayout( j - layouts.begin( )))
      56             :                 {
      57           0 :                     _update = true;
      58             :                 }
      59             :             }
      60             :         }
      61           8 :         return TRAVERSE_CONTINUE;
      62             :     }
      63             : 
      64           8 :     bool needsUpdate() const { return _update; }
      65             : 
      66             : private:
      67             :     const Strings& _layouts;
      68             :     const float _modelUnit;
      69             :     bool _update;
      70             : };
      71             : }
      72             : }

Generated by: LCOV version 1.10