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 16 : class ConfigParams
35 : {
36 : public:
37 8 : ConfigParams()
38 8 : : flags( eq::fabric::Global::getFlags( ))
39 16 : , prefixes( eq::fabric::Global::getPrefixes( ))
40 : {
41 8 : 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 8 : break;
54 : default:
55 0 : LBUNIMPLEMENTED;
56 : }
57 8 : }
58 :
59 : std::string name;
60 : std::string renderClient;
61 : std::string workDir;
62 : uint32_t flags;
63 : fabric::Equalizer equalizer;
64 : Strings prefixes;
65 : std::string gpuFilter;
66 : };
67 : }
68 :
69 8 : ConfigParams::ConfigParams()
70 8 : : _impl( new detail::ConfigParams )
71 : {
72 8 : }
73 :
74 4 : ConfigParams::ConfigParams( const ConfigParams& rhs )
75 4 : : _impl( new detail::ConfigParams( *rhs._impl ))
76 : {
77 4 : }
78 :
79 0 : ConfigParams& ConfigParams::operator = ( const ConfigParams& rhs )
80 : {
81 0 : if( this == &rhs )
82 0 : return *this;
83 :
84 0 : *_impl = *rhs._impl;
85 0 : return *this;
86 : }
87 :
88 12 : ConfigParams::~ConfigParams()
89 : {
90 12 : delete _impl;
91 12 : }
92 :
93 4 : void ConfigParams::setName( const std::string& name )
94 : {
95 4 : _impl->name = name;
96 4 : }
97 :
98 4 : const std::string& ConfigParams::getName() const
99 : {
100 4 : return _impl->name;
101 : }
102 :
103 4 : void ConfigParams::setRenderClient( const std::string& renderClient )
104 : {
105 4 : _impl->renderClient = renderClient;
106 : #ifdef _WIN32 // replace dir delimiters since '\' is often used as escape char
107 : std::replace( _impl->renderClient.begin(),
108 : _impl->renderClient.end(), '\\', '/' );
109 : #endif
110 4 : }
111 :
112 12 : const std::string& ConfigParams::getRenderClient() const
113 : {
114 12 : return _impl->renderClient;
115 : }
116 :
117 4 : void ConfigParams::setWorkDir( const std::string& workDir )
118 : {
119 4 : _impl->workDir = workDir;
120 : #ifdef _WIN32 // replace dir delimiters since '\' is often used as escape char
121 : std::replace( _impl->workDir.begin(), _impl->workDir.end(), '\\', '/' );
122 : #endif
123 4 : }
124 :
125 8 : const std::string& ConfigParams::getWorkDir() const
126 : {
127 8 : return _impl->workDir;
128 : }
129 :
130 2 : void ConfigParams::setFlags( const uint32_t flags )
131 : {
132 2 : _impl->flags = flags;
133 2 : }
134 :
135 0 : uint32_t ConfigParams::getFlags() const
136 : {
137 0 : return _impl->flags;
138 : }
139 :
140 0 : const Equalizer& ConfigParams::getEqualizer() const
141 : {
142 0 : return _impl->equalizer;
143 : }
144 :
145 0 : Equalizer& ConfigParams::getEqualizer()
146 : {
147 0 : return _impl->equalizer;
148 : }
149 :
150 0 : void ConfigParams::setPrefixes( const Strings& prefixes )
151 : {
152 0 : _impl->prefixes = prefixes;
153 0 : }
154 :
155 0 : const Strings& ConfigParams::getPrefixes() const
156 : {
157 0 : return _impl->prefixes;
158 : }
159 :
160 4 : void ConfigParams::setGPUFilter( const std::string& regex )
161 : {
162 4 : _impl->gpuFilter = regex;
163 4 : }
164 :
165 4 : const std::string& ConfigParams::getGPUFilter() const
166 : {
167 4 : return _impl->gpuFilter;
168 : }
169 :
170 4 : void ConfigParams::serialize( co::DataOStream& os ) const
171 : {
172 4 : os << _impl->name << _impl->renderClient << _impl->workDir << _impl->flags
173 8 : << _impl->equalizer << _impl->prefixes << _impl->gpuFilter;
174 4 : }
175 :
176 4 : void ConfigParams::deserialize( co::DataIStream& is )
177 : {
178 4 : is >> _impl->name >> _impl->renderClient >> _impl->workDir >> _impl->flags
179 8 : >> _impl->equalizer >> _impl->prefixes >> _impl->gpuFilter;
180 4 : }
181 :
182 4 : co::DataOStream& operator << ( co::DataOStream& os, const ConfigParams& params )
183 : {
184 4 : params.serialize( os );
185 4 : return os;
186 : }
187 :
188 4 : co::DataIStream& operator >> ( co::DataIStream& is, ConfigParams& params )
189 : {
190 4 : params.deserialize( is );
191 4 : return is;
192 : }
193 :
194 : }
195 84 : }
|