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_VARIABLE_EXPRESSION_H___
27 #define __MATHML_AST_VARIABLE_EXPRESSION_H___
28 
29 #include "MathMLSolverPrerequisites.h"
30 #include "MathMLString.h"
31 #include "MathMLASTNode.h"
32 #include "MathMLASTConstantExpression.h"
33 
34 namespace MathML
35 {
36 
37     namespace AST
38     {
39 
40         /** Specialized variable node implementing INode. */
41 
42         class _MATHML_SOLVER_EXPORT VariableExpression : public INode
43         {
44 
45         private:
46             /** The name of the variable. */
47             String mName;
48 
49             /** The value of the variable. */
50             ConstantExpression* mValue;
51 
52         public:
53             /** Initializing constructor.
54             @param name The name of the variable
55             */
56             VariableExpression( const String& name );
57 
58             /** D-tor. */
59             virtual ~VariableExpression();
60 
61             // see INode::accept(IVisitor* )
62             virtual void accept( IVisitor* visitor ) const;
63 
64 			// see INode::getType()
getNodeType()65 			virtual NodeType getNodeType() const { return VARIABLE; }
66 
67             /** @return a copy of this node. */
68             virtual INode* clone(CloneFlags cloneFlags) const;
69 
70             /** Getter for the name of the variable.
71             @return The name of the variable.
72             */
73             virtual const String& getName() const;
74 
75             /** Getter for value of the variable.
76             @par If variable is not initialized, the scalar holding the value is
77             of type 'SCALAR_INVALID'.
78             @return The ConstantExpression holding the value of the variable.
79             */
80             virtual const ConstantExpression* getValue() const;
81 
82             /** Setter for the value of the variable.
83             @param value The ConstantExpression to set as value.
84             */
85             virtual void setValue( ConstantExpression* value ) ;
86 			virtual void setValue( int value ) ;
87 			virtual void setValue( long value ) ;
88 			virtual void setValue( double value ) ;
89 			virtual void setValue( bool value ) ;
90         };
91 
92     } //namespace AST
93 
94 } //namespace MathML
95 
96 #endif //__MATHML_AST_VARIABLE_EXPRESSION_H___
97