Loading...
Searching...
No Matches
FunctionDefn.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/FunctionDefn.h
22
23 \brief The definition of a function that can be used in a query object.
24*/
25
26#ifndef __TERRALIB_DATAACCESS_INTERNAL_FUNCTIONDEFN_H
27#define __TERRALIB_DATAACCESS_INTERNAL_FUNCTIONDEFN_H
28
29// TerraLib
30#include "../../datatype/Enums.h"
31#include "../Config.h"
32
33// STL
34#include <string>
35#include <vector>
36
37// Boost
38#include <boost/noncopyable.hpp>
39
40namespace te
41{
42 namespace da
43 {
44// Forward declarations
45 class FunctionParameter;
46
47 /*!
48 \class FunctionDefn
49
50 \brief The definition of a function that can be used in a query object.
51
52 All functions must have a name in lower case letters.
53
54 \sa FunctionCatalog, FunctionCatalogManager, FunctionParameter
55 */
56 class TEDATAACCESSEXPORT FunctionDefn : public boost::noncopyable
57 {
58 public:
59
60 /*!
61 \brief Constructor.
62
63 \param name The function name.
64 \param retValType The return value type (void by default).
65 \param isAggregate Tells if function is an aggregate function (false by default).
66 \param description A brief description about the function (NULL by default). The FunctionDefn will take the ownership of the given description.
67 */
68 FunctionDefn(const std::string& name,
69 int retValType = te::dt::VOID_TYPE,
70 bool isAggregate = false,
71 std::string* description = 0);
72
73 /*! \brief Destructor. */
75
76 /*!
77 \brief It returns the function name.
78
79 \return The function name.
80 */
81 const std::string& getName() const { return m_name; }
82
83 /*!
84 \brief It sets the function name;
85
86 \param name The function name.
87
88 \note If the function belongs to a FunctionCatalog, don't call this method!
89 */
90 void setName(const std::string& name) { m_name = name; }
91
92 /*!
93 \brief It returns the data type of the return value.
94
95 \return The data type of the return value.
96 */
97 int getRetValType() const { return m_retValType; }
98
99 /*!
100 \brief It sets the data type of the return value.
101
102 \param r The data type of the return value.
103 */
104 void setRetValType(int r) { m_retValType = r; }
105
106 /*!
107 \brief It returns true if it is an aggregate function, otherwise, returns false.
108
109 \return True if it is an aggregate function, otherwise, returns false.
110 */
111 bool isAggregate() const { return m_isAggregate; }
112
113 /*!
114 \brief It tells if the function is an aggregate function or not.
115
116 \param a If true the function is an aggeragte function otherwise it is not.
117 */
118 void SetIsAggregate(bool a) { m_isAggregate = a; }
119
120 /*!
121 \brief It returns a brief description about the function.
122
123 \return A brief description about the function or NULL if none is provide.
124 */
125 std::string* getDescription() const { return m_description; };
126
127 /*!
128 \brief It sets a brief description about the function.
129
130 \param description A brief description about the function. The FunctionDefn will take the ownership of the given description.
131 */
132 void setDescription(std::string* description);
133
134 /*!
135 \brief It returns the number of parameters for the function.
136
137 \return The number of parameters.
138 */
139 std::size_t getNumParams() const { return m_params.size(); }
140
141 /*!
142 \brief It returns the i-th function parameter.
143
144 \param i The parameter position.
145
146 \return The i-th function parameter.
147
148 \note It will not check the index range.
149 */
150 FunctionParameter* operator[](std::size_t i) const { return m_params[i]; }
151
152 /*!
153 \brief It adds the parameter to the function list of parameters.
154
155 \param p The parameter to be added.
156
157 \note The FunctionDefn will take the ownership of the given parameter.
158 */
159 void add(FunctionParameter* p) { m_params.push_back(p); }
160
161 protected:
162
163 std::string m_name; //!< The function name. It may be an operator symbol or just a regular name like st_intersects.
164 std::vector<FunctionParameter*> m_params; //!< The list of arguments.
165 int m_retValType; //!< Data type of the return value.
166 bool m_isAggregate; //!< A flag that defines if the function is an aggregate one.
167 std::string* m_description; //!< A brief description of the function.
168 //int m_cost; //!< Estimated execution cost.
169 };
170
171 } // end namespace da
172} // end namespace te
173
174#endif // __TERRALIB_DATAACCESS_INTERNAL_FUNCTIONDEFN_H
175
The definition of a function that can be used in a query object.
Definition: FunctionDefn.h:57
std::string m_name
The function name. It may be an operator symbol or just a regular name like st_intersects.
Definition: FunctionDefn.h:163
void add(FunctionParameter *p)
It adds the parameter to the function list of parameters.
Definition: FunctionDefn.h:159
FunctionDefn(const std::string &name, int retValType=te::dt::VOID_TYPE, bool isAggregate=false, std::string *description=0)
Constructor.
std::string * getDescription() const
It returns a brief description about the function.
Definition: FunctionDefn.h:125
void setDescription(std::string *description)
It sets a brief description about the function.
void setRetValType(int r)
It sets the data type of the return value.
Definition: FunctionDefn.h:104
std::size_t getNumParams() const
It returns the number of parameters for the function.
Definition: FunctionDefn.h:139
bool isAggregate() const
It returns true if it is an aggregate function, otherwise, returns false.
Definition: FunctionDefn.h:111
void setName(const std::string &name)
It sets the function name;.
Definition: FunctionDefn.h:90
std::vector< FunctionParameter * > m_params
The list of arguments.
Definition: FunctionDefn.h:164
int m_retValType
Data type of the return value.
Definition: FunctionDefn.h:165
FunctionParameter * operator[](std::size_t i) const
It returns the i-th function parameter.
Definition: FunctionDefn.h:150
std::string * m_description
A brief description of the function.
Definition: FunctionDefn.h:167
~FunctionDefn()
Destructor.
const std::string & getName() const
It returns the function name.
Definition: FunctionDefn.h:81
bool m_isAggregate
A flag that defines if the function is an aggregate one.
Definition: FunctionDefn.h:166
int getRetValType() const
It returns the data type of the return value.
Definition: FunctionDefn.h:97
void SetIsAggregate(bool a)
It tells if the function is an aggregate function or not.
Definition: FunctionDefn.h:118
A FunctionParameter models the parameter of a function definition.
@ VOID_TYPE
Definition: Enums.h:186
TerraLib.
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97