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 2 : ConfigRegistrator() {}
34 2 : virtual ~ConfigRegistrator() {}
35 2 : virtual VisitorResult visit(Observer* observer)
36 : {
37 : // double commit on update/delete
38 2 : return _register(observer, observer->getConfig()->getLatency() + 1);
39 : }
40 :
41 2 : virtual VisitorResult visit(Segment* segment)
42 : {
43 : // double commit on update/delete
44 2 : return _register(segment, segment->getConfig()->getLatency() + 1);
45 : }
46 :
47 2 : virtual VisitorResult visitPost(Canvas* canvas)
48 : {
49 : // double commit on update/delete
50 2 : return _register(canvas, canvas->getConfig()->getLatency() + 1);
51 : }
52 :
53 14 : virtual VisitorResult visit(View* view)
54 : {
55 : // double commit on update/delete
56 14 : return _register(view, view->getConfig()->getLatency() + 1);
57 : }
58 :
59 14 : virtual VisitorResult visitPost(Layout* layout)
60 : {
61 : // double commit on update/delete
62 14 : return _register(layout, layout->getConfig()->getLatency() + 1);
63 : }
64 :
65 18 : virtual VisitorResult visit(Channel* channel)
66 : {
67 18 : return _register(channel, 0);
68 : }
69 4 : virtual VisitorResult visitPost(Window* window)
70 : {
71 4 : return _register(window, 0);
72 : }
73 4 : virtual VisitorResult visitPost(Pipe* pipe) { return _register(pipe, 0); }
74 2 : virtual VisitorResult visitPost(Node* node) { return _register(node, 0); }
75 132 : virtual VisitorResult visit(Compound* compound)
76 : {
77 132 : compound->register_();
78 132 : return TRAVERSE_CONTINUE;
79 : }
80 :
81 2 : virtual VisitorResult visitPost(Config* config)
82 : {
83 2 : return _register(config, 0);
84 : }
85 :
86 : private:
87 : template <class O>
88 64 : VisitorResult _register(O* object, const uint32_t nBuffers)
89 : {
90 128 : ServerPtr server = object->getServer();
91 64 : LBASSERT(!object->isAttached());
92 64 : server->registerObject(object);
93 64 : if (nBuffers > 0)
94 34 : object->setAutoObsolete(nBuffers);
95 128 : return TRAVERSE_CONTINUE;
96 : }
97 : };
98 : }
99 : }
100 : }
101 : #endif // EQSERVER_CONFIGREGISTRATOR_H
|