Line data Source code
1 :
2 : /* Copyright (c) 2007-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_COMPOUNDVISITOR_H
19 : #define EQSERVER_COMPOUNDVISITOR_H
20 :
21 : #include "types.h"
22 : #include "visitorResult.h" // enum
23 :
24 : namespace eq
25 : {
26 : namespace server
27 : {
28 : /** A visitor to traverse a non-const compound tree. */
29 : class CompoundVisitor
30 : {
31 : public:
32 : /** Constructs a new CompoundVisitor. */
33 11172 : CompoundVisitor() {}
34 : /** Destruct the CompoundVisitor */
35 11172 : virtual ~CompoundVisitor() {}
36 : /** Visit a non-leaf compound on the down traversal. */
37 5454 : virtual VisitorResult visitPre(Compound* compound)
38 : {
39 5454 : return visit(compound);
40 : }
41 : /** Visit a leaf compound. */
42 3980 : virtual VisitorResult visitLeaf(Compound* compound)
43 : {
44 3980 : return visit(compound);
45 : }
46 : /** Visit a non-leaf compound on the up traversal. */
47 3074 : virtual VisitorResult visitPost(Compound* compound)
48 : {
49 3074 : return visitPost(static_cast<const Compound*>(compound));
50 : }
51 :
52 : /** Visit every compound on the down traversal. */
53 2348 : virtual VisitorResult visit(Compound* compound)
54 : {
55 2348 : return visit(static_cast<const Compound*>(compound));
56 : }
57 :
58 : /** Visit a non-leaf compound on the down traversal. */
59 0 : virtual VisitorResult visitPre(const Compound* compound)
60 : {
61 0 : return visit(compound);
62 : }
63 : /** Visit a leaf compound. */
64 0 : virtual VisitorResult visitLeaf(const Compound* compound)
65 : {
66 0 : return visit(compound);
67 : }
68 : /** Visit a non-leaf compound on the up traversal. */
69 3074 : virtual VisitorResult visitPost(const Compound*)
70 : {
71 3074 : return TRAVERSE_CONTINUE;
72 : }
73 :
74 : /** Visit every compound on the down traversal. */
75 2348 : virtual VisitorResult visit(const Compound*) { return TRAVERSE_CONTINUE; }
76 : };
77 : }
78 : }
79 : #endif // EQSERVER_COMPOUNDVISITOR_H
|