~ubuntu-branches/ubuntu/wily/opencollada/wily-proposed

« back to all changes in this revision

Viewing changes to Externals/MathMLSolver/include/AST/MathMLASTVisitor.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
ImportĀ upstreamĀ versionĀ 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
Copyright (c) 2007 netAllied GmbH, Tettnang
 
3
 
 
4
Permission is hereby granted, free of charge, to any person
 
5
obtaining a copy of this software and associated documentation
 
6
files (the "Software"), to deal in the Software without
 
7
restriction, including without limitation the rights to use,
 
8
copy, modify, merge, publish, distribute, sublicense, and/or sell
 
9
copies of the Software, and to permit persons to whom the
 
10
Software is furnished to do so, subject to the following
 
11
conditions:
 
12
 
 
13
The above copyright notice and this permission notice shall be
 
14
included in all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
17
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 
18
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
19
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 
20
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 
21
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
22
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
23
OTHER DEALINGS IN THE SOFTWARE.
 
24
******************************************************************************/
 
25
 
 
26
#ifndef __MATHML_AST_VISITOR_H___
 
27
#define __MATHML_AST_VISITOR_H___
 
28
 
 
29
#include "MathMLSolverPrerequisites.h"
 
30
#include "MathMLASTNode.h"
 
31
#include "MathMLASTArithmeticExpression.h"
 
32
#include "MathMLASTLogicExpression.h"
 
33
#include "MathMLASTBinaryComparisionExpression.h"
 
34
#include "MathMLASTConstantExpression.h"
 
35
#include "MathMLASTUnaryArithmeticExpression.h"
 
36
#include "MathMLASTFragmentExpression.h"
 
37
#include "MathMLASTVariableExpression.h"
 
38
#include "MathMLASTFunctionExpression.h"
 
39
 
 
40
namespace MathML
 
41
{
 
42
 
 
43
    namespace AST
 
44
    {
 
45
 
 
46
        /** Interface of AST node visitor. */
 
47
 
 
48
        class _MATHML_SOLVER_EXPORT IVisitor
 
49
        {
 
50
 
 
51
        public:
 
52
 
 
53
            /** Virtual D-tor to make sure sub class D-tors are called. */
 
54
            virtual ~IVisitor()
 
55
            {}
 
56
 
 
57
            /** Callback for visiting of (specialized) arithmetic node.
 
58
                     @param node The arithmetic expression node.
 
59
                     */
 
60
            virtual void visit( const ArithmeticExpression* const node ) = 0;
 
61
 
 
62
            /** Callback for visiting of (specialized) binary comparision node.
 
63
            @param node The binary comparision expression node.
 
64
            */
 
65
            virtual void visit( const BinaryComparisonExpression* const node ) = 0;
 
66
 
 
67
            /** Callback for visiting of (specialized) fragment node.
 
68
            @param node The fragment expression node.
 
69
            */
 
70
            virtual void visit( const FragmentExpression* const node ) = 0;
 
71
 
 
72
            /** Callback for visiting of (specialized) logic node.
 
73
            @param node The logic expression node.
 
74
            */
 
75
            virtual void visit( const LogicExpression* const node ) = 0;
 
76
 
 
77
            /** Callback for visiting of (specialized) constant node.
 
78
            @param node The constant expression node.
 
79
            */
 
80
            virtual void visit( const ConstantExpression* const node ) = 0;
 
81
 
 
82
            /** Callback for visiting of (specialized) function node.
 
83
            @param node The function expression node.
 
84
            */
 
85
            virtual void visit( const FunctionExpression* const node ) = 0;
 
86
 
 
87
            /** Callback for visiting of (specialized) unary arithmetic node.
 
88
            @param node The unary arithmetic expression node.
 
89
            */
 
90
            virtual void visit( const UnaryExpression* const node ) = 0;
 
91
 
 
92
            /** Callback for visiting of (specialized) variable node.
 
93
            @param node The variable expression node.
 
94
            */
 
95
            virtual void visit( const VariableExpression* const node ) = 0;
 
96
 
 
97
                        virtual void visit( const INode* const node)
 
98
                        {
 
99
                                switch(node->getNodeType())
 
100
                                {
 
101
                                case INode::FRAGMENT:
 
102
                                        visit(static_cast<const FragmentExpression* const>(node));
 
103
                                        break;
 
104
 
 
105
                                case INode::ARITHMETIC:
 
106
                                        visit(static_cast<const ArithmeticExpression* const>(node));
 
107
                                        break;
 
108
 
 
109
                                case INode::COMPARISON:
 
110
                                        visit(static_cast<const BinaryComparisonExpression* const>(node));
 
111
                                        break;
 
112
 
 
113
                                case INode::CONSTANT:
 
114
                                        visit(static_cast<const ConstantExpression* const>(node));
 
115
                                        break;
 
116
 
 
117
                                case INode::FUNCTION:
 
118
                                        visit(static_cast<const FunctionExpression* const>(node));
 
119
                                        break;
 
120
 
 
121
                                case INode::LOGICAL:
 
122
                                        visit(static_cast<const LogicExpression* const>(node));
 
123
                                        break;
 
124
 
 
125
                                case INode::UNARY:
 
126
                                        visit(static_cast<const UnaryExpression* const>(node));
 
127
                                        break;
 
128
 
 
129
                                case INode::VARIABLE:
 
130
                                        visit(static_cast<const VariableExpression* const>(node));
 
131
                                        break;
 
132
                //to prevent WARNING for unusued enum USERDEFINED
 
133
                case INode::USERDEFINED:
 
134
                default:
 
135
                    break;
 
136
                                }
 
137
                        }
 
138
            
 
139
        };
 
140
 
 
141
        /** Default expression node visitor implementing AST-Node-Interface ('INode').
 
142
        @par Does nothing. Specialized Visitors have to implement/override the methods.
 
143
        */
 
144
 
 
145
        class _MATHML_SOLVER_EXPORT DefaultVisitor : public IVisitor
 
146
        {
 
147
 
 
148
        public:
 
149
            // see IVisitor::visit(const ArithmeticExpression&)
 
150
            virtual void visit( const ArithmeticExpression* const node )
 
151
            {}
 
152
 
 
153
            // see IVisitor::visit(const BinaryComparisionExpression&)
 
154
            virtual void visit( const BinaryComparisonExpression* const node )
 
155
            {}
 
156
 
 
157
            // see IVisitor::visit(const FragmentExpression&)
 
158
            virtual void visit( const FragmentExpression* const node )
 
159
            {}
 
160
 
 
161
            // see IVisitor::visit(const LogicExpression&)
 
162
            virtual void visit( const LogicExpression* const node )
 
163
            {}
 
164
 
 
165
            // see IVisitor::visit(const ConstantExpression&)
 
166
            virtual void visit( const ConstantExpression* const node )
 
167
            {}
 
168
 
 
169
            // see IVisitor::visit(const FunctionExpression&)
 
170
            virtual void visit( const FunctionExpression* const node )
 
171
            {}
 
172
 
 
173
            // see IVisitor::visit(const UnaryArithmeticExpression&)
 
174
            virtual void visit( const UnaryExpression* const node )
 
175
            {}
 
176
 
 
177
            // see IVisitor::visit(const VariableExpression&)
 
178
            virtual void visit( const VariableExpression* const node )
 
179
            {}
 
180
 
 
181
        }
 
182
 
 
183
        ;
 
184
 
 
185
    } //namespace AST
 
186
 
 
187
} //namespace MathML
 
188
 
 
189
#endif //__MATHML_AST_VISITOR_H___