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 0 : class ResetSegmentEyes : public ServerVisitor
21 : {
22 0 : virtual VisitorResult visit( Segment* segment )
23 : {
24 0 : if( segment->getEyes() == 0 )
25 0 : segment->setEyes( EYES_ALL );
26 0 : return TRAVERSE_CONTINUE;
27 : }
28 : };
29 :
30 236 : class ConvertTo11Visitor : public ServerVisitor
31 : {
32 104 : virtual VisitorResult visitPre( Config* config )
33 : {
34 104 : const float version = config->getFAttribute( Config::FATTR_VERSION );
35 104 : if( version >= 1.1f )
36 104 : return TRAVERSE_PRUNE;
37 :
38 0 : ServerPtr server = config->getServer();
39 0 : if( !server->getConnectionDescriptions().empty( ))
40 0 : return TRAVERSE_CONTINUE;
41 :
42 0 : const Nodes& nodes = config->getNodes();
43 0 : if( nodes.size() > 1 )
44 : {
45 : // RFE 3156103: Add default appNode connection for multi-node config
46 0 : LBINFO << "Adding default server connection for multi-node config"
47 0 : << std::endl;
48 0 : co::ConnectionDescriptionPtr desc = new co::ConnectionDescription;
49 0 : desc->port = EQ_DEFAULT_PORT;
50 0 : server->addConnectionDescription( desc );
51 : }
52 0 : return TRAVERSE_CONTINUE;
53 : }
54 0 : virtual VisitorResult visitPost( Config* config )
55 : {
56 : // reset eyes of compound-less segments
57 0 : ResetSegmentEyes resetEyes;
58 0 : config->accept( resetEyes );
59 :
60 : // set new version
61 0 : config->setFAttribute( Config::FATTR_VERSION, 1.1f );
62 0 : Global::instance()->setConfigFAttribute( Config::FATTR_VERSION, 1.1f );
63 0 : return TRAVERSE_CONTINUE;
64 : }
65 :
66 0 : virtual VisitorResult visitPre( Node* node )
67 : {
68 0 : if( node->isApplicationNode() &&
69 0 : node->getConnectionDescriptions().empty() &&
70 0 : node->getConfig()->getNodes().size() > 1 )
71 : {
72 : //RFE 3156103: Add default appNode connection for multi-node configs
73 0 : LBINFO << "Adding default appNode connection for multi-node config"
74 0 : << std::endl;
75 0 : node->addConnectionDescription( new ConnectionDescription );
76 : }
77 0 : return TRAVERSE_PRUNE;
78 : }
79 :
80 0 : virtual VisitorResult visit( Segment* segment )
81 : {
82 0 : segment->setEyes( 0 ); // eyes will be re-enabled below and above
83 0 : return TRAVERSE_CONTINUE;
84 : }
85 :
86 0 : virtual VisitorResult visit( Compound* compound )
87 : {
88 0 : if( !compound->isDestination() )
89 0 : return TRAVERSE_CONTINUE;
90 :
91 0 : Channel* channel = compound->getChannel();
92 0 : Segment* segment = channel->getSegment();
93 0 : View* view = channel->getView();
94 :
95 0 : if( segment == 0 || view == 0 ) // view-less dest compound
96 0 : return TRAVERSE_PRUNE;
97 :
98 0 : uint32_t compoundEyes = compound->getEyes();
99 0 : const uint32_t segmentEyes = segment->getEyes();
100 0 : Compound* parent = compound->getParent();
101 :
102 0 : if( compoundEyes != fabric::EYE_UNDEFINED &&
103 0 : ( compoundEyes & fabric::EYE_CYCLOP ) == 0 )
104 : {
105 0 : view->changeMode( View::MODE_STEREO );
106 0 : compound->enableEye( fabric::EYE_CYCLOP );
107 : }
108 0 : while( compoundEyes == fabric::EYE_UNDEFINED && parent )
109 : {
110 0 : const uint32_t parentEyes = parent->getEyes();
111 0 : if( parentEyes == fabric::EYE_UNDEFINED )
112 : {
113 0 : parent = parent->getParent();
114 0 : continue;
115 : }
116 0 : compoundEyes = parentEyes;
117 0 : if( ( parentEyes & fabric::EYE_CYCLOP ) == 0 )
118 : {
119 0 : view->changeMode( View::MODE_STEREO );
120 0 : parent->enableEye( fabric::EYE_CYCLOP );
121 : }
122 0 : parent = parent->getParent();
123 : }
124 :
125 0 : if( compoundEyes == fabric::EYE_UNDEFINED )
126 0 : compoundEyes = fabric::EYES_ALL;
127 :
128 0 : segment->setEyes( compoundEyes | segmentEyes | fabric::EYE_CYCLOP );
129 0 : return TRAVERSE_PRUNE;
130 : }
131 : };
132 : }
|