LCOV - code coverage report
Current view: top level - eq/server - convert11Visitor.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 5 67 7.5 %
Date: 2017-12-16 05:07:20 Functions: 3 12 25.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           0 : class ResetSegmentEyes : public ServerVisitor
      21             : {
      22           0 :     virtual VisitorResult visit(Segment* segment)
      23             :     {
      24           0 :         if (segment->getEyes() == 0)
      25           0 :             segment->setEyes(EYES_ALL);
      26           0 :         return TRAVERSE_CONTINUE;
      27             :     }
      28             : };
      29             : 
      30         404 : class ConvertTo11Visitor : public ServerVisitor
      31             : {
      32         200 :     virtual VisitorResult visitPre(Config* config)
      33             :     {
      34         200 :         const float version = config->getFAttribute(Config::FATTR_VERSION);
      35         200 :         if (version >= 1.1f)
      36         200 :             return TRAVERSE_PRUNE;
      37             : 
      38           0 :         ServerPtr server = config->getServer();
      39           0 :         if (!server->getConnectionDescriptions().empty())
      40           0 :             return TRAVERSE_CONTINUE;
      41             : 
      42           0 :         const Nodes& nodes = config->getNodes();
      43           0 :         if (nodes.size() > 1)
      44             :         {
      45             :             // RFE 3156103: Add default appNode connection for multi-node config
      46           0 :             LBINFO << "Adding default server connection for multi-node config"
      47           0 :                    << std::endl;
      48           0 :             co::ConnectionDescriptionPtr desc = new co::ConnectionDescription;
      49           0 :             desc->port = 0; // Let the OS choose the port.
      50           0 :             server->addConnectionDescription(desc);
      51             :         }
      52           0 :         return TRAVERSE_CONTINUE;
      53             :     }
      54           0 :     virtual VisitorResult visitPost(Config* config)
      55             :     {
      56             :         // reset eyes of compound-less segments
      57           0 :         ResetSegmentEyes resetEyes;
      58           0 :         config->accept(resetEyes);
      59             : 
      60             :         // set new version
      61           0 :         config->setFAttribute(Config::FATTR_VERSION, 1.1f);
      62           0 :         Global::instance()->setConfigFAttribute(Config::FATTR_VERSION, 1.1f);
      63           0 :         return TRAVERSE_CONTINUE;
      64             :     }
      65             : 
      66           0 :     virtual VisitorResult visitPre(Node* node)
      67             :     {
      68           0 :         if (node->isApplicationNode() &&
      69           0 :             node->getConnectionDescriptions().empty() &&
      70           0 :             node->getConfig()->getNodes().size() > 1)
      71             :         {
      72             :             // RFE 3156103: Add default appNode connection for multi-node
      73             :             // configs
      74           0 :             LBINFO << "Adding default appNode connection for multi-node config"
      75           0 :                    << std::endl;
      76           0 :             node->addConnectionDescription(new ConnectionDescription);
      77             :         }
      78           0 :         return TRAVERSE_PRUNE;
      79             :     }
      80             : 
      81           0 :     virtual VisitorResult visit(Segment* segment)
      82             :     {
      83           0 :         segment->setEyes(0); // eyes will be re-enabled below and above
      84           0 :         return TRAVERSE_CONTINUE;
      85             :     }
      86             : 
      87           0 :     virtual VisitorResult visit(Compound* compound)
      88             :     {
      89           0 :         if (!compound->isDestination())
      90           0 :             return TRAVERSE_CONTINUE;
      91             : 
      92           0 :         Channel* channel = compound->getChannel();
      93           0 :         Segment* segment = channel->getSegment();
      94           0 :         View* view = channel->getView();
      95             : 
      96           0 :         if (segment == 0 || view == 0) // view-less dest compound
      97           0 :             return TRAVERSE_PRUNE;
      98             : 
      99           0 :         uint32_t compoundEyes = compound->getEyes();
     100           0 :         const uint32_t segmentEyes = segment->getEyes();
     101           0 :         Compound* parent = compound->getParent();
     102             : 
     103           0 :         if (compoundEyes != fabric::EYE_UNDEFINED &&
     104           0 :             (compoundEyes & fabric::EYE_CYCLOP) == 0)
     105             :         {
     106           0 :             view->changeMode(View::MODE_STEREO);
     107           0 :             compound->enableEye(fabric::EYE_CYCLOP);
     108             :         }
     109           0 :         while (compoundEyes == fabric::EYE_UNDEFINED && parent)
     110             :         {
     111           0 :             const uint32_t parentEyes = parent->getEyes();
     112           0 :             if (parentEyes == fabric::EYE_UNDEFINED)
     113             :             {
     114           0 :                 parent = parent->getParent();
     115           0 :                 continue;
     116             :             }
     117           0 :             compoundEyes = parentEyes;
     118           0 :             if ((parentEyes & fabric::EYE_CYCLOP) == 0)
     119             :             {
     120           0 :                 view->changeMode(View::MODE_STEREO);
     121           0 :                 parent->enableEye(fabric::EYE_CYCLOP);
     122             :             }
     123           0 :             parent = parent->getParent();
     124             :         }
     125             : 
     126           0 :         if (compoundEyes == fabric::EYE_UNDEFINED)
     127           0 :             compoundEyes = fabric::EYES_ALL;
     128             : 
     129           0 :         segment->setEyes(compoundEyes | segmentEyes | fabric::EYE_CYCLOP);
     130           0 :         return TRAVERSE_PRUNE;
     131             :     }
     132             : };
     133             : }

Generated by: LCOV version 1.11