All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Function.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 terralib/dataaccess/query/Function.cpp
22 
23  \brief A class that models a Function expression.
24 */
25 
26 // TerraLib
27 #include "../../common/STLUtils.h"
28 #include "Function.h"
29 
30 // STL
31 #include <cassert>
32 
34  : m_name(rhs.m_name)
35 {
37 }
38 
40 {
42 }
43 
45 {
46  if(this != &rhs)
47  {
48  m_name = rhs.m_name;
50  m_args.clear();
51  te::common::Clone(rhs.m_args, m_args);
52  }
53 
54  return *this;
55 }
56 
58 {
59  return new Function(*this);
60 }
61 
62 std::size_t te::da::Function::getNumArgs() const
63 {
64  return m_args.size();
65 }
66 
68 {
69  assert(i < m_args.size());
70  return m_args[i];
71 }
72 
74 {
75  assert(i < m_args.size());
76  return m_args[i];
77 }
78 
80 {
81  m_args.push_back(arg);
82 }
83 
Expression * getArg(std::size_t i) const
It returns the i-th function argument.
Definition: Function.cpp:67
void add(Expression *arg)
It adds the argument to the function list of arguments.
Definition: Function.cpp:79
A class that models a Function expression.
TE_DEFINE_VISITABLE Function(const std::string &name)
Constructor.
Definition: Function.h:60
std::string m_name
The function name. May be an operator symbol or just a regular name like ST_Intersects.
Definition: Function.h:117
This is an abstract class that models a query expression.
Definition: Expression.h:47
Expression * clone() const
It creates a new copy of this expression.
Definition: Function.cpp:57
A class that models a Function expression.
Definition: Function.h:47
virtual ~Function()
Virtual Destructor.
Definition: Function.cpp:39
Expression * operator[](std::size_t i) const
It returns the i-th function argument.
Definition: Function.cpp:73
Function & operator=(const Function &rhs)
Definition: Function.cpp:44
std::vector< Expression * > m_args
The list of arguments.
Definition: Function.h:118
void Clone(const std::vector< T * > &src, std::vector< T * > &dst)
This function can be applied to a vector of pointers.
Definition: STLUtils.h:237
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition: BoostUtils.h:55
std::size_t getNumArgs() const
It returns the number of arguments informed to the function.
Definition: Function.cpp:62