Function.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/dataaccess/query/Function.h
22 
23  \brief A class that models a Function expression.
24 */
25 
26 #ifndef __TERRALIB_DATAACCESS_INTERNAL_FUNCTION_H
27 #define __TERRALIB_DATAACCESS_INTERNAL_FUNCTION_H
28 
29 // TerraLib
30 #include "Expression.h"
31 
32 // STL
33 #include <string>
34 #include <vector>
35 
36 namespace te
37 {
38  namespace da
39  {
40  /*!
41  \class Function
42 
43  \brief A class that models a Function expression.
44 
45  \sa Expression
46  */
48  {
49  public:
50 
52 
53  /*!
54  \brief Constructor.
55 
56  \param name The function name.
57 
58  \note See FunctionNames.h for a list of common names.
59  */
60  Function(const std::string& name) : m_name(name) {}
61 
62  /*! \brief Copy constructor. */
63  Function(const Function& rhs);
64 
65  /*! \brief Virtual Destructor. */
66  virtual ~Function();
67 
68  /*! Assignment operator. */
69  Function& operator=(const Function& rhs);
70 
71  /*! \brief It creates a new copy of this expression. */
72  Expression* clone() const;
73 
74  /*!
75  \brief It returns the function name.
76 
77  \return The function name.
78  */
79  const std::string& getName() const { return m_name; };
80 
81  /*!
82  \brief It returns the number of arguments informed to the function.
83 
84  \return The number of parameters.
85  */
86  std::size_t getNumArgs() const;
87 
88  /*!
89  \brief It returns the i-th function argument.
90 
91  \param i The argument position.
92 
93  \return The it-th function argument.
94  */
95  Expression* getArg(std::size_t i) const;
96 
97  /*!
98  \brief It returns the i-th function argument.
99 
100  \param i The argument position.
101 
102  \return The it-th function argument.
103  */
104  Expression* operator[](std::size_t i) const;
105 
106  /*!
107  \brief It adds the argument to the function list of arguments.
108 
109  \param arg The argument to be added.
110 
111  \note The Function will take the ownership of the given argument.
112  */
113  void add(Expression* arg);
114 
115  protected:
116 
117  std::string m_name; //!< The function name. May be an operator symbol or just a regular name like ST_Intersects.
118  std::vector<Expression*> m_args; //!< The list of arguments.
119  };
120 
121  } // end namespace da
122 } // end namespace te
123 
124 #endif // __TERRALIB_DATAACCESS_INTERNAL_FUNCTION_H
125 
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
URI C++ Library.
This is an abstract class that models a query expression.
A class that models a Function expression.
Definition: Function.h:47
const std::string & getName() const
It returns the function name.
Definition: Function.h:79
#define TE_DEFINE_VISITABLE
Definition: BaseVisitable.h:75
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97
std::vector< Expression * > m_args
The list of arguments.
Definition: Function.h:118