LCOV - code coverage report
Current view: top level - eq/fabric - windowSettings.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 57 58 98.3 %
Date: 2017-12-16 05:07:20 Functions: 18 19 94.7 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2014, Daniel Nachbaur <danielnachbaur@gmail.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             : #include "windowSettings.h"
      19             : #include "iAttribute.h"
      20             : #include "window.h"
      21             : 
      22             : #include <co/dataIStream.h>
      23             : #include <co/dataOStream.h>
      24             : 
      25             : namespace eq
      26             : {
      27             : namespace fabric
      28             : {
      29             : namespace detail
      30             : {
      31             : class WindowSettings
      32             : {
      33             : public:
      34        2996 :     WindowSettings()
      35        2996 :     {
      36        2996 :         memset(iAttributes, 0xff,
      37        2996 :                fabric::WindowSettings::IATTR_ALL * sizeof(int32_t));
      38        2996 :     }
      39        3004 :     ~WindowSettings() {}
      40          12 :     WindowSettings(const WindowSettings& rhs)
      41          12 :         : pixelViewport(rhs.pixelViewport)
      42          12 :         , windowName(rhs.windowName)
      43             :     {
      44          12 :         memcpy(iAttributes, rhs.iAttributes,
      45          12 :                fabric::WindowSettings::IATTR_ALL * sizeof(int32_t));
      46          12 :     }
      47             : 
      48           4 :     WindowSettings& operator=(const WindowSettings& rhs)
      49             :     {
      50           4 :         if (this == &rhs)
      51           0 :             return *this;
      52             : 
      53           4 :         memcpy(iAttributes, rhs.iAttributes,
      54           4 :                fabric::WindowSettings::IATTR_ALL * sizeof(int32_t));
      55           4 :         pixelViewport = rhs.pixelViewport;
      56           4 :         windowName = rhs.windowName;
      57           4 :         return *this;
      58             :     }
      59             : 
      60             :     int32_t iAttributes[fabric::WindowSettings::IATTR_ALL];
      61             : 
      62             :     PixelViewport pixelViewport;
      63             :     std::string windowName;
      64             : };
      65             : }
      66             : 
      67        2996 : WindowSettings::WindowSettings()
      68        2996 :     : _impl(new detail::WindowSettings())
      69             : {
      70        2996 : }
      71             : 
      72          12 : WindowSettings::WindowSettings(const WindowSettings& rhs)
      73          12 :     : _impl(new detail::WindowSettings(*rhs._impl))
      74             : {
      75          12 : }
      76             : 
      77        6008 : WindowSettings::~WindowSettings()
      78             : {
      79        3004 :     delete _impl;
      80        3004 : }
      81             : 
      82           4 : WindowSettings& WindowSettings::operator=(const WindowSettings& rhs)
      83             : {
      84           4 :     *_impl = *rhs._impl;
      85           4 :     return *this;
      86             : }
      87             : 
      88       31706 : bool WindowSettings::setIAttribute(const IAttribute attr, const int32_t value)
      89             : {
      90       31706 :     if (_impl->iAttributes[attr] == value)
      91       14262 :         return false;
      92             : 
      93       17444 :     _impl->iAttributes[attr] = value;
      94       17444 :     return true;
      95             : }
      96             : 
      97       16052 : int32_t WindowSettings::getIAttribute(const IAttribute attr) const
      98             : {
      99       16052 :     return _impl->iAttributes[attr];
     100             : }
     101             : 
     102        4860 : const PixelViewport& WindowSettings::getPixelViewport() const
     103             : {
     104        4860 :     return _impl->pixelViewport;
     105             : }
     106             : 
     107        1708 : void WindowSettings::setPixelViewport(const PixelViewport& pvp)
     108             : {
     109        1708 :     _impl->pixelViewport = pvp;
     110        1708 : }
     111             : 
     112         544 : void WindowSettings::setName(const std::string& name)
     113             : {
     114         544 :     _impl->windowName = name;
     115         544 : }
     116             : 
     117         550 : const std::string& WindowSettings::getName() const
     118             : {
     119         550 :     return _impl->windowName;
     120             : }
     121             : 
     122          12 : void WindowSettings::serialize(co::DataOStream& os) const
     123             : {
     124          24 :     os << co::Array<int32_t>(_impl->iAttributes, IATTR_ALL)
     125          24 :        << _impl->pixelViewport << _impl->windowName;
     126          12 : }
     127             : 
     128          12 : void WindowSettings::deserialize(co::DataIStream& is)
     129             : {
     130          24 :     is >> co::Array<int32_t>(_impl->iAttributes, IATTR_ALL) >>
     131          24 :         _impl->pixelViewport >> _impl->windowName;
     132          12 : }
     133             : }
     134          60 : }

Generated by: LCOV version 1.11