Line data Source code
1 :
2 : /* Copyright (c) 2010, Cedric Stalder <cedric.stalder@gmail.com>
3 : * 2010-2013, Stefan Eilemann <eile@eyescale.ch>
4 : * 2011, Daniel Nachbaur <danielnachbaur@gmail.com>
5 : *
6 : * This library is free software; you can redistribute it and/or modify it under
7 : * the terms of the GNU Lesser General Public License version 2.1 as published
8 : * by the Free Software Foundation.
9 : *
10 : * This library is distributed in the hope that it will be useful, but WITHOUT
11 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 : * details.
14 : *
15 : * You should have received a copy of the GNU Lesser General Public License
16 : * along with this library; if not, write to the Free Software Foundation, Inc.,
17 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 : */
19 :
20 : #ifndef EQSERVER_CHANGELATENCYVISITOR_H
21 : #define EQSERVER_CHANGELATENCYVISITOR_H
22 :
23 : #include "compound.h"
24 : #include "configVisitor.h"
25 : #include "frame.h"
26 : #include "layout.h"
27 : #include "node.h"
28 : #include "observer.h"
29 : #include "segment.h"
30 : #include "tileQueue.h"
31 : #include "view.h"
32 :
33 : namespace eq
34 : {
35 : namespace server
36 : {
37 : /**
38 : * The Change Latency visitor modifies the latency on all relevant objects.
39 : */
40 0 : class ChangeLatencyVisitor : public ConfigVisitor
41 : {
42 : public:
43 0 : explicit ChangeLatencyVisitor( const uint32_t latency )
44 0 : : _latency( latency ) {}
45 :
46 0 : virtual VisitorResult visit( Compound* compound )
47 : {
48 0 : const Frames& outputFrames = compound->getOutputFrames();
49 0 : for( FramesCIter i = outputFrames.begin();
50 0 : i != outputFrames.end(); ++i )
51 : {
52 0 : Frame* frame = *i;
53 0 : frame->setAutoObsolete( _latency );
54 : }
55 :
56 0 : const Frames& inputFrames = compound->getInputFrames();
57 0 : for( FramesCIter i = inputFrames.begin();
58 0 : i != inputFrames.end(); ++i )
59 : {
60 0 : Frame* frame = *i;
61 0 : frame->setAutoObsolete( _latency );
62 : }
63 :
64 0 : const TileQueues& outputTileQueues = compound->getOutputTileQueues();
65 0 : for( TileQueuesCIter i = outputTileQueues.begin();
66 0 : i != outputTileQueues.end(); ++i )
67 : {
68 0 : TileQueue* queue = *i;
69 0 : queue->setAutoObsolete( _latency );
70 : }
71 :
72 0 : const TileQueues& inputTileQueues = compound->getInputTileQueues();
73 0 : for( TileQueuesCIter i = inputTileQueues.begin();
74 0 : i != inputTileQueues.end(); ++i )
75 : {
76 0 : TileQueue* queue = *i;
77 0 : queue->setAutoObsolete( _latency );
78 : }
79 0 : return TRAVERSE_CONTINUE;
80 : }
81 :
82 0 : virtual VisitorResult visitPre( Node* node )
83 : {
84 0 : node->changeLatency( _latency );
85 0 : return TRAVERSE_CONTINUE;
86 : }
87 :
88 0 : virtual VisitorResult visit( Observer* observer )
89 0 : { return _visit( observer ); }
90 :
91 0 : virtual VisitorResult visitPre( Layout* layout )
92 0 : { return _visit( layout ); }
93 0 : virtual VisitorResult visit( View* view )
94 0 : { return _visit( view ); }
95 :
96 0 : virtual VisitorResult visitPre( Segment* segment )
97 0 : { return _visit( segment ); }
98 0 : virtual VisitorResult visit( Segment* segment )
99 0 : { return _visit( segment ); }
100 :
101 : private:
102 : const uint32_t _latency;
103 :
104 0 : VisitorResult _visit( co::Object* object )
105 : {
106 : // double commit on update/delete
107 0 : object->setAutoObsolete( _latency + 1 );
108 0 : return TRAVERSE_CONTINUE;
109 : }
110 : };
111 :
112 : }
113 : }
114 : #endif // EQSERVER_CHANGELATENCYVISITOR
|