LCOV - code coverage report
Current view: top level - eq - initVisitor.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 16 27 59.3 %
Date: 2016-09-29 05:02:09 Functions: 6 7 85.7 %

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

Generated by: LCOV version 1.11