Line data Source code
1 :
2 : /* Copyright (c) 2011, Stefan Eilemann <eile@eyescale.ch>
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 : namespace
19 : {
20 468 : class ConvertTo12Visitor : public ServerVisitor
21 : {
22 214 : virtual VisitorResult visitPre( Config* config )
23 : {
24 214 : const float version = config->getFAttribute( Config::FATTR_VERSION );
25 214 : if( version >= 1.2f )
26 26 : return TRAVERSE_PRUNE;
27 :
28 : // set new version
29 188 : config->setFAttribute( Config::FATTR_VERSION, 1.2f );
30 188 : Global::instance()->setConfigFAttribute( Config::FATTR_VERSION, 1.2f );
31 188 : return TRAVERSE_CONTINUE;
32 : }
33 :
34 398 : virtual VisitorResult visitPre( Node* node )
35 : {
36 398 : if( !node->getHost().empty( ))
37 : {
38 0 : LBWARN << "Pre-1.2 configurations should not have a node host name "
39 0 : << "set: " << node->getHost() << std::endl;
40 0 : return TRAVERSE_PRUNE;
41 : }
42 :
43 : const co::ConnectionDescriptions& descs =
44 398 : node->getConnectionDescriptions();
45 1194 : for( co::ConnectionDescriptionsCIter i = descs.begin();
46 796 : i != descs.end(); ++i )
47 : {
48 256 : const std::string& hostname = (*i)->getHostname();
49 256 : if( hostname.empty( ))
50 0 : continue;
51 :
52 256 : node->setHost( hostname );
53 256 : return TRAVERSE_PRUNE;
54 : }
55 142 : return TRAVERSE_PRUNE;
56 : }
57 : };
58 : }
|