LCOV - code coverage report
Current view: top level - eq/fabric - nameFinder.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 11 11 100.0 %
Date: 2017-12-16 05:07:20 Functions: 40 342 11.7 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-2012, 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 EQFABRIC_NAMEFINDER_H
      19             : #define EQFABRIC_NAMEFINDER_H
      20             : 
      21             : #include "types.h"
      22             : 
      23             : namespace eq
      24             : {
      25             : namespace fabric
      26             : {
      27             : template <class T, class V>
      28             : class NameFinder : public V
      29             : {
      30             : public:
      31        6796 :     explicit NameFinder(const std::string& name)
      32             :         : _name(name)
      33        6796 :         , _result(0)
      34             :     {
      35        6796 :     }
      36        6796 :     virtual ~NameFinder() {}
      37        7308 :     virtual VisitorResult visitPre(T* entity) { return visit(entity); }
      38       43502 :     virtual VisitorResult visit(T* entity)
      39             :     {
      40       43502 :         if (entity->getName() == _name)
      41             :         {
      42        6796 :             _result = entity;
      43        6796 :             return TRAVERSE_TERMINATE;
      44             :         }
      45       36706 :         return TRAVERSE_CONTINUE;
      46             :     }
      47             : 
      48        6796 :     T* getResult() { return _result; }
      49             : private:
      50             :     const std::string _name;
      51             :     T* _result;
      52             : };
      53             : }
      54             : }
      55             : #endif // EQFABRIC_NAMEFINDER_H

Generated by: LCOV version 1.11