Line data Source code
1 :
2 : /* Copyright (c) 2005-2013, Stefan Eilemann <eile@equalizergraphics.com>
3 : * 2012, Daniel Nachbaur <danielnachbaur@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 "configParams.h"
20 :
21 : #include "equalizer.h"
22 : #include "global.h"
23 :
24 : #include <co/dataOStream.h>
25 : #include <co/dataIStream.h>
26 : #include <co/global.h>
27 :
28 : namespace eq
29 : {
30 : namespace fabric
31 : {
32 : namespace detail
33 : {
34 194 : class ConfigParams
35 : {
36 : public:
37 16 : ConfigParams()
38 16 : : flags( eq::fabric::Global::getFlags( ))
39 32 : , prefixes( eq::fabric::Global::getPrefixes( ))
40 : {
41 16 : switch( flags & fabric::ConfigParams::FLAG_LOAD_EQ_ALL )
42 : {
43 : case fabric::ConfigParams::FLAG_LOAD_EQ_2D:
44 0 : equalizer.setMode( fabric::Equalizer::MODE_2D );
45 0 : break;
46 : case fabric::ConfigParams::FLAG_LOAD_EQ_HORIZONTAL:
47 0 : equalizer.setMode( fabric::Equalizer::MODE_HORIZONTAL );
48 0 : break;
49 : case fabric::ConfigParams::FLAG_LOAD_EQ_VERTICAL:
50 0 : equalizer.setMode( fabric::Equalizer::MODE_VERTICAL );
51 0 : break;
52 : case fabric::ConfigParams::FLAG_NONE:
53 16 : break;
54 : default:
55 0 : LBUNIMPLEMENTED;
56 : }
57 16 : }
58 :
59 : std::string renderClient;
60 : std::string workDir;
61 : uint32_t flags;
62 : fabric::Equalizer equalizer;
63 : Strings prefixes;
64 : std::string gpuFilter;
65 : };
66 : }
67 :
68 16 : ConfigParams::ConfigParams()
69 16 : : _impl( new detail::ConfigParams )
70 : {
71 16 : }
72 :
73 89 : ConfigParams::ConfigParams( const ConfigParams& rhs )
74 89 : : _impl( new detail::ConfigParams( *rhs._impl ))
75 : {
76 89 : }
77 :
78 0 : ConfigParams& ConfigParams::operator = ( const ConfigParams& rhs )
79 : {
80 0 : if( this == &rhs )
81 0 : return *this;
82 :
83 0 : *_impl = *rhs._impl;
84 0 : return *this;
85 : }
86 :
87 105 : ConfigParams::~ConfigParams()
88 : {
89 105 : delete _impl;
90 105 : }
91 :
92 10 : void ConfigParams::setRenderClient( const std::string& renderClient )
93 : {
94 10 : _impl->renderClient = renderClient;
95 : #ifdef _WIN32 // replace dir delimiters since '\' is often used as escape char
96 : std::replace( _impl->renderClient.begin(),
97 : _impl->renderClient.end(), '\\', '/' );
98 : #endif
99 10 : }
100 :
101 30 : const std::string& ConfigParams::getRenderClient() const
102 : {
103 30 : return _impl->renderClient;
104 : }
105 :
106 10 : void ConfigParams::setWorkDir( const std::string& workDir )
107 : {
108 10 : _impl->workDir = workDir;
109 : #ifdef _WIN32 // replace dir delimiters since '\' is often used as escape char
110 : std::replace( _impl->workDir.begin(), _impl->workDir.end(), '\\', '/' );
111 : #endif
112 10 : }
113 :
114 20 : const std::string& ConfigParams::getWorkDir() const
115 : {
116 20 : return _impl->workDir;
117 : }
118 :
119 2 : void ConfigParams::setFlags( const uint32_t flags )
120 : {
121 2 : _impl->flags = flags;
122 2 : }
123 :
124 315 : uint32_t ConfigParams::getFlags() const
125 : {
126 315 : return _impl->flags;
127 : }
128 :
129 0 : const Equalizer& ConfigParams::getEqualizer() const
130 : {
131 0 : return _impl->equalizer;
132 : }
133 :
134 112 : Equalizer& ConfigParams::getEqualizer()
135 : {
136 112 : return _impl->equalizer;
137 : }
138 :
139 0 : void ConfigParams::setPrefixes( const Strings& prefixes )
140 : {
141 0 : _impl->prefixes = prefixes;
142 0 : }
143 :
144 8 : const Strings& ConfigParams::getPrefixes() const
145 : {
146 8 : return _impl->prefixes;
147 : }
148 :
149 10 : void ConfigParams::setGPUFilter( const std::string& regex )
150 : {
151 10 : _impl->gpuFilter = regex;
152 10 : }
153 :
154 18 : const std::string& ConfigParams::getGPUFilter() const
155 : {
156 18 : return _impl->gpuFilter;
157 : }
158 :
159 10 : void ConfigParams::serialize( co::DataOStream& os ) const
160 : {
161 10 : os << _impl->renderClient << _impl->workDir << _impl->flags
162 20 : << _impl->equalizer << _impl->prefixes << _impl->gpuFilter;
163 10 : }
164 :
165 10 : void ConfigParams::deserialize( co::DataIStream& is )
166 : {
167 10 : is >> _impl->renderClient >> _impl->workDir >> _impl->flags
168 20 : >> _impl->equalizer >> _impl->prefixes >> _impl->gpuFilter;
169 10 : }
170 :
171 10 : co::DataOStream& operator << ( co::DataOStream& os, const ConfigParams& params )
172 : {
173 10 : params.serialize( os );
174 10 : return os;
175 : }
176 :
177 10 : co::DataIStream& operator >> ( co::DataIStream& is, ConfigParams& params )
178 : {
179 10 : params.deserialize( is );
180 10 : return is;
181 : }
182 :
183 : }
184 45 : }
|