Line data Source code
1 :
2 : /* Copyright (c) 2010-2013, 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 : #ifndef EQSERVER_CONFIGREGISTRATOR_H
19 : #define EQSERVER_CONFIGREGISTRATOR_H
20 :
21 : #include "configVisitor.h" // base class
22 :
23 : namespace eq
24 : {
25 : namespace server
26 : {
27 : namespace
28 : {
29 : /** Registers all objects of a config. @internal */
30 : class ConfigRegistrator : public ConfigVisitor
31 : {
32 : public:
33 10 : ConfigRegistrator() {}
34 10 : virtual ~ConfigRegistrator() {}
35 :
36 10 : virtual VisitorResult visit( Observer* observer )
37 : {
38 : // double commit on update/delete
39 : return _register( observer,
40 10 : observer->getConfig()->getLatency() + 1 );
41 : }
42 :
43 10 : virtual VisitorResult visit( Segment* segment )
44 : {
45 : // double commit on update/delete
46 : return _register( segment,
47 10 : segment->getConfig()->getLatency() + 1 );
48 : }
49 :
50 10 : virtual VisitorResult visitPost( Canvas* canvas )
51 : {
52 : // double commit on update/delete
53 : return _register( canvas,
54 10 : canvas->getConfig()->getLatency() + 1 );
55 : }
56 :
57 63 : virtual VisitorResult visit( View* view )
58 : {
59 : // double commit on update/delete
60 : return _register( view,
61 63 : view->getConfig()->getLatency() + 1 );
62 : }
63 :
64 63 : virtual VisitorResult visitPost( Layout* layout )
65 : {
66 : // double commit on update/delete
67 : return _register( layout,
68 63 : layout->getConfig()->getLatency() + 1 );
69 : }
70 :
71 86 : virtual VisitorResult visit( Channel* channel )
72 : {
73 86 : return _register( channel, 0 );
74 : }
75 23 : virtual VisitorResult visitPost( Window* window )
76 : {
77 23 : return _register( window, 0 );
78 : }
79 23 : virtual VisitorResult visitPost( Pipe* pipe )
80 : {
81 23 : return _register( pipe, 0 );
82 : }
83 15 : virtual VisitorResult visitPost( Node* node )
84 : {
85 15 : return _register( node, 0 );
86 : }
87 :
88 435 : virtual VisitorResult visit( Compound* compound )
89 : {
90 435 : compound->register_();
91 435 : return TRAVERSE_CONTINUE;
92 : }
93 :
94 10 : virtual VisitorResult visitPost( Config* config )
95 : {
96 10 : return _register( config, 0 );
97 : }
98 :
99 : private:
100 : template< class O >
101 313 : VisitorResult _register( O* object, const uint32_t nBuffers )
102 : {
103 313 : ServerPtr server = object->getServer();
104 313 : LBASSERT( !object->isAttached() );
105 313 : server->registerObject( object );
106 313 : if( nBuffers > 0 )
107 156 : object->setAutoObsolete( nBuffers );
108 313 : return TRAVERSE_CONTINUE;
109 : }
110 : };
111 : }
112 : }
113 : }
114 : #endif // EQSERVER_CONFIGREGISTRATOR_H
|