Line data Source code
1 :
2 : /* Copyright (c) 2009-2013, Stefan Eilemann <eile@equalizergraphics.com>
3 : * 2010, Cedric Stalder <cedric.stalder@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 : #ifndef EQSERVER_COMPOUNDACTIVATEVISITOR_H
20 : #define EQSERVER_COMPOUNDACTIVATEVISITOR_H
21 :
22 : #include "compoundVisitor.h" // base class
23 :
24 : namespace eq
25 : {
26 : namespace server
27 : {
28 : /** The compound visitor (de-)activating channels of a compound tree. */
29 : class CompoundActivateVisitor : public CompoundVisitor
30 : {
31 : public:
32 4 : CompoundActivateVisitor(const bool activate, const Eye eye)
33 4 : : _activate(activate)
34 4 : , _eye(eye)
35 : {
36 4 : }
37 4 : virtual ~CompoundActivateVisitor() {}
38 : /** Visit all compounds. */
39 36 : virtual VisitorResult visit(Compound* compound)
40 : {
41 36 : Channel* channel = compound->getChannel();
42 36 : if (channel && compound->testInheritEye(_eye))
43 : {
44 16 : if (_activate)
45 : {
46 8 : channel->activate();
47 :
48 : // Fix https://github.com/Eyescale/Equalizer/issues/147
49 8 : compound->updateInheritTasks();
50 8 : channel->addTasks(compound->getInheritTasks());
51 : }
52 : else
53 8 : channel->deactivate();
54 : }
55 36 : return TRAVERSE_CONTINUE;
56 : }
57 :
58 : private:
59 : const bool _activate;
60 : const Eye _eye;
61 : };
62 : }
63 : }
64 : #endif // EQSERVER_COMPOUNDACTIVATEVISITOR_H
|