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