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 236 : class ConvertTo12Visitor : public ServerVisitor
21 : {
22 104 : virtual VisitorResult visitPre( Config* config )
23 : {
24 104 : const float version = config->getFAttribute( Config::FATTR_VERSION );
25 104 : if( version >= 1.2f )
26 11 : return TRAVERSE_PRUNE;
27 :
28 : // set new version
29 93 : config->setFAttribute( Config::FATTR_VERSION, 1.2f );
30 93 : Global::instance()->setConfigFAttribute( Config::FATTR_VERSION, 1.2f );
31 93 : return TRAVERSE_CONTINUE;
32 : }
33 :
34 198 : virtual VisitorResult visitPre( Node* node )
35 : {
36 198 : 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 198 : node->getConnectionDescriptions();
45 594 : for( co::ConnectionDescriptionsCIter i = descs.begin();
46 396 : i != descs.end(); ++i )
47 : {
48 128 : const std::string& hostname = (*i)->getHostname();
49 128 : if( hostname.empty( ))
50 0 : continue;
51 :
52 128 : node->setHost( hostname );
53 128 : return TRAVERSE_PRUNE;
54 : }
55 70 : return TRAVERSE_PRUNE;
56 : }
57 : };
58 : }
|