LCOV - code coverage report
Current view: top level - eq/server - canvas.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 39 50 78.0 %
Date: 2017-12-16 05:07:20 Functions: 10 12 83.3 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-2017, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          Cedric Stalder <cedric.stalder@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #include "canvas.h"
      20             : 
      21             : #include "channel.h"
      22             : #include "compound.h"
      23             : #include "config.h"
      24             : #include "configDestCompoundVisitor.h"
      25             : #include "layout.h"
      26             : #include "log.h"
      27             : #include "node.h"
      28             : #include "pipe.h"
      29             : #include "segment.h"
      30             : #include "view.h"
      31             : #include "window.h"
      32             : 
      33             : #include <co/dataIStream.h>
      34             : #include <co/dataOStream.h>
      35             : #include <eq/fabric/log.h>
      36             : #include <eq/fabric/paths.h>
      37             : 
      38             : namespace eq
      39             : {
      40             : namespace server
      41             : {
      42             : typedef fabric::Canvas<Config, Canvas, Segment, Layout> Super;
      43             : 
      44         420 : Canvas::Canvas(Config* parent)
      45             :     : Super(parent)
      46             :     , _state(STATE_STOPPED)
      47         420 :     , _private(0)
      48             : {
      49         420 : }
      50             : 
      51         836 : Canvas::~Canvas()
      52             : {
      53         836 : }
      54             : 
      55        2706 : Segment* Canvas::getSegment(const SegmentPath& path)
      56             : {
      57        2706 :     const Segments& segments = getSegments();
      58        2706 :     LBASSERTINFO(segments.size() > path.segmentIndex,
      59             :                  segments.size() << " <= " << path.segmentIndex);
      60             : 
      61        2706 :     if (segments.size() <= path.segmentIndex)
      62           0 :         return 0;
      63             : 
      64        2706 :     return segments[path.segmentIndex];
      65             : }
      66             : 
      67           4 : ServerPtr Canvas::getServer()
      68             : {
      69           4 :     Config* config = getConfig();
      70           4 :     LBASSERT(config);
      71           4 :     return (config ? config->getServer() : 0);
      72             : }
      73             : 
      74           0 : void Canvas::activateLayout(const uint32_t index)
      75             : {
      76           0 :     if (_state == STATE_RUNNING)
      77           0 :         _switchLayout(getActiveLayoutIndex(), index);
      78             :     else
      79           0 :         Super::activateLayout(index);
      80           0 : }
      81             : 
      82           2 : void Canvas::init()
      83             : {
      84           2 :     LBASSERT(_state == STATE_STOPPED);
      85           2 :     _switchLayout(LB_UNDEFINED_UINT32, getActiveLayoutIndex());
      86           2 :     _state = STATE_RUNNING;
      87           2 : }
      88             : 
      89           2 : void Canvas::exit()
      90             : {
      91           2 :     LBASSERT(_state == STATE_RUNNING || _state == STATE_DELETE);
      92           2 :     _switchLayout(getActiveLayoutIndex(), LB_UNDEFINED_UINT32);
      93           2 :     if (_state == STATE_RUNNING)
      94           2 :         _state = STATE_STOPPED;
      95           2 : }
      96             : 
      97           4 : void Canvas::_switchLayout(const uint32_t oldIndex, const uint32_t newIndex)
      98             : {
      99           4 :     if (oldIndex == newIndex)
     100           0 :         return;
     101             : 
     102           4 :     const Layouts& layouts = getLayouts();
     103           4 :     const size_t nLayouts = layouts.size();
     104           4 :     Layout* oldLayout = (oldIndex >= nLayouts) ? 0 : layouts[oldIndex];
     105           4 :     Layout* newLayout = (newIndex >= nLayouts) ? 0 : layouts[newIndex];
     106             : 
     107           4 :     if (oldLayout)
     108           2 :         oldLayout->trigger(this, false);
     109             : 
     110           4 :     if (newIndex == LB_UNDEFINED_UINT32)
     111           2 :         return;
     112             : 
     113           2 :     Super::activateLayout(newIndex);
     114             : 
     115           2 :     if (newLayout)
     116           2 :         newLayout->trigger(this, true);
     117             : }
     118             : 
     119           0 : void Canvas::postDelete()
     120             : {
     121           0 :     _state = STATE_DELETE;
     122           0 :     getConfig()->postNeedsFinish();
     123           0 : }
     124             : }
     125             : }
     126             : 
     127             : #include "../fabric/canvas.ipp"
     128             : #include "nodeFactory.h"
     129             : 
     130             : template class eq::fabric::Canvas<eq::server::Config, eq::server::Canvas,
     131             :                                   eq::server::Segment, eq::server::Layout>;
     132             : /** @cond IGNORE */
     133             : template std::ostream& eq::fabric::operator<<(
     134             :     std::ostream&,
     135             :     const eq::fabric::Canvas<eq::server::Config, eq::server::Canvas,
     136          60 :                              eq::server::Segment, eq::server::Layout>&);
     137             : /** @endcond */

Generated by: LCOV version 1.11