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_UNARY_ARITHMETIC_EXPRESSION_H___
27 #define __MATHML_AST_UNARY_ARITHMETIC_EXPRESSION_H___
28 
29 #include "MathMLSolverPrerequisites.h"
30 #include "MathMLASTNode.h"
31 
32 namespace MathML
33 {
34 
35     namespace AST
36     {
37         /** String representation for enum Operator::ADD. */
38         static const String OPERATOR_UNARY_ADD = "+";
39         /** String representation for enum Operator::SUB. */
40         static const String OPERATOR_UNARY_SUB = "-";
41         /** String representation for enum Operator::NOT. */
42         static const String OPERATOR_UNARY_NOT = "!";
43         /** String representation for invalid operator. */
44         static const String OPERATOR_UNARY_ILLEGAL = "ILLEGAL";
45 
46         /** Specialized unary arithmetic node implementing INode. */
47 
48         class _MATHML_SOLVER_EXPORT UnaryExpression : public INode
49         {
50 
51         public:
52             /** Enumeration of the unary arithmetic operators. */
53             enum Operator
54             {
55                 ADD,
56                 SUB,
57                 NOT
58             };
59 
60         private:
61             /** The operand for the unary expression. */
62             INode* mOperand;
63 
64             /** The operator of the unary expression. */
65             Operator mOperator;
66 
67             /** Disable copy construction to avoid expensive deep copies of big trees.
68             */
69             UnaryExpression( const UnaryExpression& );
70             UnaryExpression& operator=( const UnaryExpression& );
71 
72         public:
73             /** C-tor. */
74             UnaryExpression();
75 
76             /** D-tor. */
77             virtual ~UnaryExpression();
78 
79             // see INode::accept(IVisitor* )
80             virtual void accept( IVisitor* visitor ) const;
81 
82 			// see INode::getType()
getNodeType()83 			virtual NodeType getNodeType() const { return UNARY; }
84 
85             /** @return a copy of this node. */
86             virtual INode* clone(CloneFlags cloneFlags) const;
87 
88             /** Getter for the operator of the unary expression.
89             @return The operator of the expression.
90             */
91             virtual Operator getOperator() const;
92 
93             /** Setter for the operator of the unary expression.
94             @param op The operator to set.
95             */
96             virtual void setOperator( Operator op );
97 
98             /** Getter for the operator of the unary expression.
99             @return The operator of the expression as string.
100             */
101             virtual const String& getOperatorString() const;
102 
103             /** Setter for the operator of the unary expression.
104             @param op The operator to set as string.
105             */
106             virtual void setOperator( const String& op );
107 
108             /** Getter for the operand of the unary expression.
109             @return The operand of the expression.
110             */
111             virtual INode* getOperand() const;
112 
113             /** Setter for the operand of the unary expression.
114             @param operand The operand to set.
115             */
116             virtual void setOperand( INode* operand );
117 
118             /** Returns a string representation of passed operator. */
119             static const String& operatorString( Operator op );
120         };
121 
122     } //namespace AST
123 
124 } //namespace MathML
125 
126 #endif //__MATHML_AST_UNARY_ARITHMETIC_EXPRESSION_H___
127