BinaryOperator.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/fe/BinaryOperator.h
22 
23  \brief This class can be used to represent binary operation expressions.
24  */
25 
26 #ifndef __TERRALIB_FE_INTERNAL_BINARYOPERATOR_H
27 #define __TERRALIB_FE_INTERNAL_BINARYOPERATOR_H
28 
29 // TerraLib
30 #include "Expression.h"
31 
32 // STL
33 #include <set>
34 
35 namespace te
36 {
37  namespace fe
38  {
39  /*!
40  \class BinaryOperator
41 
42  \brief This class can be used to represent binary operation expressions.
43 
44  The BinaryOperator class can be used to encode
45  the fundamental arithmetic operations of addition,
46  subtraction, multiplication and division. Arithmetic
47  operators are binary operators meaning that they
48  accept two arguments and evaluate to a single result.
49  <br>
50  The following operators are defined in the Filter
51  Encoding specification:
52  <ul>
53  <li>Add</li>
54  <li>Sub</li>
55  <li>Mul</li>
56  <li>Div</li>
57  </ul>
58  Of course, you can extend the list of supported binary operators.
59 
60  \ingroup fe
61 
62  \sa Expression
63 
64  \todo Mostrar como a pessoa pode estender a lista de operadores binarios!
65  */
67  {
68  public:
69 
71 
72  /** @name Initializer Methods
73  * Methods related to instantiation and destruction.
74  */
75  //@{
76 
77  /*!
78  \brief It initializes a new BinaryOperator.
79 
80  \param opName The operator name.
81 
82  \note The BinaryOperator will not take the ownership of the given name.
83  */
84  BinaryOperator(const char* opName = 0);
85 
86  /*!
87  \brief It initializes a new BinaryOperator.
88 
89  \param opName The operator name.
90  \param first The <i>first</i> operand.
91  \param second The <i>second</i> operand.
92 
93  \note The BinaryOperator will not take the ownership of the given name.
94 
95  \note It will take the ownership of the <i>first</i> and <i>second</i> operands.
96  */
97  BinaryOperator(const char* opName, Expression* first, Expression* second);
98 
99  /*! \brief Virtual destructor. */
100  virtual ~BinaryOperator();
101 
102  //@}
103 
104  /** @name Accessor methods
105  * Methods used to get or set properties.
106  */
107  //@{
108 
109  /*!
110  \brief It returns the operator name.
111 
112  \return The operator name.
113  */
114  const char* getName() const { return m_opName; }
115 
116  /*!
117  \brief It sets the <i>first operand</i>.
118 
119  \param first The <i>first operand</i>.
120 
121  \note The binary operator will take the ownership of the <i>first operand</i>.
122  */
123  void setFirst(Expression* first);
124 
125  /*!
126  \brief It returns the <i>first operand</i>.
127 
128  \return The <i>first operand</i>.
129  */
130  Expression* getFirst() const;
131 
132  /*!
133  \brief It sets the <i>second operand</i>.
134 
135  \param second The <i>second</i> operand.
136 
137  \note It will take the ownership of the <i>second operand</i>.
138  */
139  void setSecond(Expression* second);
140 
141  /*!
142  \brief It returns the <i>second operand</i>.
143 
144  \return The <i>second operand</i>.
145  */
146  Expression* getSecond() const;
147 
148  //@}
149 
150  /** @name Expression Re-implementation
151  * Methods re-implemented from Expression.
152  */
153  //@{
154 
155  virtual Expression* clone() const;
156 
157  //@}
158 
159  private:
160 
161  const char* m_opName; //!< The operator name. (Mandatory)
162  Expression* m_first; //!< First operand (an expression). (Mandatory)
163  Expression* m_second; //!< Second operand (an expression). (Mandatory)
164  };
165 
166  } // end namespace fe
167 } // end namespace te
168 
169 #endif // __TERRALIB_FE_INTERNAL_BINARYOPERATOR_H
Expression * m_second
Second operand (an expression). (Mandatory)
Expression * m_first
First operand (an expression). (Mandatory)
#define TEFEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:59
This class can be used to represent binary operation expressions.
URI C++ Library.
This is an abstract class that models a Filter Encoding expression.
Definition: Expression.h:50
This is an abstract class that models a Filter Encoding expression.
#define TE_DEFINE_VISITABLE
Definition: BaseVisitable.h:75
const char * m_opName
The operator name. (Mandatory)
const char * getName() const
It returns the operator name.