LCOV - code coverage report
Current view: top level - eq/server - convert12Visitor.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 18 22 81.8 %
Date: 2017-12-16 05:07:20 Functions: 4 5 80.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2011, Stefan Eilemann <eile@eyescale.ch>
       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
      19             : {
      20         404 : class ConvertTo12Visitor : public ServerVisitor
      21             : {
      22         200 :     virtual VisitorResult visitPre(Config* config)
      23             :     {
      24         200 :         const float version = config->getFAttribute(Config::FATTR_VERSION);
      25         200 :         if (version >= 1.2f)
      26          24 :             return TRAVERSE_PRUNE;
      27             : 
      28             :         // set new version
      29         176 :         config->setFAttribute(Config::FATTR_VERSION, 1.2f);
      30         176 :         Global::instance()->setConfigFAttribute(Config::FATTR_VERSION, 1.2f);
      31         176 :         return TRAVERSE_CONTINUE;
      32             :     }
      33             : 
      34         380 :     virtual VisitorResult visitPre(Node* node)
      35             :     {
      36         380 :         if (!node->getHost().empty())
      37             :         {
      38           0 :             LBWARN << "Pre-1.2 configurations should not have a node host name "
      39           0 :                    << "set: " << node->getHost() << std::endl;
      40           0 :             return TRAVERSE_PRUNE;
      41             :         }
      42             : 
      43             :         const co::ConnectionDescriptions& descs =
      44         380 :             node->getConnectionDescriptions();
      45        1140 :         for (co::ConnectionDescriptionsCIter i = descs.begin();
      46         760 :              i != descs.end(); ++i)
      47             :         {
      48         246 :             const std::string& hostname = (*i)->getHostname();
      49         246 :             if (hostname.empty())
      50           0 :                 continue;
      51             : 
      52         246 :             node->setHost(hostname);
      53         246 :             return TRAVERSE_PRUNE;
      54             :         }
      55         134 :         return TRAVERSE_PRUNE;
      56             :     }
      57             : };
      58             : }

Generated by: LCOV version 1.11