All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BinaryOperator.cpp
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 BinaryOperator.cpp
22 
23  \brief This class can be used to represent binary operation expressions.
24  */
25 
26 // TerraLib
27 #include "BinaryOperator.h"
28 #include "Globals.h"
29 
30 // STL
31 #include <cassert>
32 
34  : m_opName(opName),
35  m_first(0),
36  m_second(0)
37 {
38 }
39 
40 te::fe::BinaryOperator::BinaryOperator(const char* opName, Expression* first, Expression* second)
41  : m_opName(opName),
42  m_first(first),
43  m_second(second)
44 {
45 }
46 
48 {
49  delete m_first;
50  delete m_second;
51 }
52 
54 {
55  delete m_first;
56  m_first = first;
57 }
58 
60 {
61  return m_first;
62 }
63 
65 {
66  delete m_second;
67  m_second = second;
68 }
69 
71 {
72  return m_second;
73 }
74 
76 {
77  te::fe::Expression* arg1;
78  m_first ? arg1 = m_first->clone() : arg1 = 0;
79 
80  te::fe::Expression* arg2;
81  m_second ? arg2 = m_second->clone() : arg2 = 0;
82 
83  return new BinaryOperator(m_opName, arg1, arg2);
84 }
virtual ~BinaryOperator()
Virtual destructor.
void setFirst(Expression *first)
It sets the first operand.
virtual Expression * clone() const =0
It returns a clone of this object.
This class can be used to represent binary operation expressions.
This is an abstract class that models a Filter Encoding expression.
Definition: Expression.h:50
Expression * getSecond() const
It returns the second operand.
Expression * getFirst() const
It returns the first operand.
void setSecond(Expression *second)
It sets the second operand.
An static class with global definitions.
This class can be used to represent binary operation expressions.
BinaryOperator(const char *opName=0)
It initializes a new BinaryOperator.
virtual Expression * clone() const
It returns a clone of this object.