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/fe/Function.h
22 
23  \brief A function is a named procedure that performs a distinct computation.
24  */
25 
26 #ifndef __TERRALIB_FE_INTERNAL_FUNCTION_H
27 #define __TERRALIB_FE_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 fe
39  {
40  /*!
41  \class Function
42 
43  \brief A function is a named procedure that performs a distinct computation.
44 
45  A function may accept zero or more arguments
46  as input and generates a single result.
47 
48  \ingroup fe
49 
50  \sa Expression
51 
52  \todo Remover o uso do atributo nome de forma que as funcoes sejam registradas e de forma que se possa manter um pool das funcoes com os argumentos previamente alocados para cada tipo de funcao.
53  */
55  {
56  public:
57 
59 
60  /** @name Initializer Methods
61  * Methods related to instantiation and destruction.
62  */
63  //@{
64 
65  /*!
66  \brief It initializes a new Function.
67 
68  \param name Function name. Must be a non-empty value.
69  */
70  Function(const std::string& name);
71 
72  /*! \brief Destructor. */
73  ~Function();
74 
75  //@}
76 
77  /** @name Accessor methods
78  * Methods used to get or set properties.
79  */
80  //@{
81 
82  /*!
83  \brief It returns the function name.
84 
85  \return The function name.
86  */
87  const std::string& getName() const;
88 
89  /*!
90  \brief It sets the function name.
91 
92  \param n The function name.
93  */
94  void setName(const std::string& n);
95 
96  /*!
97  \brief It returns the argument in the specified position.
98 
99  \param i The argument index.
100 
101  \return The argument in the specified position.
102 
103  \note The argument index start at 0.
104 
105  \note It doesn't check the index range.
106  */
107  Expression* getArgument(size_t i) const;
108 
109  /*!
110  \brief It adds a new argument to the function.
111 
112  \param argument The argument to be added. The Function object will take the ownership of the given argument.
113  */
114  void add(Expression* argument);
115 
116  /*!
117  \brief It sets the argument in the specified position.
118 
119  \param i The argument index.
120  \param argument The new argument. The Function object will take the ownership of the given argument.
121 
122  \note The argument index start at 0.
123 
124  \note Be sure that the argument list is already defined having the location
125  you are specifying.
126 
127  \note It doesn't check the index range.
128  */
129  void setArgument(size_t i, Expression* argument);
130 
131  /*!
132  \brief It removes the n-th argument.
133 
134  \param i The argument index.
135 
136  \note It doesn't check the index range.
137  */
138  void removeArgument(size_t i);
139 
140  //@}
141 
142  /** @name Expression Re-implementation
143  * Methods re-implemented from Expression.
144  */
145  //@{
146 
147  virtual Expression* clone() const;
148 
149  //@}
150 
151  protected:
152 
153  std::string m_name; //!< Function name. (Mandatory)
154  std::vector<Expression*> m_argumentList; //!< Argument list (actually, a list of expressions). (Optional)
155  };
156 
157  } // end namespace fe
158 } // end namespace te
159 
160 #endif // __TERRALIB_FE_INTERNAL_FUNCTION_H
std::string m_name
Function name. (Mandatory)
Definition: Function.h:153
std::vector< Expression * > m_argumentList
Argument list (actually, a list of expressions). (Optional)
Definition: Function.h:154
#define TEFEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:59
A function is a named procedure that performs a distinct computation.
Definition: Function.h:54
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