Line data Source code
1 :
2 : /* Copyright (c) 2010-2013, Stefan Eilemann <eile@equalizergraphics.com>
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 : #ifndef EQSERVER_CONFIGDESTCOMPOUNDVISITOR_H
19 : #define EQSERVER_CONFIGDESTCOMPOUNDVISITOR_H
20 :
21 : #include "configVisitor.h" // base class
22 : #include "compound.h" // used in inline method
23 :
24 : namespace eq
25 : {
26 : namespace server
27 : {
28 : namespace
29 : {
30 :
31 : class ConfigDestCompoundVisitor : public ConfigVisitor
32 : {
33 : public:
34 374 : ConfigDestCompoundVisitor( const Channels& channels, const bool ao )
35 374 : : _channels( channels ), _activeOnly( ao ) {}
36 16 : ConfigDestCompoundVisitor( Channel* channel, const bool ao )
37 16 : : _activeOnly( ao ) { _channels.push_back( channel ); }
38 390 : virtual ~ConfigDestCompoundVisitor() {}
39 :
40 220 : virtual VisitorResult visit( Compound* compound )
41 : {
42 220 : Channel* channel = compound->getChannel();
43 220 : if( !channel )
44 110 : return TRAVERSE_CONTINUE;
45 :
46 : // Not in our search list
47 110 : Channels::const_iterator i = lunchbox::find( _channels, channel );
48 110 : if( i == _channels.end( ))
49 94 : return TRAVERSE_PRUNE;
50 :
51 16 : if( _activeOnly )
52 : {
53 : // Not an active compound
54 16 : const Canvas* canvas = channel->getCanvas();
55 32 : if( !canvas ||
56 16 : canvas->getActiveLayout() != channel->getLayout( ))
57 : {
58 0 : return TRAVERSE_PRUNE;
59 : }
60 : }
61 16 : _result.push_back( compound );
62 16 : return TRAVERSE_PRUNE;
63 : }
64 :
65 390 : const Compounds& getResult() const { return _result; }
66 :
67 : private:
68 : Channels _channels;
69 : Compounds _result;
70 : const bool _activeOnly;
71 : };
72 :
73 : }
74 : }
75 : }
76 :
77 : #endif // EQSERVER_CONFIGDESTCOMPOUNDVISITOR_H
|